而不是为for循环放入40我想获得数组的长度,这是我想要存储文件中的信息的地方。我会使用strlen或sizeof吗?总的来说,我将如何从文件中获取信息,然后将其存储在数组中,以获得40循环所在的for循环中的数组大小。谢谢。另外我假设使用strlen,对吗?
Int40 *loadPlainText(char *fname){//declare function
int i; //for eventual for loop
char c;//declare character c
Int40 *Point=createInt40(); //call the create function because it returns a pointer to the int40 struct that holds an array filled with 0s
//something has to catch the value that the function returns. thats why its equal to structure
FILE* ifp = fopen(inputFilename, "r");//opens thew file in read mode
int arr[40];//declare an array
for(i=0;i<=40;i++){//for loop
fscanf(ifp, "%c", &arr[i]);//read file into an array
Point->digits[i]=c;
}//end for loop
return Point;//return the pointer
}//end function