I'm trying to use the function "getche()", which is a non-standard instruction to retrieve an entry from the keyboard with a display, but Xcode dosen't take it.
It shows:
Does somebody knows how to use that function or knows an alternative function?
basically, my program asks a sentence then counts which letters are used and how many times.
It shows:
Code:
[FONT="Courier New"][I][I]Undefined symbols for architecture x86_64:
"_getche", referenced from:
_main in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
[/I][/I][/FONT]
Does somebody knows how to use that function or knows an alternative function?
basically, my program asks a sentence then counts which letters are used and how many times.
Code:
[FONT="Courier New"]#include <stdio.h>
#include <ctype.h>
int main(void)
{
int ltrs[27] = {0}, i;
char key;
int getche(void);
printf("Enter a sentence.\n");
do
{
key = getche();
toupper(key);
if(key >= 'A' && key <= 'Z')
{
ltrs[key - 'A']++;
}
}
while (key != '.' && key != '!' && key != '?');
for (i = 0 ; i < 27 ; i++)
{
if (ltrs[i] > 0)
{
printf("\nthe lettrer %c = %d",i+'A',ltrs[i]);
}
}
return 0;
}[/FONT]
Last edited by a moderator: