Jump to content

C++ help

Sdot

I am doing an assignment for school and it just isn't working. I have to use the getline() function and specify a delimiter value for a new line character.

 

 cout << "What is your favorite food? ";getline(cin,favFood, '\n') ; 

 

Does anyone know what I am doing wrong?

Link to comment
Share on other sites

Link to post
Share on other sites

I'm sorry guys, I got it. I put a space after the close parenthesis, go ahead and delete this thread pls.

Link to comment
Share on other sites

Link to post
Share on other sites

#include <iostream>#include <string>using namespace std;int main () {  string favorite;  cout << "What is your favorite food? ";  getline (cin, favorite);  cout << "Your answer: " << favorite << endl;  return 0;}

Try this. 

Link to comment
Share on other sites

Link to post
Share on other sites

#include <iostream>#include <string>using namespace std;int main () {  string favorite;  cout << "What is your favorite food? ";  getline (cin, favorite);  cout << "Your answer: " << favorite << endl;  return 0;}

Try this. 

 

Thank you

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×