Code being tried below:
#include <stdio.h>
#include <conio.h>
#include <ctype.h>
int main(void)
{
char ch;
do{
ch=getch();
cprintf("%c", toupper(ch));
} while(ch !='q');
return 0;
}
error below:
C:\Users\Towsif\Desktop\C\sd\main.c||In function 'main':| C:\Users\Towsif\Desktop\C\sd\main.c|11|warning: implicit declaration of function 'cprintf' [-Wimplicit-function-declaration]| obj\Debug\main.o||In function
main':| C:\Users\Towsif\Desktop\C\sd\main.c|11|undefined reference tocprintf'| ||=== Build finished: 1 errors, 1 warnings (0 minutes, 0 seconds) ===|
<conio.h> header file is not available in GCC(MinGW/Cygwin) compiler.
The error is not informative and is misleading.Try without using that header file...
EDIT :-
You can't use getch() and cprintf()!
So, instead of them you try getchar() and printf(). Also, there is no need to change the compiler as GCC is considered the best compiler for C language. Actually, you should either skim that portion of book which requires these <conio.h> header files OR alternately just install another C-compiler alongside GCC. Don't remove GCC! Please use GCC only...
Try this code :-
do{
ch=getchar(); // changed getch() to getchar();
printf("%c", toupper(ch)); //changed cprintf() to printf();
}
while(ch !='q');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With