Curioustab
Aptitude
General Knowledge
Verbal Reasoning
Computer Science
Interview
Take Free Test
Aptitude
General Knowledge
Verbal Reasoning
Computer Science
Interview
Take Free Test
Structures, Unions, Enums Questions
In standard C, is there a built-in, portable way to print the symbolic names of enum constants at runtime, or must we create our own mapping?
Accessing union members in C: Do we always need the address-of (&) operator, or do we use the member access operator (.) to read/write fields?
Union layout in C: Must all members of a union have the same size, or can members differ in size with the union sized to fit the largest?
Storage class defaults in C: If you declare a structure variable inside a block without an explicit storage-class specifier, what is its default storage duration?
C typedef with struct tag reuse: Will the following declaration compile and work as intended, creating both a struct tag and a typedef of the same name? typedef struct s { int a; float b; } s;
Flexible storage for names: Will the following C code allocate enough space for a variable-length name and print it correctly? #include
#include
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 ", p->len, p->name); return 0; }
In C programming, can we create a union whose members are pointers (for example, to allow the same storage to hold either an int* or a char*)? Choose the most accurate statement.
1
2
3