Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
假设我有一个 int 变量c = 4;
c = 4;
现在我想要一个名为 tin 的字符串包含 4
我怎么做??
不使用 2 个程序。如果我printf("%s",tin)必须打印 4 我该怎么办
printf("%s",tin)
您可以使用sprintf或snprintf。
int c = 4; char tin [Some_Length]; sprintf(tin , "%d", c);
或者
snprintf(tin , Some_Length, "%d", c);
此外,C 中没有字符串类型。