Well, what have you done so far? And have you read http://www.cplusplus.com/reference/string/string/ and any of the links that may apply to what you are doing?
I have gone through the reference articles about strings, but I haven't been able to find anything of help to me.
So far I have created a string and have possibly put in some words:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
#include <iostream>
#include <iomanip>
#include <string.h>
usingnamespace std;
int main()
{
constint SIZE = 20;
string names[SIZE];
cout << "Please type your name like this: Last Name (comma) First Name: ";
cin >> names[SIZE];
cout << names[SIZE];
return 0;
}
This code doesn't do what I want it to do, and thus far I am clueless as to how to get it to output what I just input.
EDIT: Updated code so it outputs part of the input.
#include <iostream> //didn't need iomanip
#include <string.h>
usingnamespace std;
int main()
{
string names;
cout << "Please type your name like this: Last Name (comma) First Name: ";
cin >> names;
cout << names;
cin.get();
cin.get();
return 0;
}
strings are dynamic, so you only need to clarify how large they are if you specifically want them to be static.
I didn't compile it, but what exactly did your code do wrong? The only obvious thing i could see was a possible runtime error if names[i] had empty characters at the end of it.