Store names in String Array.

I have the coding below for an array for characters, but I'm having trouble figuring out how to alter it into a String Array for storing names. Also, it needs a menu having these options: getNames, sortNames, displayNames, findName, removeName. I would appreciate any help at all!

1
2
3
4
5
6
#include <iostream>
using namespace std;
const int SIZE=5;
void getData(char a[], int& s);
void display(char a[], int s);//need to display
int main ()

1
2
3
4
5
6
{
	char chs[SIZE];
	int n;
	getData(chs, n);
	display(chs, n);
}


1
2
3
4
5
6
7
8
9
10
11
12
void getData(char a[], int& s)
{
	s=0;
	do 
	{
		cout<<"Enter a character:";
		cin>>a[s];
	} while ((a[s++] != '0') && (s<SIZE));
	if (s<SIZE)
	{
		s--;
	}

}
1
2
3
4
5
void display(char a[], int s)
{//for display
	for (int i=0; i<s; i++)
	cout<< a[i]<<endl;	
}
[/code]
Last edited on
Please use code tags: http://www.cplusplus.com/articles/jEywvCM9/

I'm finding what you want a bit vague. getData is supposed to be your input function? Do you have to use static c-style arrays? This seems like a homework assignment, it'd be better if we better understand what you need to do before trying to help you.
Yes it is a homework assignment, I asked my professor for help but he wasn't too specific. So I'm confused even more. I'm totally new to programming btw.

For clarification, I need to convert the above program into a string array for storing names, by using string name [SIZE]. In line 3, would I used string name [5] or string name SIZE=5?
Topic archived. No new replies allowed.