+ 1
c++ string that has a return value ?
how can i write a string with a return value . for example i will input a name . then the program will output the entered name and so on . i dont want my program will exit if i dont want to enter a value that is exit .
4 Réponses
+ 7
std::string var = "";
while (var != "exit")
{
std::cin >> var;
std::cout << "Your input is : " << var << std::endl;
}
+ 1
sir hatsy rei i tried it but it continuos showing my input i want my program tha i can input then show the output then stop then another input
+ 1
its working now sir thank you !
0
If you want to read the string from keyboard just use cin to read and store it in a variable and then cout or printf to print it to screen. I think there is a lesson for this in this app (but not 100% sure)