Data storage

I am relatively new to c++, i have been working on an application to have me import names into an array. its a console app, but i keep getting a linker error that says:fatal error LNK1120: 1 unresolved externals. I do not know what this means here is the code:

#include <iostream>
#include <fstream>
#include <string>

using namespace std;

int index;
int count = 1;
int names [];

int main()
{
for( index = 1; index < 3001; index ++)
{
cout << "Client Name"<<count<<": ";
cin >> names[index];
}
return 0;
}

i am not sure if what i am trying to do here is possible...
Hi ! Please use code tags.

Here's a quick overview of what u have here:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <iostream>   //cin and cout are defined in here
#include <fstream>  //never used
#include <string>     //never used

using namespace std;

//global variables are 99.9% of the time bad. they should be inside of main
int index;   //this is only used as an iterator for ur 'for' loop so should be declared in there
int count = 1;
int names [];  //incomplete type. this is where ur linker error probably is. u need to give it a size...
//also, 'names' suggests that u want to write chars into here, not ints

int main()
{
//why count so high to 3000? make sure this doesn't count more than the size of the names[]
// or u'll get some more undefined behavior
for( index = 1; index < 3001; index ++)   
{
cout << "Client Name"<<count<<": ";   //'count' never increments
cin >> names[index];     //this will fail if u put in anything but an integer
}
return 0;
}
Last edited on
thank you this helped a ton
Topic archived. No new replies allowed.