我在C新型..并且仍然具有语法麻烦,希望你能帮助我......因为我在这个代码困惑的C语法
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main(void){
FILE *stream = NULL;
stream = fopen("studentinfo.txt", "a+");
/*some of initialization were used for testing purposes only*/
char arr[5];
char arr2[5];
int i;
char name[3];
char course[5];
printf("enter details: ");
scanf("%s", arr2);
while(!feof(stream)){
fgets(arr, 100, stream);//i am confused if the line capture was stored at arr[0]
if(strcmp(arr, arr2)==0){//i want to compare
printf("success");//testing
}
printf("%s", arr);//i wonder does fgets just overwrites the new line to arr[0]
}
fclose(stream);
getch();
}
感谢球员很卡.. 。
试着将所有的代码格式化为代码,它会帮助我们来帮助你。问一些具体的问题 - 你告诉我们的是,你仍然在语法上遇到问题。这种邀请的回应是'阅读许多优秀的在线教程或解释C语法的书籍之一'。 – 2010-12-03 09:29:40
有什么问题?你想要它做什么?你得到了什么错误? – Muggen 2010-12-03 09:30:18
@ muggen:我实际上被指示去做一个学生信息系统......而且我在编辑其中一行时遇到了麻烦......我们被要求稍后向用户询问学生ID并编辑信息。 。我正在考虑首先捕获该行,然后将其与用户的输入进行比较...希望您可以提前帮助我... thnx – iamanapprentice 2010-12-03 09:45:24