-
scanf() <-> esc key
Hi all!
I'm using the function scanf but I looking for another function can get user string from the console becuse:
1- I'd like a function that when the user type ESC key it stop asking for some string input
2- I'd like a non-multile type.
for ex: "type the path where the file is located"
> [here goes the scanf() but it will take lots of '\n' on console if the user type enter key without at least a char input]
Thanks for any suggestion!
-
-
If its not in the FAQ, you can search the board for what you're looking for.....you will things like this.
gg
-
i tried the faq but i found nothing.
I tried this:
Code:
cc = getche();
while (cc != 13 || cc != 27)
{
...
cc = getche();
}
but don't worked
-
cool.
Code:
char path[100]
int a;
cc=getche();
while (cc != 13 && cc != 27)
{
cc=getche();
path[a++]=cc;
}
in the line path[a++]=cc; may have a better way to do that, isn't it?
strcat would be fine but should be CHARcat :)
-
Dont forget to initialze 'a' in your example.