Array of Structures

This is a discussion on Array of Structures within the C Programming forums, part of the General Programming Boards category; Ok, my question is how do you search for something inside an array of structures? Here's my problem: struct Customer ...

  1. #1
    Registered User
    Join Date
    Feb 2002
    Posts
    10

    Thumbs down Array of Structures

    Ok, my question is how do you search for something inside an array of structures? Here's my problem:

    struct Customer
    {
    int Cid;
    char Cname;
    int Tele;
    int NumMovies;
    int New;
    int Old;
    {;

    struct Customer Customer[MAX];

    Ok, now there's my structure and my array. Now, if I wanted to search for Cid (ID number), how do you I go about doing that? I'm really clueless on it and the majority of my functions are asking for me to do this search.

  2. #2
    Just one more wrong move. -KEN-'s Avatar
    Join Date
    Aug 2001
    Posts
    3,230
    first off, fix this:

    struct Customer
    {
    int Cid;
    char Cname;
    int Tele;
    int NumMovies;
    int New;
    int Old;
    {;

    to this:

    struct CUSTOMER
    {
    int Cid;
    char Cname;
    int Tele;
    int NumMovies;
    int New;
    int Old;
    };

    and this:

    struct Customer Customer[MAX];

    to this:
    struct CUSTOMER Customer[MAX];

    Ok, so now that we're set with that:

    Code:
    for(int x=0; x<MAX; x++)
         if(Customer[x].Cid == SomeCID)
         {
                DoSomething();
                DoSomethingElse();
         }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Structures, passing array of structures to function
    By saahmed in forum C Programming
    Replies: 10
    Last Post: 04-06-2006, 12:06 AM
  2. filling an array of structures?
    By voodoo3182 in forum C Programming
    Replies: 9
    Last Post: 08-06-2005, 06:29 PM
  3. Array of Structures: Sorting
    By Drainy in forum C Programming
    Replies: 3
    Last Post: 04-13-2005, 10:55 AM
  4. Filling an Array of Structures
    By Zildjian in forum C Programming
    Replies: 5
    Last Post: 11-12-2003, 05:54 PM
  5. Need serious help on array of structures
    By cwd in forum C Programming
    Replies: 2
    Last Post: 11-11-2001, 03:39 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21