#include <string.h>
#include <stdio.h>
#include <stdlib.h>
int main()
{
//wchar_t str[]=L"这个是一个测试";
//char *p=(char *)str;
int i;
const char* str = "这是一个测试";
for (i = 0; i < strlen(str); i += 2)
{
printf("%c%c\n", str[i], str[i + 1]); //每次输出两个 %c 即可
}
system("pause");
return 0;
}
C - 输出字符串中的每个中文字符
本文展示了一个使用C语言进行字符串操作的简单示例,通过遍历字符串并以每两个字符为一组输出,演示了基本的字符串处理技巧。代码中包含了必要的头文件,并使用了system函数暂停程序以便查看输出。

被折叠的 条评论
为什么被折叠?



