C++中关于输出的小问题?

来源:百度知道 编辑:UC知道 时间:2024/06/09 02:48:17
如何输出下面这句话?
This (") is a quote, and this (\) is a backslash.

试试就知道我没有疯掉。谢谢

用转义字符\嘛
#include<iostream>

using namespace std;

void main()
{
cout<<"This (\") is a quote, and this (\\) is a backslash. "<<endl;
}

用格式符\

cout<<"This (\") is a quote, and this (\\) is a backslash.";

cout<<"This (\") is a quote, and this (\\) is a backslash. "<<endl;

同意楼上观点,用字符串也应该可以,只是麻烦一些,两个特殊符号要单独赋值