What is difference between multi character constant and string literals?

1 answer

Answer

1282884

2026-09-06 10:30

+ Follow

In C, you can assign integers multiple characters such that they fit in their size. For e.g.:

int - 4 bytes

char - 1 byte

So an assignment like this is valid:

int a = 'ABCD';

The first byte in a will be assigned the value of 'A', the second - 'B' and so on.

A string literal is a character array constant. It is enclosed in double quotes and assignment can only be made to a char pointer. There is no limit on the size of the literal and it is terminated with a null character. e.g.:

char str[] = "This is a trial";

ReportLike(0ShareFavorite

Copyright © 2026 eLLeNow.com All Rights Reserved.