Note that there are some explanatory texts on larger screens.

plurals
  1. POC writing in files problems with repeatable choice
    primarykey
    data
    text
    <p>Ok, thats half of my code, but i have problem and i cant fix it. For example i need to pick choice 2 it is adding something to file, i enter[ name, surname, date, gender ] press enter and program shows like menu again(2.Add to file) but this time automatically picks 2 choice and i need to write data another time and it happens all the time when picking choice 2. Please help me find solution of this problem. </p> <pre><code>#include &lt;stdio.h&gt; #include &lt;string.h&gt; #include &lt;conio.h&gt; #include &lt;windows.h&gt; #define N 15 struct date { int da_year; int da_month; int da_day; }; struct studenti { int Nr; char name[25]; char surname[25]; struct date dzd; char dzimums; }students[N] ; int main() { sakums: // FILE *fails_st; char line[100]; char *ptk; char * end; int i;int sorted; int g=0,ch,count=0; int n; int choice; FILE *fails_st = fopen("studenti.txt", "r+"); /* errors ja neizdodas atveert failu */ if (fails_st == NULL) { printf("Error opening file!\n"); exit(1); } printf("\n2.Add to file"); scanf("%d",&amp;choice); if(choice==2){ /* write in file */ for (n=0; n&lt;1; n++) { printf("%d. Ievadiet: vards, uzvards, datums, dzimums &gt;", n+1); scanf("%s",&amp;students[n].name); scanf("%s",&amp;students[n].surname); scanf("%d.%d.%d", &amp;students[n].dzd.da_day, &amp;students[n].dzd.da_month, &amp;students[n].dzd.da_year); scanf("%c",&amp;students[n].dzimums); } fseek(fails_st, 0, SEEK_END); for (i=0; i&lt;n; i++) fprintf(fails_st, " %d. %s %s %d.%d.%d %c\n", N+1, students[i].name, students[i].surname, students[i].dzd.da_day, students[i].dzd.da_month, students[i].dzd.da_year, students[i].dzimums); fclose(fails_st); goto sakums; } getche(); return 0; } </code></pre>
    singulars
    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.
 

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