#include <stdio.h>
int main() {
char url[200]; // Adjust the size based on your expected URL length
char keyword[] = "this parameter should be changed each time!";
char auth[] = "username:password";
// Construct the URL string with placeholders
snprintf(url, sizeof(url), "http://website.com/?keyword=%s&auth=%s", keyword, auth);
// Print the constructed URL
printf("URL: %s\n", url);
return 0;
}
1条答案
按热度按时间0lvr5msh1#
在C中,可以通过使用格式化字符串函数(如
sprintf
或snprintf
)来实现与Python的f-strings
类似的功能。字符串