int i ='abcd';

S

spibou

shaanxxx said:
int i ='abcd';
how exactly it works?

I'm not sure what you're asking but if you want
to know what the meaning of 'abcd' is then it is
implementation defined because it contains more
than 1 characters. So you need to check the
documentation for your C compiler and the answer
might be different for other compilers.

Spiros Bousbouras
 
C

Cong Wang

shaanxxx said:
int i ='abcd';
how exactly it works?

Njoy,
Shaan.

See the following:

ANSI C99 6.4.4.4 Character constants:
An integer character constant has type int. The value of an integer
character constant
containing a single character that maps to a single-byte execution
character is the
numerical value of the representation of the mapped character
interpreted as an integer.
The value of an integer character constant containing more than one
character (e.g.,
'ab'), or containing a character or escape sequence that does not map
to a single-byte
execution character, is implementation-deï¬ned. If an integer
character constant contains
a single character or escape sequence, its value is the one that
results when an object with type char whose value is that of the single
character or escape sequence is converted to type int.

;-p
 
S

shaanxxx

Cong said:
See the following:

ANSI C99 6.4.4.4 Character constants:
An integer character constant has type int. The value of an integer
character constant
containing a single character that maps to a single-byte execution
character is the
numerical value of the representation of the mapped character
interpreted as an integer.
The value of an integer character constant containing more than one
character (e.g.,
'ab'), or containing a character or escape sequence that does not map
to a single-byte
execution character, is implementation-deï¬ned. If an integer
character constant contains
a single character or escape sequence, its value is the one that
results when an object with type char whose value is that of the single
character or escape sequence is converted to type int.

;-p
thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top