摘要: 我有一个程序是这样的:int main(){ int *p; int i; int*fun(void); p=fun(); for(i=0;i<3;i++) { printf("%d\n",*p); p++; } return 0;};int* fun(void){ static int str[]={1,2,3,4,5}; int*q=str; return q;}我想问一下,除了将str定义为静态区以及用malloc这样的方法外,还有什么好的方法,同时也想问一下如果我改成int main(){ char *p; char*fun(void); p=fun(); p 阅读全文
posted @ 2012-10-22 09:19 SA高处不胜寒 阅读(713) 评论(0) 推荐(1) 编辑
摘要: 请问以下两段代码输出为什么会不同?代码1:void main(){ char a[10]; cin.getline(a,10); //输入"123456789" cout << a << endl; //输出"123456789" cout << cin.gcount(); //输出10}代码2:void main(){ char a[10]; cin.getline(a,10); //输入"1234567890" cout << a << endl; //输出"1 阅读全文
posted @ 2012-10-22 08:54 SA高处不胜寒 阅读(857) 评论(0) 推荐(0) 编辑
摘要: #include <iostream>#include <vector>#include <fstream>using namespace std;int main(void){ ifstream fp("I:\\temp.txt"); vector< vector<double> > tmp; // string str; char str[100]; double i; char *ch,*ch1; int num; while(!fp.eof()) { vector<double> m1; // 阅读全文
posted @ 2012-10-22 08:52 SA高处不胜寒 阅读(746) 评论(0) 推荐(0) 编辑