MCQs
A compiler may leave holes in structures by padding the first char in the structure with another
byte just to ensures that the integer that follows is stored at an location. Also, there might be
2extra bytes after the integer to ensure that the long integer is stored at an address, which is
multiple of 4. Such alignment is done by machines to improve the efficiency of accessing values.
A structure pointing to itself is called self-referential structures.
No answer description available for this question.
No answer description available for this question.
No answer description available for this question.
No answer description available for this question.
No answer description available for this question.
No answer description available for this question.
You can write a function of your own to map an enumeration constant to a string.
Will the following code work?
#include<stdio.h>
#include<malloc.h>
struct emp
{
int len;
char name[1];
};
int main()
{
char newname[] = "Rahul";
struct emp *p = (struct emp *) malloc(sizeof(struct emp) -1 +
strlen(newname)+1);
p->len = strlen(newname);
strcpy(p -> name, newname);
printf("%d %s\n", p->len, p->name);
return 0;
}
The program allocates space for the structure with the size adjusted so that the
name field can hold the requested name.