1,259 views
2 2 votes
case : 'AB'

is it valid to write multiple characters in single quotes?

And if valid does ASCII value of a& b gets added and stored as integral constant?

Thanks

1 Answer

1 1 vote

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, 

therefore they got the size of int 

       
103 102 101 100

 

let 'AB' ==> if you are using little endien ===> char c = 'AB' mapped to 'B' ( due to character hold only one Byte Memory )

'\0' '\0' 'A' 'B'
103 102 101 100

 

 

if you are using big endien ===> char c = 'AB' mapped to '\0' ( due to character hold only one Byte Memory )

'\0' '\0' 'A' 'B'
100 101 102 103

 

• edited by
Position:
Show:

Related questions

7 7 votes
2 2 answers
438
438 views
Cutoff_Breaker asked Jul 10
438 views
What is the output given exp = 4?switch (exp){ default: printf("default\n"); case 5: printf("5\n"); case 3: printf("3\n"); case 2: ...
9 9 votes
3 3 answers
348
348 views
GO Classes asked Jun 5
348 views
What is the output of the following code?#include <stdio.h int main() { int x = 3, y = 1; switch (x - 1) { case 1: y = y + 2; case 2: y = y * 3; case 3: y = y - 1; break;...
10 10 votes
1 1 answer
308
308 views
GO Classes asked Jun 3
308 views
What is the output of the following code?#include <stdio.h int main() { int x = 2, y = 0; switch (x) { case 1: y = y + 1; case 2: y = y + 2; case 3: y = y + 3; break; def...