cout与printf

liuzq133 liuzq133 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
下面这个程序不能正常运行:
#include <string.h>
#include <stdio.h>
#include <iostream.h>

void main()
{
const int MAX = 20 ;

char str_a[MAX] ;
char str_b[MAX] ;

cout << "please input the first string:" ;
gets(str_a) ;

cout << "please input the second string:" ;
gets(str_b) ;

char *pa ;
char *pb ;

for (pa = str_a , pb = str_b ; pa < str_a + strlen(str_a) && pb < str_b + strlen(str_b) ;
pa++ , pb++)
{
if (*pa == *pb)
{
cout << *pa ;
}
}

cout << endl ;
}
如果把上面的cout << "please input the first string:" ;cout << "please input the second string:" ;输出换成printf就可以正常运行,那位知道是什么原因啊,可能涉及到cout与printf的区别,
...全文
评论 17
收藏 已收藏
分享
返回顶部
liuzq133
新手乐园 33,315 成员 41,769 内容