求C语言和C++大神解答,printf怎么转成cout输出语句

2025年01月16日 22:53
有3个网友回答
网友(1):

cout输出不需要指定输出的格式类型,其他的和printf一样的,

endl 表示换行,当然 \n也还是可以用的. cout << "\n"


cout << "Trim : "<< s.Trim()  << endl;            

cout << "[3] : " <
cout <<"Replace:"<< s.Replace("c","cdef")<
cout <<"Format : "<< s.Format("1:%s; 2:%d","One",123) << endl ;    
cout <<"'book' < 'cat':"  << (s < s2) ? "True" : "False") << endl; 
cout << "Copy 'cat' to s:" <<  s << endl;

网友(2):

printf("a=",a);
转换成count<<"a=="<

网友(3):

百度一下,cout格式输出