struct node
{
int *a;
char *b;
char array[12];
};
struct node m,*n;
assign the value in *a,*b,char array[12]
Answer Posted / varun
m.a=(int*)malloc(4);
*(m.a)=2;
m.b=(char*)malloc(10);
m.b="hello";
strcpy(m.array,"world");
n=(struct node*)malloc(sizeof(struct node));
n->a=(int*)malloc(4);
*(n->a)=2;
n->b=(char*)malloc(10);
n->b="hello";
strcpy(n->array,"world");
| Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
Explain with the aid of an example why arrays of structures don’t provide an efficient representation when it comes to adding and deleting records internal to the array.
What are the two types of structure?
What is the difference between malloc() and calloc()?
What is the purpose of sprintf() function?
Explain about C function prototype?
How can I write data files which can be read on other machines with different word size, byte order, or floating point formats?
Why c is called top down?
What are the salient features of c languages?
What is page thrashing?
How can I rethow can I return a sequence of random numbers which dont repeat at all?
What is default value of global variable in c?
What are the 5 organizational structures?
I need a sort of an approximate strcmp routine?
What is function prototype in c with example?
How can I check whether a file exists? I want to warn the user if a requested input file is missing.