题解 | #参数解析#
参数解析
https://www.nowcoder.com/practice/668603dc307e4ef4bb07bcd0615ea677
#include <stdio.h> #include <string.h> int main() { char s[1001] = { 0 }; char ss[500][100] = { 0 }; int c = 0; int i = 0; int count = 0; while (scanf("%s", s) != EOF) { if (s[0] != '"') { strncpy(ss[c],s,strlen(s)); c++; } else { int len = strlen(s); while (s[len - 1] != '"') { strncpy(&ss[c][i], s, strlen(s)); i = len + i; ss[c][i] = ' '; i++; scanf("%s", s); len = strlen(s); } strncpy(&ss[c][i], s, strlen(s)-1); memmove(ss[c], &ss[c][1], sizeof(ss[c]) - 1); c++; i = 0; } } printf("%d\n", c); for (i = 0; i < c; i++) { printf("%s\n", ss[i]); } return 0; }