I have some warnings when trying to compile a C program:
13:20: warning: excess elements in array initializer [enabled by default] 13:20: warning: (near initialization for 'litera') [enabled by default] 22:18: warning: excess elements in array initializer [enabled by default] 22:18: warning: (near initialization for 'liczba') [enabled by default] 43:1: warning: format '%s' expects argument of type 'char *', but argument 2 has type 'int' [-Wformat] 45:2: warning: format '%s' expects argument of type 'char *', but argument 2 has type 'int' [-Wformat] 55:2: warning: format '%s' expects argument of type 'char *', but argument 2 has type 'int' [-Wformat]
A source:
char litera[63] = {'E', 'G', 'H', 'F', 'E', 'G', 'H', 'F', 'D', 'B', 'A', 'C', 'D', 'B', 'A', 'C', 'B', 'A', 'C', 'D', 'C', 'A', 'B', 'D', 'F', 'H', 'G', 'E', 'F', 'H', 'G', 'E', 'C', 'D', 'B', 'A', 'B', 'A', 'C', 'D', 'F', 'E', 'G', 'H', 'G', 'H', 'F', 'G', 'H', 'F', 'E', 'F', 'H', 'G', 'E', 'C', /*line13:*/ 'A', 'B', 'D', 'C', 'A', 'B', 'D', 'E'}; int liczba[63] ={'8', '7', '5', '6', '4', '3', '1', '2', '1', '2', '4', '3', '5', '6', '8', '7', '5', '7', '8', '6', '4', '3', '1', '2', '1', '2', '4', '3', '5', '6', '8', '7', '6', '8', '7', '5', '3', '1', '2', '4', '3', '1', '2', '4', '6', '8', '7', '5', '7', '8', '6', '4', '3', '1', '2', '1', /*line22*/ '2', '4', '3', '5', '6', '8', '7', '5'}; int i=0, x=0, n; char a; int b=0; printf("Podaj literę z pola startowego skoczka(duże litery)\n"); scanf("%s", &a); printf("Podaj liczbę z pola startowego skoczka \n"); scanf("%d", &b); if (b<=0 || b>8){ printf("Zła pozycja skoczka\n"); return 0; } while (litera[i] != a || liczba[i] != b){ ++i; } n=i; /*line43*/ printf("Trasa skoczka od punktu %s %d to:\n", a, b); while (i<=64){ /*line45*/ printf("%s%d ", litera[i], liczba[i]); ++i; ++x; x=x%8; if(x==0) printf("/n"); } i=0; while (i<n){ /*line55*/ printf("%s%d ", litera[i], liczba[i]); ++i; ++x; x=x%8; if(x==0) printf("/n"); }
also i have "core dumped" after scanf("%d", &b); but int b=0; no problem ...