开发者

strtok with space delimiter [closed]

Closed. This question needs debugging details. It is not currently accepting answers.

Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.

Closed 7 years ago.

Improve this question

hey i am trying to use the strtok function in C with " " as a delimiter and 开发者_如何学JAVAfor some reason it does not work. can some one please tell me how to parse using strtok with a space as a delimiter thanks in advance


Stolen (and slightly modified) from here.

/* 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, " ");
  }
  return 0;
}


Use tab "\t" or use both " \t" ie. space and tab both...see if it works

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜