New to coding but Geany is isn’t compiling this what do I do wrong?

Oct 10, 2020 at 5:57pm
Question: Write a loop that will continuously input and print the first names of contest participants until QUIT is entered in place of the name.

#include <iostream>
using namespace std;
int main()
{
count<<“Enter name or enter QUIT to stop<<endl;
cin>>name;

while(name!= “QUIT)
{
cout<<name<<endl;
cout<<“Enter name or enter QUIT to stop”<<endl;
cin>>name;
}
return 0;
}
Last edited on Oct 10, 2020 at 6:00pm
Oct 10, 2020 at 6:00pm
You haven't declared the variable "name" (presumably as a string).

You're also missing some end quotes in your while statement.

And cout has been misspelt as count.
Last edited on Oct 10, 2020 at 6:02pm
Oct 10, 2020 at 6:19pm
std::cout is misspelled.

You are not declaring/creating the name variable before you use it.

Your string constant ("QUIT) doesn't have the closing quotes (").

A real big problem, not a problem with your code, is not using code tags. PLEASE learn to use code tags when posting source code, they make reading and commenting on the code MUCH easier.

HINT, you can edit your post and add the code tags.

http://www.cplusplus.com/articles/jEywvCM9/
Oct 10, 2020 at 6:33pm
My bad all the typing errors weren’t in my actual code I’m typing this on phone and I have sausage fingers but this really helped thanks. I didn’t declare the variable.
Oct 10, 2020 at 9:51pm
1
2
3
4
5
6
7
#include <iostream>
#include <string>

int main()
{
	for (std::string name; (std::cout << "Enter first name or enter QUIT to stop: ") && (std::cin >> name) && (name != "QUIT"); std::cout << name << std::endl);
}

Topic archived. No new replies allowed.