【发布时间】:2014-06-10 15:11:49
【问题描述】:
我试图在我的 C 程序中打印出逗号分隔的值,但我认为我一直在获得内存分配。 从命令行运行时,会发生这种情况。
1
49 this is the response
10 this is the response
1
49 this is the response
10 this is the response
这是我的程序:
void main(){
int j;
int idnum;
j = 0;
char entry[99];
do{
idnum = get_field(entry);
j++;
}
while(idnum!='\n' && idnum!= ',' && j!= MAXTYPES);
int recur = 0;
while (recur != 4){
printf("%4d\n", entry[recur]);
recur++;
}
printf("\nEnd of Input\n");
}
int get_field(char entry[]){
int idnum;
char n;
int j = 0;
char temp[45];
while ((n=getchar())!= EOF){
printf("%d this is the response\n",n);
}
return idnum;
}
【问题讨论】:
-
也许你想要
printf("%c this is the response\n",n);?