Structure array problem

This is a discussion on Structure array problem within the C++ Programming forums, part of the General Programming Boards category; I made my own structure called person it consists of Code: struct person { char personName[30]; int amLevel; int noonLevel; ...

  1. #1
    Registered User Birdhaus's Avatar
    Join Date
    Nov 2005
    Posts
    11

    Question Structure array problem

    I made my own structure called person it consists of
    Code:
    struct person
    {
    
    	char personName[30];
    	
    	int amLevel;
    	
    	int noonLevel;
    	
    	int pmLevel;
    
    };
    Now I made an array of this structure called
    person patient[25]
    This I know limits the number of names I can put into the array to 25, but one name has everything that is in the structure. So when I call the program that has this structure and there is enough data to fill out 15 structures how can I only print out certain names with that name's info? or if there are many occurances of one name? Any help is appreciated. Thanks

    So what I'm basically doing is this:
    Code:
    c:\>program  //This calls all the info and displays
    
    c:\>programJohn_Doe  //This calls all occurances of that name 
    
    c:\>programJohn_Doeam   //This calls all John Does and the am level
    Last edited by Birdhaus; 11-21-2005 at 08:28 PM.

  2. #2
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,074
    Well, you'd want to use spaces between those arguments, but if you know how to do this:

    http://www.cprogramming.com/tutorial/lesson14.html

    Then it's simple. Fill in your array, then have a loop that checks argv[1] against the values in patient[25].personName[x]. If it finds a match it outputs it. Also if argc > 2, then it can check the next argument against the appropriate variable, etc.
    Sent from my iPadŽ

  3. #3
    Registered User Birdhaus's Avatar
    Join Date
    Nov 2005
    Posts
    11

    Smile

    Now that helped a lot. Didn't think to use the argc and argv except in my switch statement. Appreciate the help. Thanks a lot.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 07-11-2008, 07:39 AM
  2. 2D array becoming "deallocaded"
    By Aaron M in forum C Programming
    Replies: 2
    Last Post: 09-23-2006, 07:53 AM
  3. Multidimensional Array in a Structure
    By Night_Blade in forum C Programming
    Replies: 3
    Last Post: 04-04-2005, 08:14 PM
  4. Replies: 6
    Last Post: 10-21-2003, 09:57 PM
  5. problem: reading user input into an array
    By alpha561 in forum C Programming
    Replies: 13
    Last Post: 05-24-2002, 07:23 PM

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