是否有输出C的int与看跌期权较短的方法吗? [英] Is there a shorter way to output C int with puts?

查看:90
本文介绍了是否有输出C的int与看跌期权较短的方法吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在做以下很多的USB(的libusb)基于C的命令行工具我写:

I'm having to do the following a lot in a USB (libusb) C based command line utility I am writing:

char pid[20];
sprintf(pid, "Product ID : %#06x", anInteger);
puts(pid);

是否有短,一个班轮办法做到这一点?

Is there a shorter, one-liner way to do this?

推荐答案

用printf?

printf("Product ID : %#06x\n", descriptor.idVendor);

这篇关于是否有输出C的int与看跌期权较短的方法吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆