Download

When should you use "" and when should you use ' '

So here’s my code:


#include <iostream>
#include <string>
using namespace std;

int main()

{
	bool hungry;
	char isHungry;
	cout << "Are you hungry? y/n" << endl;
	cin >> isHungry;

	if (isHungry == 'y')
	{
		cout << "Eating..." << endl;
	}

	else {
		cout << "Welp..." << endl;
	}

	return 0;

}

So why is


if (isHungry == 'y')

not


if (isHungry == "y")

When should you use speech marks and when quotation?

Thanks!

short version: a string is always inside double quotes, single quotes denote a single character

cheers,
indy