Cannot type in CMD

I recently came across the issue of not being able to type in my cmd console. I was working on a project in MSV; while starting a new one I was unable to type in the console. *After compiling with no errors.


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

//@author Will A. Training Exercise Grade Programming

int main()
{
	int grade = NULL;
	bool repeat = true;

	std::cout<<"Grade Programming Created By Will A.\n";

	while(repeat)
	{
		if((grade <=100)&&(grade >=90))
		{
			std::cout<<"Your grade is an A\n";
		}
	}
}



Although in another project I worked on previously I still may type in the console.


You aren't asking for any input?
Well, I added

1
2
std::cout<<"Your grade is an A\n";
			std::cin>>grade;


I'm most likely completely wrong, sorry for my ignorance.

If you don't mind assisting me a tad more.
So it still doesn't let you type with that there?

That's rather odd, are you sure the window is in focus?
How do you mean? ...in focus?
Can you please post your code WITH WillDesigned's code inserted.
start with something like this,,,,

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <iostream>

using namespace std;

//@author Will A. Training Exercise Grade Programming

int main()
{
	int grade = NULL;
	char repeat = 'y';

	cout<<"Grade Programming Created By Will A" << endl;

	while(repeat == 'y')
	{
		cout<<"Enter your grade:" << endl;
		cin >> grade;

		if((grade <=100)&&(grade >=90))
		{
			cout<<"Your grade is an A"<< endl;
		}

		cout<<"Enter a new grade? Y OR N:" << endl;
		cin >> repeat;
		system("cls");
	}
	return 0;
}
Here is what I came up with very quickly. The while loop is currently unnecessary but I left it in for your sake.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <iostream>

//@author Will A. Training Exercise Grade Programming

int main()
{
	int grade = NULL;
	bool repeat = true;

	std::cout<<"Grade Programming Created By Will A.\n";
	std::cout << "Enter your grade: ";
	std::cin >> grade;
	while(repeat){
		if((grade <=100)&&(grade >=90))
		{
			std::cout<<"Your grade is an A\n";
		}
	}
} 
@CodeWeaver @joneele @firedraco

Thank you for the help! Glad to know people are considerate unlike other forums I've previously was part of.
Ah, I see. std::cin was inside your if check, which is never true because grade is 0 and is never changed.

Btw:

int grade = NULL;

This sets grade to 0, *not* something like NULL or NaN. You should only use NULL with pointers.
Yeah. Sorry about not presenting the full code.


I asked my friend whom has experience in c++. (Early till this moment)
He said it doesn't make much a difference in this case. Thanks for telling me that, I'll make sure to use that to the best of my knowledge.
Topic archived. No new replies allowed.