char *args[32];
char **next = args;
char *temp = NULL;
char *quotes = NULL;
temp = strtok(line, " \n&");
while (temp != NULL) {
if (strncmp(temp, "\"", 1) == 0) {
//int i = strlen(temp);
printf("first if");
quotes = strtok(temp, "\"");
} else if (strncmp(temp, "\"", 1) != 0) {
*next++ = temp;
temp = strtok(NULL, " \n&");
}
}
文字列の一部が引用符で囲まれている場合、スペースを保持する方法を理解するのに苦労しています。たとえば、execvp() にこれを実行させたい場合: diff "space name.txt" sample.txt、args[0] に diff、args[1] に space name.txt、args[ に sample.txt を保存する必要があります。 2]。
これを実装する方法がよくわかりません.ifステートメントを使用していくつかの異なるロジックを試しましたが、まだ十分ではありません. 現時点では、ls "folder" のような簡単なことをしようとしていますが、printf() ステートメントを出力する while ループでスタックします。
これは質問として表現されていないことを知っています-それは私が達成しようとしていることと私がこれまでのところどこにいるのかをより説明していますが、私は問題を抱えており、ロジックがどうあるべきかについてのヒントを本当に感謝しています.