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