|
Beginners code
Description
This example shows the usage of a basic structure ,
in this example we will store info about a website
Code
#include <stdio.h>
/*our structure*/
struct website{
char url[60];
char description[60];
int rating;
};
int main()
{
/*site is a variable of the structure website*/
struct website site;
/*get the url*/
printf("Enter the url of the website,\n");
gets(site.url);
/*get the description*/
printf("Now enter the description of the website.\n");
gets(site.description);
/*get the rating*/
printf("Now enter the rating out of 10.\n");
scanf("%d",&site.rating);
/*display the entered info*/
printf("%s\n",site.url);
printf("%s\n",site.description );
printf("Is rated at %d out of 10\n",site.rating );
return 0;
}
Information
tested using Visual C++ 6
Download
structure1.txt
|