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.
与我的问题相关:以下代码
sprintf(buffer, "%-16s%-224s%-8s%-8s", "set", "ravi", "26", "60");
...填充空白区域。'\0'我需要用字符而不是空格来填充。这可以实现吗?
'\0'
您可以通过以下循环实现此目的:
int i; sprintf(buffer, "%-16s%-224s%-8s%-8s", "set", "ravi", "26", "60"); for (i=0;i<sizeof(buffer);i++) { if (buffer[i] == ' ') buffer[i] = '\0'; }