how to store names using array C++

i was trying to store name and in formation about an employee on an array that i will need at some times (print them later) but first name seem to be owerated by the new one .how can i store ifor as mach as i wan in array C++

my code sofar

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
#include<iosteam>
#include<string>

using namespace std;

int main()
{
 int inforSize=5;
 int a[20];
 int b[20];
 int c[20];
 int d[20];
 int e[20];
 int information[inforSize]={ a,b,c,d,e}

cout<<"enter your name :";
cin>>a;
cout<<"enter your name :";
cin>>b;
cout<<"enter your name :";
cin>>c;
cout<<"enter your name :";
cin>>d;
cout<<"enter your name :";
cin>>e;

cout<<"names are "<<information;

return 0;
}


Use appropriate types. Why would you try to store a name (which is made of characters) in an array designed to store int types?

Use std::string type to store names.

http://www.cplusplus.com/reference/string/string/

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <iostream>
#include <string>
 
int main()
{
  std::string names[20];
  std::cout<<"enter your name :";
  std::cin>>names[0];
  std::cout<<"enter your name :";
  std::cin>>names[1];
 
  std::cout << names[0] << " " << names[1];
  return 0;
} 
k i haveto give it a try
Topic archived. No new replies allowed.