The opening and closing seems to be working, but could someone guide or give me a suggestions as to how to store which lines have been used? Perhaps if I stored the indexes?
The opening and closing seems to be working, but could someone guide or give me a suggestions as to how to store which lines have been used? Perhaps if I stored the indexes?
Or is there anyway I can just use a flag to tell if the line has been used or not?
I don't really want to use a 2d array because I have been so often criticized for trying to use them before.
I currently have this for getting the line number. What could I add to it to prevent the same one from being used again
Code:while(fgets(temp,100,phraseFile)!=0){ ++count; } fclose(phraseFile); fopen("clues.txt", "r"); line= rand()%count; while(line--){ fgets(temp, 100, phraseFile); /*gets line and stores in temp*/ }
seems to be ok except
fopen("clues.txt", "r"); - you need to store the return value again
bytheway - if line == 0 you will be left with the last read line in the buffer...
All problems in computer science can be solved by another level of indirection,
except for the problem of too many layers of indirection.
– David J. Wheeler
Would the line ==0 work though if my program is in a loop to be performed three times though? It seems like there could be a change that the first and third rounds of the program could use the same word...