a všetko čo bolo v súbore vymaže. Už som prehľadal všetko možné ale na nič podobné som nenatrafil. Ďakujem za odpoveď
Kód: Vybrať všetko
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#define MAX 5
int main()
{
while(1) {
int vc[MAX], loto[MAX];
char banka[8];
int i, j, k = 0, n, c, a;
FILE *fw, *fr;
srand(time(0));
if (fw = fopen("loteria.txt", "w") == NULL) {
printf("Subor sa nepodarilo otvorit\n");
return 1;
}
if (fr = fopen("loteria.txt", "r") == NULL) {
printf("Subor sa nepodarilo otvorit\n");
return 1;
}
fgets(banka, 7, fr);
printf("%s", banka);
printf("Aku sumu chces stavit?\n");
scanf("%d", &n);
printf("Zadaj 5 cisel od 1 do 9: ");
for( i = 0; i < 5; i++)
scanf("%d", &vc[i]);
printf("Vyherne cisla su: ");
for( i = 0; i < 5; i++)
{
loto[i] = rand()%8 + 1;
printf("%d\n", loto[i]);
}
for( i = 0; i < 5; i++)
if( loto[i] == vc[i]) {
k += 1;
}
printf("%d\n", k);
system("pause");
}
return 0;
}