c - 如何将“放在C中的字符串内

标签 c string pointers escaping

我尝试使用 strstr() 来查找双引号 (") 的第一次出现,但是,当我使用这行代码时:

pch = strstr(tmp,""");

它不会编译,因为我没有终止引用。所以我用了

pch = strstr(tmp,'"');

然后告诉我有一个这样的错误:

passing argument 2 of ‘strstr’ makes pointer from integer without a cast [enabled by default]
  pch = strstr(tmp,'"'); //finds the first occurrence and deletes the preceeding
  ^
In file included from /usr/include/stdio.h:29:0,
                 from assignment1.c:1:
/usr/include/string.h:40:8: note: expected ‘const char *’ but argument is of type ‘int’
 char  *_EXFUN(strstr,(const char *, const char *));

对此有什么想法吗?或者有人知道使用 strstr 检测双引号字符的方法吗?也许可以进行 ASCII 转换?

最佳答案

使用pch = strstr(tmp,"\"");它会起作用

关于c - 如何将“放在C中的字符串内,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26828342/

相关文章:

c++ - Strtok 在行尾返回额外的数据

java - 将字符串中的英文数字替换为波斯数字,URL 除外

c - void * 赋值问题

c - 如何测试 FILE*(指向结构的指针)(如果 == NULL)?

c - 二进制文件模式

c - 当我运行代码时,出现段错误,但是当调试器运行它时,它说没有问题

更改程序以使用多行

c++ - BuildCommDCB 实际上做了什么?

string - 在for循环中获取 token 的子字符串?

c - 如何修改已传递给 C 函数的指针?