我是C编程的新手,我知道有关于如何将字符串拆分为单词的其他解释,但没有一个与我的程序类似。我很难找到我的程序中的错误:Tokenise在C编程中的字符串
#include <stdio.h>
#include <stdlib.h>
int tokenise(char str[], int start, char result[]) {
if (str[start] == "/o") {
return -1;
} else {
result = str[start];
}
}
int main() {
const int MAX_STRING = 256;
char buffer[MAX_STRING];
fgets(buffer, MAX_STRING, stdin);
char result[256];
int start;
start = tokenise(buffer, 0, result);
while (start != -1) {
printf("%s\n", result);
start = tokenise(buffer, start, result);
}
}
您是否有真正的问题? –
请在将来使用正确的缩进;它会让你的生活变得更加轻松,人们更有可能回答你的问题。这次我已经为你修好了。此外,此代码不能编译。 – szczurcio
是的,我的程序不会工作,我不知道为什么 – bike3