If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Threaded View

Array, Function, and Loop - In Sync, not the boy band

Hi DevX community,

This is my first post!

I'm a beginner programmer in C++ and I'm having trouble with integrating a struct array and loop with a function - by the way, this is a lab project for school. The objective is to create a small contact database for a class and includes the following:
(1) create an array for 3 records
(2) create a function using a loop to prompt user console input for the 3 records
(3) create a function to output the three records

I first developed the program with out functions, and it ran fine. I then was able to get the output into a function; however, I ran into trouble when putting the user input into a function.

I understand array values may be initialized like so:

Code:

Student a = {"George Washington", 7065 lancaster ct, Dublin...};

My idea, which isn't working, was to call a function from a loop, put the function input into a struct variable, x, and then return it to the array initialization in the loop. Here is the basic idea behind my failing trial: