587 views
2 votes
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 votes
1 votes

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

Related questions

1 votes
1 votes
2 answers
2
Hira Thakur asked Sep 14, 2018
1,483 views
int main() { int a =50; switch(a) { default: a=45; case 49: a++; case 50: a ; case 51: a =a+1; } printf("%d",a); }my doubt is the default case is not executed here why??,...
5 votes
5 votes
1 answer
3
Tuhin Dutta asked Nov 14, 2017
1,453 views
#include <stdio.h>int main(){ int check = 20; const int arr[] = {10, 20, 30}; switch (check) { case arr[0]: printf("Tuhin "); case arr : printf...
1 votes
1 votes
1 answer
4