Answer the question
In order to leave comments, you need to log in
`
Why 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
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question