我在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