开发者

How to represent this in printf format?

开发者 https://www.devze.com 2023-02-15 05:18 出处:网络
I have: printf(\"%.2s\\n\", &s[2]); How can I represent that as a chosen value? So I would want something like:

I have:

printf("%.2s\n", &s[2]);

How can I represent that as a chosen value?

So I would want something like:

printf(%.%is\n",开发者_JAVA技巧 someInt, &s[2]); # but this doesnt work, where %i is someInt


You want printf("%.*s\n", someInt, &s[2]);. Consult the printf man page for more details.


I am confused about your question but I think you want printf("%d.%s\n",someint,&s[2]);

0

精彩评论

暂无评论...
验证码 换一张
取 消