answersLogoWhite

0


Best Answer

It doesn't.

Try this

#include <stdio.h>

#include <wchar.h>

int main (void) {

printf ("sizeof (char)=%d, sizeof (wchar_t)=%d\n",

(int)sizeof (char), (int)sizeof (wchar_t));

return 0;

}

User Avatar

Wiki User

14y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Why does a character constant require two bytes of memory space in c?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

What is data file?

it may require a large amount of data to be read,processed and also served for latter use.such memory is store ion the auxiliary memory device in form of data file.the data file is collection of bytes.


What function allocate n bytes in heap memory?

malloc


How many bytes does date DD-MM-YYYY datatype occupy in java?

A java.util.Date object will take about 32 bytes in memory.


Are pointers integers?

A pointer holds a memory address, from 0 to the upper limit of your memory (in 32 bit addressing this is up to 2^32, 64 bit is up to 2^64 bytes). So in math terms, a pointer could be considered a non-negative integer. However this is not the same as the integer type used in C and other languages, which refers to how the data at that memory address (the raw bits) is interpreted by the system. So the expression "int *x;" declares a pointer to an integer, but x is a memory address, not a literal C-style integer. The value pointed to by x, however, will be interpreted as a literal C-style integer. It may be easier to see using a pointer to a char: char character = 'C'; char *pointerToCharacter = character; In this case, character is a standard char variable, and pointerToCharacter is a pointer (which is a memory address) that points to the location in memory of a character.


What is difference between multi character constant and string literals?

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";