我想從代碼內部打開兩個文件,但我無法嘗試從first.txt獲取我的三個數字,但它只打印第一個。我只需要幫助從我的文本文件打印所有的數字,所以不需要完成我的整個程序,但建議歡迎:)!比較來自c中兩個文件的數字;使用fopen等
int main(int argc, char **argv)
{
int *number1Pointer = malloc(80 * sizeof(int));
FILE *file1;
//FILE *file2;
file1 = fopen("first.txt", "r");
//file2 = fopen("second.txt", "r");
int read = fscanf(file1, "%d", number1Pointer);
if(read != '\0')
{
printf("%d", &number1Pointer);
}
else
{
fclose(file1);
}
return 0;
}
程序示例:http://ideone.com/YxjE4Z – congusbongus 2013-02-26 00:20:50