UltraMAX Posted July 27, 2004 Share Posted July 27, 2004 Hi, can someone help me please ?!!!! I want to make a Escape Sequence in C but i don't know how, here it is my point: I'm filling something, for example, the first name, surname, age, etc of someone, but in the middle i want to abort, so when i press the ESC key it will return to the main menu, for example. I hope you understand my point of view and sorry for my bad english. Thanks UltraMAX Link to comment Share on other sites More sharing options...
0 John Veteran Posted July 27, 2004 Veteran Share Posted July 27, 2004 You can #define something, but I don't think you can make your own escape sequence :huh: Maybe I'm wrong, that would be cool :D Link to comment Share on other sites More sharing options...
0 Mengcct Posted July 27, 2004 Share Posted July 27, 2004 the problems is how to read the "esc" key as soon as we enter it ... may be "C" scanf function can't do that... Link to comment Share on other sites More sharing options...
0 UltraMAX Posted July 27, 2004 Author Share Posted July 27, 2004 Thanks you both guys for helping me... but ... which is the ESC code in ASCII ... for example : scanf("%c", &ch); if (ch == ' (esc key code) ') then break, exit or return .... do you guys know the code? Link to comment Share on other sites More sharing options...
0 HeartsOfWar Posted July 27, 2004 Share Posted July 27, 2004 Yes, as you have ealready pointed out, just check the ascii code for the escape key The escape should be 27 - I'm not positive, I don't have an ASCII table at the moment... Link to comment Share on other sites More sharing options...
0 Mengcct Posted July 27, 2004 Share Posted July 27, 2004 i dont know but i know that how to check scanf("%d",&key); printf("%d",key); and if you want to check the ASCII code of a operator I suggest you define it is as a int or may be treat it as 'esc'(uncertain) because it have try 'enter' as enter key before while i wirte the loop condition Link to comment Share on other sites More sharing options...
0 Michael Posted July 27, 2004 Share Posted July 27, 2004 Escape is 27: http://www.asciitable.com/ Link to comment Share on other sites More sharing options...
0 UltraMAX Posted July 27, 2004 Author Share Posted July 27, 2004 Once again, THANK YOU ALL GUYS for helping me!!!!!!!! :D Now i can do a Escape Sequence like a do! i use: ch = getch(); if (ch == '\033') return; Thanks a lot. UltraMAX Link to comment Share on other sites More sharing options...
0 Mengcct Posted July 27, 2004 Share Posted July 27, 2004 getchar :( ... ok...i go to face wall.......T_T Link to comment Share on other sites More sharing options...
0 UltraMAX Posted July 27, 2004 Author Share Posted July 27, 2004 Mengcct ... i'm learning C language, but ... what's wrong with my code, it works fine ... i mean, for what i really wanna do ... it won't work :wacko: but anyway .... thank you very much for trying to help me. i'll try something else, in the project that i'm working i'm using arrays (like char name[50] and structures, so i thing it is a little difficult to do what i want! :( Thanks UltraMAX Link to comment Share on other sites More sharing options...
0 UltraMAX Posted July 29, 2004 Author Share Posted July 29, 2004 Please, can someone help me, i try but .. i can't do that ... i'm using a structure like this one: typedef struct { int ano, mes, dia; } DATA; typedef struct { int numero; char banco[20], titular[50], ordem[50], emissao[31]; float quantia; DATA data; } CHEQUE; and i want do this: when i'm filling the fields and in the middle i want to cancel, for example i press the ESC key and i goto the main menu, how can i do that, in the filling the fileds function i'm using a code like this for retrieve what we wrote: gets(chequex.titular)); gets(chequex.ordem)); gets(chequex.emissao)); scanf("%f", &chequex.quantia); scanf("%d %d %d", &chequex.data.ano, it is possible to do what i want? Forgive me for my bad english, i hope you understand what i wrote! :rolleyes: UltraMAX Link to comment Share on other sites More sharing options...
Question
UltraMAX
Hi, can someone help me please ?!!!!
I want to make a Escape Sequence in C but i don't know how, here it is my point:
I'm filling something, for example, the first name, surname, age, etc of someone, but
in the middle i want to abort, so when i press the ESC key it will return to the main menu, for example.
I hope you understand my point of view and sorry for my bad english.
Thanks
UltraMAX
Link to comment
Share on other sites
10 answers to this question
Recommended Posts