Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/55.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C 基于空间划分字符数组中的字符_C_Arrays_Pointers - Fatal编程技术网

C 基于空间划分字符数组中的字符

C 基于空间划分字符数组中的字符,c,arrays,pointers,C,Arrays,Pointers,我的代码如下: #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_

我的代码如下:

#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);
}

如何中断此字符数组并分别获取这些单词?

将每个单词后的第一个空格替换为空字符。每个单词的第一个字母都有一个指向该单词的指针。 这是标准库函数strtok使用的方法

1- hello
2- how
3- are
4- you