FILE *ranch;
FILE *myfile;
char line[500];
case 1:
ranch=fopen("garrudaRanch.txt ","w+");
if(ranch != NULL)
{
printf("Enter amount of Corral: \n");
scanf("%d",&corral);
fprintf(ranch,"%d\n",corral);
printf("Enter size of Corral: \n");
scanf("%d",&corrals);
fprintf(ranch,"%d\n",corrals);
}
fclose(ranch);
break;
case 2:
myfile=fopen("garrudaRanch.txt ","r+");
if(myfile != NULL)
{
//fscanf(myfile,"%s",line[1]);
printf("Number of Corral: %s",line[1]);
printf("Size of Corral: %s",line[2]);
}
else
printf("File didnt open");
fclose(myfile);
break;
Can someone show me how to read from the file line by line please. It write the information to the file but i did some research but i keep failing. I try the fscanf and the gets but to no success.