fprintf(fp,"%-8s|","high");什么意思?fprintf(fp,"%-8s|","high");这里的"%-8s|"是什么意思?

来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/23 18:55:13
fprintf(fp,"%-8s|","high");什么意思?fprintf(fp,"%-8s|","high");这里的"%-8s|"是什么意思?fprintf(fp,"%-8s|","high"

fprintf(fp,"%-8s|","high");什么意思?fprintf(fp,"%-8s|","high");这里的"%-8s|"是什么意思?
fprintf(fp,"%-8s|","high");什么意思?
fprintf(fp,"%-8s|","high");
这里的"%-8s|"是什么意思?

fprintf(fp,"%-8s|","high");什么意思?fprintf(fp,"%-8s|","high");这里的"%-8s|"是什么意思?
向右对齐处理一个字符串(就是后面的"high"),右边加一个竖线,然后输出到通过fp打开的文件中.fprintf是流输出函数吧,一般用来写入数据到文件.除了前面多了个决定目标的参数之外,其它用法基本和printf差不多.
输出的文件中应该是“ high|”的效果,%-8s决定这个字符串总长度为8,符号表示向右对齐,左边补充空格(没有符号则是向左对齐,右边补空格).