以下函数解析字符串str是否合法的C语言字符串字面值定义(不考虑八进制和十六进制字符编码),如果是,则将解码后的内容保存到buf中,并返回0,否则返回-1。比如,"hello \"sangfor\""解码后结果为hello "sangfor",请完成该函数代码: int unescape_c_quoted(char *buf, const char *str) { } 框架代码: int main() { char str[10000]; char buf[10000]; int len; int ret; if (fgets(str, sizeof(str), stdin) == NULL) { fprintf(stderr, "input error\n"); return 0; } len = strlen(str); while (len 0 && isspace(str[len - 1])) { str[len - 1] = '\0'; --len; } ret = unescape_c_quoted(buf, str); if (ret printf("error\n"); else printf("%s\n", buf); fprintf(stderr, "input:%s\noutput:%s\n", str, buf); return 0; }
输入描述:
字符串


输出描述:
解码后的字符串
示例1

输入

"\"hello world\\n\\\"too\""

输出

"hello world\n\"too"
加载中...