Přidat otázku mezi oblíbenéZasílat nové odpovědi e-mailem C - Porovnanie String & Integer

Tento funguje...

#include <stdio.h>
#include <string.h>

int main()
{  
   int x = 0, i, lineCount = 3, skore=1;
   char line[4], *lineArray[lineCount];
   FILE *file = fopen("file.txt", "r" );
   
     if (file == NULL){
        printf("Cannot open file\n");
        return 1;
    }

rewind(file);

printf("Top skore:\n");
while (fgets(line, sizeof(line), file) != NULL) {
    lineArray[x] = malloc(strlen(line));
    strcpy(lineArray[x], line);
    printf("%d. %s", x+1, lineArray[x]);
    x++;
} 
   printf("\n\n\n");
   system("PAUSE");
   return(0);
}

Reakce na odpověď

1 Zadajte svou přezdívku:
2 Napište svou odpověď:
3 Pokud chcete dostat ban, zadejte libovolný text:

Zpět do poradny