I have accomplished getting my c program to read text line by line. That was the easy part or at least in my perspective. What i need to do now is to assign variables per line. For Example the first line of the text file would be equal to the variable line1.
Or this
char line1 = (text from line one)
char line2 = (text from line two)
My code thus far:
char line[1000] = "";
FILE *ifp;
ifp = fopen("Tree-B.txt", "r");
if (ifp == NULL)
{
printf("Error opening file!\n");
exit(1);
}
while (fscanf(ifp, "%s", line) == 1)
{
printf("%s ", line);
}
printf("\n");
fclose(ifp);
return 0;
I have absolutely no idea how to do this.