+ 2
How to create a function a .txt line in C to be read, to be used of like (*file,"test.txt")
Create a function with args FILE and const char
2 ответов
+ 4
Look at the fopen() function in the C tutorial.
+ 1
You can create a function with args FILE and const char to read from pointer fptr like this:-
/*Here goes the function declaration*/
int ReadFromFile(FILE *fptr, const char *filename);
/*Here goes the function definition*/
int ReadFromFile(FILE *fptr, const char *filename)
{
if(fptr = fopen(filename, "r"))
{
printf("Error file doesn't exist");
return -1;
}
else
{ while(!feof(fptr))
{ putchar(getc(fptr));}
return 0;
}
}
I hope this helped u....😃😃