Note that there are some explanatory texts on larger screens.

plurals
  1. POSame name input/output issue
    primarykey
    data
    text
    <p>Okay guys, I'm having one more issue with my program. I'm running into an issue with using the same filename (KnightsBall."extension"). I don't know if it's something locally, or an issue I'll have when I move the code over. So can anyone help me with what thing I'm overlooking? The output and input have to both go to the same filename.(in) or (out) so no ways around. If I change the output file to <code>knights.out</code> it works. Any ideas? Relevant segments of code:</p> <pre><code>FILE *fr; FILE *fo; typedef struct KnightsBallLottoPlayer { char firstName[20]; char lastName[20]; int numbers[6]; } KBLottoPlayer; int main() { KBLottoPlayer *temp; int numPlays=0; //What file to read from fr = fopen("KnightsBall.in", "r"); //What file to read to fo = fopen("KnightsBall.out", "w"); </code></pre> <p>and the part where the output is accessed:</p> <pre><code>if(match==3) fprintf(fo,"%s %s matched %d numbers and won $10.\n", temp[r].firstName, temp[r].lastName, match); if(match==4) fprintf(fo,"%s %s matched %d numbers and won $100.\n", temp[r].firstName, temp[r].lastName, match); if(match==5) fprintf(fo,"%s %s matched %d numbers and won $10000.\n", temp[r].firstName, temp[r].lastName, match); if(match==6) fprintf(fo,"%s %s matched %d numbers and won $1000000.\n", temp[r].firstName, temp[r].lastName, match); </code></pre> <p>Also on a completely unrelated side note, does anyone know how to close the command prompt after I scan in the values I need from the user? All help is much appreciated.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload