c语言字符串printf
发布时间: 2025-03-02 03:30:30
Ⅰ c语言怎么用printf输出字符串。
void main()
{
unsigned char *x = "ab,sdf,sad,23432,cc";
data = x;
printf("data = %c ", *data);
printf("data = %s ", data);
system("pause");
}
(1)c语言字符串printf扩展阅读:
printf输出字符串的一些格式
1、原样输出字符串:printf("%s", str);
2、输出指定长度的字符串, 超长时不截断, 不足时右对齐:printf("%Ns", str);
注:N 为指定长度的10进制数值
3、输出指定长度的字符串, 超长时不截断, 不足时左对齐:printf("%-Ns", str);
注:N 为指定长度的10进制数值
4、输出指定长度的字符串, 超长时截断, 不足时右对齐:printf("%N.Ms", str);
注:N 为最终的字符串输出长度
M 为从参数字符串中取出的子串长度
5、输出指定长度的字符串, 超长时截断, 不足时左对齐是:printf("%-N.Ms", str);
注:N 为最终的字符串输出长度
M 为从参数字符串中取出的子串长度
参考资料来源:printf-网络
热点内容