用printf一个非空结尾的字符串 [英] Using printf with a non-null terminated string
本文介绍了用printf一个非空结尾的字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
假如你有一个不为空结束的字符串,你知道它的确切大小,所以你怎么能打印字符串的printf用C?我记得这样的方法,但我不能找出知道......
Suppose you have a string which is NOT null terminated and you know its exact size, so how can you print that string with printf in C? I recall such method but I can not find out know...
推荐答案
有与printf的可能性,它是这样的:
There is a possibility with printf, it goes like this:
printf("%.*s", stringLength, pointerToString);
没有必要复制任何东西,不需要修改原来的字符串或缓冲区。
No need to copy anything, no need to modify the original string or buffer.
这篇关于用printf一个非空结尾的字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文