Questions tagged «strtok»

15
strtok()如何在C中将字符串拆分为令牌?
请向我解释strtok()功能的作用。该手册说它将字符串拆分为令牌。我无法从手册中了解其实际功能。 我添加了手表,str并*pch在第一个while循环发生时检查其工作情况,其中的内容str仅为“ this”。屏幕上如何显示下面显示的输出? /* strtok example */ #include <stdio.h> #include <string.h> int main () { char str[] ="- This, a sample string."; char * pch; printf ("Splitting string \"%s\" into tokens:\n",str); pch = strtok (str," ,.-"); while (pch != NULL) { printf ("%s\n",pch); pch = strtok (NULL, " ,.-"); } …
114 c  string  split  token  strtok 
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.