This is my code
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void CharacterScan(int*);
int main(void){
int* iPtr;
CharacterScan(&iPtr);
}
void CharacterScan(int* iPtr){
char ch;
int asciiValue;
do{
printf("Enter any character: \n");
ch = _getch();
asciiValue=(int)ch;
iPtr = (int*)asciiValue;
printf("ASCII value of character %c is: %d\n",ch,iPtr);
}while(ch != 27);
return ;
}
As I said, it runs fine in the IDE I am using, but it doesn't run in a Linux environment. I get the following errors:
testchar.c: In function ‘main’:
testchar.c:19:5: warning: passing argument 1 of ‘CharacterScan’ from incompatible pointer type [enabled by default]
CharacterScan(&iPtr);
^
testchar.c:15:6: note: expected ‘int *’ but argument is of type ‘int **’
void CharacterScan(int*);
^
testchar.c: In function ‘CharacterScan’:
testchar.c:30:16: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
iPtr = (int*)asciiValue;
^
/tmp/cceTSMdl.o: In function `CharacterScan':
testchar.c:(.text+0x32): undefined reference to `_getch'
collect2: error: ld returned 1 exit status
I have never encountered this problem before. Does anyone know what could be the problem?