Simple Struct Example
2002-02-23 16:21:58
Category: c:structures
Description: Basic example of using a data structure to store variables.
Author: mind
Viewed: 11368
Rating: (74 votes)


/* struct example by mind@metalshell.com
 *
 * This is a simple example on structures, I based this on website hits.
 *
 * 02/19/2002
 *
 * http://www.metalshell.com
 *
 */
 
#include <stdio.h>
 
struct hits
{
        int totalHits;
        int dailyHits;
} nullhosting, metalshell;
 
int main()
{
        nullhosting.totalHits = 1000;
        nullhosting.dailyHits = 10;
 
        metalshell.totalHits = 3000;
        metalshell.dailyHits = 100;
 
        /* print metalshell's hits */
        printf("Metalshell.com's Stats:\n");
        printf("Total hits: %i Daily hits: %i\n\n", metalshell.totalHits, metalshell.dailyHits);
 
        /* print nullhosting's hits */
        printf("Nullhosting.com's Stats:\n");
        printf("Total hits: %i Daily Hits: %i\n", nullhosting.totalHits, nullhosting.dailyHits);
 
        return 0;
}