ForumsProgramming ForumC++ help

6 3615
zoogle11
offline
zoogle11
14 posts
Nomad

#include <iostream>
#include <string>

using namespace std;

int main()
{
string get;
string again;
string ret;
do;
while (again != "n&quot;
cout << "Type Qbasic get C++" << endl;
getline (cin, get);
if (get == &quotrint&quot{
ret = "cout <<";
}
else if (get == "input&quot{
ret = "cin >>";
}
cout << ret << endl;
cout << "Again(y, n)?\
";
cin >> again;
if (again == "y&quot{
}
else{
}
system (&quotause&quot;
return 0;
}

  • 6 Replies
zoogle11
offline
zoogle11
14 posts
Nomad

It will compile but not run. It dosent run the prog its just a black screen.

Hectichermit
offline
Hectichermit
1,828 posts
Bard

all the code has to go right after DO and before while, other wise you have an empty do while loop B)


#include <iostream>
#include <string>

using namespace std;

int main()
{
string get;
string again;
string ret;
do { cout << "Type Qbasic get C++" << endl;
getline (cin, get);
if (get == &quotrint&quot{
ret = "cout <<";
}
else if (get == "input&quot{
ret = "cin >>";
}
cout << ret << endl;
cout << "Again(y, n)?\\
";
cin >> again;
if (again == "y&quot{
}
else{
}
system (&quotause&quot;
return 0;
}
while (again != "n&quot;


I didnt test it out

zoogle11
offline
zoogle11
14 posts
Nomad

still is not working

Hectichermit
offline
Hectichermit
1,828 posts
Bard

#include <iostream>
#include <string>

using namespace std;

int main()
{
string get;
string again;
string ret;
do
{
cout << "Type Qbasic get C++" << endl;

getline (cin, get);

if (get == &quotrint&quot
{
ret = "cout <<";
}
else if (get == "input&quot
{
ret = "cin >>";
}
cout << ret << endl;

cout << "Again(y, n)?\\\\";

cin >> again;

if (again == "y&quot
{

}
else
{

}
return 0;
}
while (again != "n&quot;
}


I formated the code a bit more readable...the system("Pause&quot stoped it from building I think but a few missing brackets and such wouldn't let my code compile....also I don't think your code could have compiled since it had too many syntax errors. What IDE do you use?

zoogle11
offline
zoogle11
14 posts
Nomad

I use devC++

zoogle11
offline
zoogle11
14 posts
Nomad

It still dosent loop it just ends.

Showing 1-6 of 6