My first question is, how do I print out long strings with spaces from a text file? I tried printing it out the normal way but only the first word gets printed out. My professor required us to print out bible passages from a text file.
For my second question, I have this code:
fp=fopen("Score.txt", "r");
for(i=0;i<30;i++){
fscanf(fp,"%s\n%s\n\n",scorename[i],scorescore[i]);
printf("%s\n%s\n\n",scorename[i],scorescore[i]);
}
It's supposed to print out the scores stored in Score.txt. But say, I have only one score recorded. It prints out 29 junk data for the rest. I'm planning on replacing 30 with n so that it will print only the correct number of scores. But my problem is, how can I keep track of the number of scores inside the text file? I need to retain this even when restarting the program.


Sign In
Create Account

Back to top









