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

Recommended Answers

All 6 Replies

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

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

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

#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.

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

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.