using codeblocks
----------------------------------------------------------------------------------------
//understanding typedef with struct
#include <stdio.h>
typedef struct // typedef for struct to assign its property to access
{
char name[40]; //members
char add[40];
int roll;
}access; // it is being tag (struct). It has got all property of struct
access first; //variable of tag access. we can also put inside main function.
int main()
{
printf("enter name\n");
gets(first.name); //gets input
printf("enter add\n");
gets(first.add);
printf("enter roll\n");
scanf("%d",&first.roll);
printf("name=%s , address=%s and roll=%d\n",first.name,first.add,first.roll);//displays output.
return 0;
}
----------------------------------------------------------------------------------------
//understanding typedef with struct
#include <stdio.h>
typedef struct // typedef for struct to assign its property to access
{
char name[40]; //members
char add[40];
int roll;
}access; // it is being tag (struct). It has got all property of struct
access first; //variable of tag access. we can also put inside main function.
int main()
{
printf("enter name\n");
gets(first.name); //gets input
printf("enter add\n");
gets(first.add);
printf("enter roll\n");
scanf("%d",&first.roll);
printf("name=%s , address=%s and roll=%d\n",first.name,first.add,first.roll);//displays output.
return 0;
}
-------------------------------------------------------------------------------------
Or
--------------------------------------------------------------------------------
//understanding typedef with struct
#include <stdio.h>
typedef struct tag // typedef for struct to assign its property to access via 'tag'
{
char name[40]; //members
char add[40];
int roll;
}access; // it is being tag (struct). It has got all property of struct
access first; //variable of tag access. we can also put inside main function.
int main()
{
printf("enter name\n");
gets(first.name); //gets input
printf("enter add\n");
gets(first.add);
printf("enter roll\n");
scanf("%d",&first.roll);
printf("name=%s , address=%s and roll=%d\n",first.name,first.add,first.roll);//displays output.
return 0;
}
//note: putting a tag doesnot make any different. We have to use same method as given in above //example.
//Mostly, the tag is unimportant.
---------------------------------------------------------------------------------------------------
using turboC++
-------------------------------------------------------------------------
#include <stdio.h>
typedef struct tag // typedef for struct to assign its property to access via 'tag'
{
char name[40]; //members
char add[40];
int roll;
}access; // it is being tag (struct). It has got all property of struct
access first; //variable of tag access. we can also put inside main function.
int main()
{
printf("enter name\n");
gets(first.name); //gets input
printf("enter add\n");
gets(first.add);
printf("enter roll\n");
scanf("%d",&first.roll);
printf("name=%s , address=%s and roll=%d\n",first.name,first.add,first.roll);//displays output.
return 0;
}
//note: putting a tag doesnot make any different. We have to use same method as given in above //example.
//Mostly, the tag is unimportant.
---------------------------------------------------------------------------------------------------
using turboC++
-------------------------------------------------------------------------
//understanding typedef with struct
#include <stdio.h>
#include<conio.h>
typedef struct // typedef for struct to assign its property to access
{
char name[40]; //members
char add[40];
int roll;
}access; // it is being tag (struct). It has got all property of struct
access first; //variable of tag access. we can also put inside main function.
int main()
{
printf("enter name\n");
gets(first.name); //gets input
printf("enter add\n");
gets(first.add);
printf("enter roll\n");
scanf("%d",&first.roll);
printf("name=%s , address=%s and roll=%d\n",first.name,first.add,first.roll);//displays output.
getch();
return 0;
}
#include <stdio.h>
#include<conio.h>
typedef struct // typedef for struct to assign its property to access
{
char name[40]; //members
char add[40];
int roll;
}access; // it is being tag (struct). It has got all property of struct
access first; //variable of tag access. we can also put inside main function.
int main()
{
printf("enter name\n");
gets(first.name); //gets input
printf("enter add\n");
gets(first.add);
printf("enter roll\n");
scanf("%d",&first.roll);
printf("name=%s , address=%s and roll=%d\n",first.name,first.add,first.roll);//displays output.
getch();
return 0;
}
No comments:
Post a Comment