Allow a blank user input

Hello everyone, I'm new to C++ and I'm playing around with code. I've been trying to figure out how to make a user input accept a blank answer instead of continually nagging the user for one. This is my code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <iostream>
#include <conio.h>
#include <ctype.h>
#include <string>
using namespace std;
int main()
{
	int x
	std::cin >> x;
	; printf("You Entered: %d\n", x)
	; printf("Press any key to continue . . . ")
	; _getch()
	; return 0;
}


On an unrelated topic, the preview button for submitting a question has a problem, where nothing shows up in the box.
As I'm new to "C++", I'm beginning to learn it's a better idea not to mix "C".

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <iostream>
#include <string>

using namespace std;

int main () {
	string Entry;
	
	cout << "\n\tEnter Name: ";
	getline ( cin, Entry, '\n');
	
	if ( Entry.empty () )
		cout << "\tNothing to say, ok!" << endl;
	else
		cout << "\tEntry is " << Entry.size () << endl;
	
	return 0;
}
Topic archived. No new replies allowed.