@DVoropaev
Ставлю + к карме на хабре за ответы на вопросы

Почему undefined reference to `getch'?

#include <ctype.h>
#include <stdio.h>

int main(void){
 char ch = getch();
 printf("%c", getch);
 ungetch(ch);
 ch = getch();
 printf("%c", ch);
 return 0;
}


$ gcc ./main.c 
./main.c: In function ‘main’:
./main.c:5:12: warning: implicit declaration of function ‘getch’ [-Wimplicit-function-declaration]
  char ch = getch();
            ^
./main.c:6:9: warning: format ‘%c’ expects argument of type ‘int’, but argument 2 has type ‘int (*)()’ [-Wformat=]
  printf("%c", getch);
         ^
./main.c:7:2: warning: implicit declaration of function ‘ungetch’ [-Wimplicit-function-declaration]
  ungetch(ch);
  ^
/tmp/ccGBsaa1.o: In function `main':
main.c:(.text+0xe): undefined reference to `getch'
main.c:(.text+0x16): undefined reference to `getch'
main.c:(.text+0x35): undefined reference to `ungetch'
main.c:(.text+0x3f): undefined reference to `getch'
collect2: error: ld returned 1 exit status
  • Вопрос задан
  • 885 просмотров
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы
24 апр. 2024, в 16:19
4000 руб./за проект
24 апр. 2024, в 15:34
20000 руб./за проект
24 апр. 2024, в 15:32
130000 руб./за проект