C语言自定义字符串输出函数

#include
#include
intmy_puts(constchar*);
intmain(void)
{
intnum;
constcharname[50]="hello,\nmynameisneo1218\n";
num=my_puts(name);
printf("name的长度是:%d\n",num);
return0;
}
intmy_puts(constchar*string)
{
intcount=0;
while(*string){
putchar(*string++);
count++;
}
putchar('\n');
return(count);
}
在Ubuntu下编译成功没有warning,但运行后输出大量乱码。。求解!!
慕婉清6462132
浏览 398回答 2
2回答

素胚勾勒不出你

Mac下编译运行过了,没问题,程序输出hello,mynameisneo1218name的长度是:27确认一下你编译的是不是贴上来的程序?
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript