struct, array, function, stumped >.<

Hi working on a lab and at this point we are supposed to alter the program so that a void function is used to print the information in place of the for loop & I can't figure out how to pass the struct with an array for fields to the function. Any help/hints/examples would be great.

thanks for your time! =]

ps INTRODUCTION TO PROGRAMMING USING C++ by Robert Burns is NOT great, in case anyone was wondering =P

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <string> 
#include <iostream>   
using namespace std;

#include <cctype>

struct student 
  { 
    string name;
    string address;
    string city;
    string state;
    char gender; 
    int id; 
    float gpa; 
  };

int main() 
{  
  student a[3];
  
  for(int i = 0; i < 3; i++)
    {
     cout << "Student " << i << "'s name:"; 
     getline(cin,a[i].name);
//blah blah blah     
     cout << "Student " << i << "'s gpa:";
     cin >> a[i].gpa; 
     cin.ignore(1000, 10);
    } 


// The aspect that needs to be in a void function    
  for(int i = 0; i < 3; i++)
    {
     cout << "Student " << i << "'s name:" << a[i].name << endl;     
//blah blah
     cout << "Student " << i << "'s gpa:" << a[i].gpa << endl; 
    }    
     
  return 0;
} 


thanks again for your time!
The declaration

void print( student *, int );

and its call

print( a, 3 );
Last edited on
thanks for the input =]...

but i go the error-

"LNK2019: unresolved external symbol "void __cdecl print(struct student *,int)' (?print@@YAXPAUstudent@@H@Z) refrenced in function _main

fatal error LNK1120: 1 unresolved externals
You shall define the function.
Topic archived. No new replies allowed.