Solvedquick help

Posts 1–6 of 6 · Page 1 of 1
quick help
i have made a program that prompts the user to enter text, but when i execute it on CMD the text comes right next to the question which doesnt look right, for example its like this: "how are you?im fine'' as you can see it looks abit messy, i have tried to add a newline by using the if statement but its still not working.

any help appreciated.
Try this:

Code:
/*header*/
#include <iostream>
using namespace std;

/* inside the function */

cout << "How are you?\n";
C:
Code:
char str[512];
printf("How are ya?\n");
fgets(str, 512, STDIN); //or scanf...
printf("%s\n", str);
C++:
Code:
char str[512];
cout << How are ya? << endl;
cin << str;
cout << str << endl;
i have tried to add a newline by using the if statement
as you can see bitcode, not did i only include at the end of the cout and cin statement i also included a n if statement.

also thanks insane hoping to try endl out today, i have tried it before but i received error messages, but ill do it again and let you know anyway.

ps. i was talking about cpp, so thanks for your time, also your code is wrong: its cin>> not cin<<
Quote Originally Posted by unspeakable View Post
also your code is wrong: its cin>> not cin<<
nice end locked ?
Posts 1–6 of 6 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us