Project not running?

So I have this code here, and I am struggling to get it to compile, all I get is the error "error C4716: 'getNames' : must return a value"

From what I can see everything should be working. Any ideas?


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
43
44
45
46
47
48
49
50
#include <iostream>
#include <string>
using namespace std;

int getNames(string[], int);
void displayNames(string[], int);

int main()
{
   int const arraySize(10);	
   int names = 8;			
   string array[arraySize];	

   getNames(array, arraySize);

   displayNames(array, 8);

   return 0;
}

int getNames(string array[], int arraySize)
{
   int names;

   for (int count = 0; count < 10; count++)
   {
      cout << "Enter name " << (count + 1) << " of 8: ";
      cin >> names >> array[count];

      if (count < 8)
      {
         names++;
      }
   }

   cout << names << " received.";
   }


void displayNames(string array[], int names)
{
 
   for (int count = 0; count < names; count++)
   {
      cout << array[count] << endl;
   }

   system("PAUSE");
   
}
From what I can see everything should be working
int getNames(string array[], int arraySize) Here you promised that this fuction will return int. It didn't. Behavior of this program is undefined and your IDE did you a favor by detecting it.
oh, duh.

so should changing it to void fix it?
You cant try and find out.
i wasn't at my computer.

i just did and it worked, thank you!
Topic archived. No new replies allowed.