954,499 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

string arrays nedd help

how would be able to display all the names a user entered. the user entered the names through a while loop

Mayank23
Light Poster
31 posts since Jan 2011
Reputation Points: 10
Solved Threads: 0
 

Save all names into an array, and then use a while loop to display the array.

firstPerson
Senior Poster
3,923 posts since Dec 2008
Reputation Points: 841
Solved Threads: 608
 

thanks for your answer but can you show me in code how to do it?

Mayank23
Light Poster
31 posts since Jan 2011
Reputation Points: 10
Solved Threads: 0
 

You first. Otherwise it looks too much like you're asking someone else to do your homework for you.

arkoenig
Master Poster
703 posts since Jun 2010
Reputation Points: 359
Solved Threads: 109
 
#include <iostream>

using namespace std;

int main()
{
string h;
double res;


string names[1] = {h};


cout << " Enter 1 to start or 0 to stop." << endl;
cin >> res;

while(res == 1);
{

}
cout << " Please enter name: " << endl;
cin >> h;
}

cout << "Names " << endl << h << endl;
    }
}


heres what i made, i keep on getting a error form it and it wont compile.

Mayank23
Light Poster
31 posts since Jan 2011
Reputation Points: 10
Solved Threads: 0
 

dont worry about the curly brackets, i messed up on those

Mayank23
Light Poster
31 posts since Jan 2011
Reputation Points: 10
Solved Threads: 0
 

hi
first when you need to use a string to need to include string library

#include<string>

also
you're getting error because you're using curly brackets in a wrong way delete some and you won't have errors

delete the ones in line 20 & 26

alaa sam
Junior Poster
135 posts since Nov 2010
Reputation Points: 8
Solved Threads: 10
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: