【发布时间】:2015-02-23 04:36:07
【问题描述】:
在我下面的代码中:
#include <stdio.h>
#include <stdlib.h>
int main() {
char text[256];
// three character pointers
char *new_line;
// store new_line pointer with hello
new_line = strcpy(text, "hello how are you");
while(*new_line)
printf("%c",*new_line++);
return (0);
}
我正在尝试根据存储在数组中的单词之间的空间来划分 *new_line 指向的数组。更具体地说,我想为数组中的每个单词分配索引并将其显示为:
1- hello
2- how
3- are
4- you
如何打破这个 char 数组并单独获取这些单词?
【问题讨论】: