• 0

C - Escape Sequence


Question

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

  • 0

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

  • 0

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

  • 0

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

  • 0

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

  • 0

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

  • 0

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

  • 0

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

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.