Re: [Dev-C++] Question about structs...
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Per W. <pw...@ia...> - 2002-10-22 19:16:40
|
Try create a variable:
database employees[100];
instead.
employees[0].age = 22;
...
/Per W
On Tue, 22 Oct 2002, Rob Peacock wrote:
> OK, I'm back for more information. I'm looking at a slightly different way
> of building the database I asked about yesterday.
>
> The examples I have seen for a structure are typically a database. Here's
> the one I have seen posted on several newbie sites:
>
> #include <iostream.h>
>
> struct database
> {
> int id_number;
> int age;
> float salary;
> };
>
> int main()
> {
> database employee;
> employee.age=22;
> employee.id_number=1;
> employee.salary=120000.21;
>
> return 0;
> }
>
> My question is this; this struct as it is written will only hold one
> record, and all of the entries are int's. If I wanted to have multiple
> records using the same struct, can I create a struct array (correct
> terminology?) like this:
>
> struct database[100]
> {
> int id_number;
> char employee_name[25];
> int age;
> float salary;
> };
>
> To populate it, or to access the individual records within the array, I
> would use the standard for() loops, correct? Same with the emplyee_name[]
> array?
>
> Thanks all,
>
> --->Rob
>
>
>
> -------------------------------------------------------
> This sf.net emial is sponsored by: Influence the future
> of Java(TM) technology. Join the Java Community
> Process(SM) (JCP(SM)) program now.
> http://ad.doubleclick.net/clk;4699841;7576301;v?http://www.sun.com/javavote
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
|