+ 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

6th Jul 2019, 4:01 AM
Rafael Santos
Rafael Santos - avatar
2 Antworten
+ 4
Look at the fopen() function in the C tutorial.
6th Jul 2019, 4:52 AM
Sonic
Sonic - avatar
+ 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....😃😃
11th Jul 2019, 9:50 AM
Yashvardhan
Yashvardhan - avatar