(single quotes & double quotes)'s difference in C++

(single quotes & double quotes)'s difference in C++

Single quotes ----- characters --- actually represent an integer

Double quotes ----- string -- is a pointer to the starting character of the unnamed array ------ end with '/0'

Code 1:

int main(){
	string s1;
	s1 = 'hello';
	cout<<s1<<endl;
	return 0;
}

output:

o

Code 2:

int main(){
	string s1;
	s1 = “hello”;
	cout<<s1<<endl;
	return 0;
}

output:

hello

Guess you like

Origin blog.csdn.net/un_lock/article/details/127408869