Main Menu

HOME

.Net
ASP
Assembly
C
C++
Delphi
HTML
Java
JavaScript
MySQL
PC interface
Powershell
Perl
PHP
VBScript
Visual Basic
XML

Make money selling software. Check this out here

Hosted clickbank mall. Check this out here


Sedo - Buy and Sell Domain Names and Websites project info: programmershelp.co.uk Statistics for project programmershelp.co.uk etracker® web controlling instead of log file analysis

   Misc

   Amazon

   Links

    


Array of structures
 

 

 

Description

This shows how to use an array of structures

Code


#include <stdio.h>

/*the maximum amount of entries*/
#define MAXSITES 4


/*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[MAXSITES];
int count = 0;
int index;
/*get the url*/
printf("Enter the url of the website and press enter,\n");
/*get the description*/
while(count < MAXSITES && gets(site[count].url) != NULL && site[count].description != '\0')

{
printf("Now enter the description of the website.\n");
gets(site[count].description);
/*get the rating*/
printf("Now enter the rating out of 10.\n");
scanf("%d",&site[count++].rating);
while(getchar() != '\n')
continue;
if(count < MAXSITES)
printf("Enter the next url.\n");
}
/*display the entered info*/
for(index = 0;index < count ;index++)
{
printf("%s\n",site[index].url);
printf("%s\n",site[index].description );
printf("Is rated at %d out of 10\n",site[index].rating );
}
return 0;
}

Information

tested using Visual C++ 6

 

 

 

Download

structurearray.txt


 




   Sponsors
 

   Software
500 Java Tips E-book
PHP editor
PERL editor
Beginning Java
Beginning Visual Basic
Learn VB.net
Learn VB 6
VB and databases
ASP image library
C++ builder programming
C++ fundamentals

   Source Code
Title bar flash(VB)
connect to internet using DUN(VB)
common dialog to list box(VB)
Display month name(VBScript)
WeekDayName example(VB)
display the IP address using WMI(VB)
hexadecimal to decimal conversion(PHP)
Blinking label(VB)

    




Copyright © 2003 by programmershelp.co.uk