-->

struct initialization

in turboc++
------------------------------------------------------------------------------
//struct initialization
#include <stdio.h>
#include<string.h>
struct onl
{
    int a;
    float b;
    char name[30];
}var;
int main()
{
     var.a=98;
     var.b=5.4;
    strcpy(var.name,"raman");
    printf("a=%d\n",var.a);
     printf("b=%f\n",var.b);
     printf("name=%s",var.name);
    return 0;
}
/*note:
We donot need to use strcpy()if we use initialization
in same line as the var is.
same we can apply in union as well.
*/

No comments:

Post a Comment