- #1
Peon666
- 108
- 0
I'm writing an SJF scheduling algo and I'm having a little problem with filing. I'm to read data from a file. I've read the entire data in a single array/pointer but now I want to read every line in a separate array/pointer/string. I'm not able to do so. Ay help would be highly appreciated.
Here's the code so far:
How can I read each line in a separate array/string/pointer?
Thanks.
Here's the code so far:
Code:
int main ()
{
FILE *fptr;
int i;
printf ("Output from the file");
char s[500];
int count = 0;
fptr = fopen ("file.txt","r");
if (!f)
{
return 1;
}
while (fgets(s,1000,fptr) != NULL)
printf ("%s",s);
fclose(fptr);
return 0;
}
How can I read each line in a separate array/string/pointer?
Thanks.