Curioustab
Aptitude
General Knowledge
Verbal Reasoning
Computer Science
Interview
Aptitude
General Knowledge
Verbal Reasoning
Computer Science
Interview
Structures, Unions, Enums Questions
Is there easy way to print enumeration values symbolically?
The elements of union are always accessed using & operator
Is it necessary that the size of all elements in a union should be same?
By default structure variable will be of auto storage class
Will the following declaration work? typedef struct s { int a; float b; }s;
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; }
A pointer union CANNOT be created
1
2
3