求C语言和C++大神解答,printf怎么转成cout输出语句
#include<stdio.h>#include<stdlib.h>#include<string.h>#include"GFSString.h"voidmain(){...
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "GFSString.h"
void main() {
FString s,s2;
s = " abc abc";
s += " test ";
printf("Trim : '%s'\n",s.Trim());
s = s.Trim();
printf("[3] : '%c'\n",s[3]); //输出字符s[3]
printf("Replace : '%s'\n",s.Replace("c","cdef")); //输出 s.Replace("c","cdef")的值
printf("Format : '%s'\n",s.Format("1:%s; 2:%d","One",123));
s = "book"; //输出 s.Format("1:%s; 2:%d","One",123)的值
s2 = "cat";
printf("'book' < 'cat': %s\n",(s < s2) ? "True" : "False");
s = s2;
printf("Copy 'cat' to s: %s\n", s);
} 展开
#include <stdlib.h>
#include <string.h>
#include "GFSString.h"
void main() {
FString s,s2;
s = " abc abc";
s += " test ";
printf("Trim : '%s'\n",s.Trim());
s = s.Trim();
printf("[3] : '%c'\n",s[3]); //输出字符s[3]
printf("Replace : '%s'\n",s.Replace("c","cdef")); //输出 s.Replace("c","cdef")的值
printf("Format : '%s'\n",s.Format("1:%s; 2:%d","One",123));
s = "book"; //输出 s.Format("1:%s; 2:%d","One",123)的值
s2 = "cat";
printf("'book' < 'cat': %s\n",(s < s2) ? "True" : "False");
s = s2;
printf("Copy 'cat' to s: %s\n", s);
} 展开
3个回答
2015-05-09
展开全部
cout输出不需要指定输出的格式类型,其他的和printf一样的,
endl 表示换行,当然 \n也还是可以用的. cout << "\n"
cout << "Trim : "<< s.Trim() << endl;
cout << "[3] : " <<s[3] << endl; //输出字符s[3]
cout <<"Replace:"<< s.Replace("c","cdef")<<endl; //输出 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;
展开全部
printf("a=",a);
转换成count<<"a=="<<a<<endl;
转换成count<<"a=="<<a<<endl;
追问
printf("Format : '%s'\n",s.Format("1:%s; 2:%d","One",123));那这句呢???
追答
count<<"Format :"<<s.Format("1:%s; 2:%d","One",123)<<endl;
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
百度一下,cout格式输出
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询