Fel*_*ost 5 c string-formatting
我想格式化交流字符串printf.例如:
char string[] = "Your Number:%i";
int number = 33;
// String should now be "Your Number:33"
Run Code Online (Sandbox Code Playgroud)
有没有图书馆或我能做到这一点的好方法?
dcp*_*dcp 12
int main() {
char str[] = "Your Number:%d";
char str2[1000];
int number = 33;
sprintf(str2,str,number);
printf("%s\n",str2);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
输出:
---------- Capture Output ----------
> "c:\windows\system32\cmd.exe" /c c:\temp\temp.exe
Your Number:33
> Terminated with exit code 0.
Run Code Online (Sandbox Code Playgroud)