私は現在、CプログラムにユーザーからのUnix引数を読み取らせようとしています。私はこれまでこのサイトを検索しましたが、私が間違っていることを正確に理解することはできませんでした-確かに私のポインター実装スキルはかなり限られています。
以下は私が今どのようにコードを持っているかです。私は運が悪かったのでポインタをいじり回してきました。エラーは、const * charを使用する必要があることも示していますが、他の例では、ユーザーが*charを入力できることを確認しました。
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
main()
{
char args[128];
//User input
printf("> ");
fgets(args, 128, stdin);
execvp(args[0], *args[0]);
}
私が得るエラーは次のとおりです。
smallshellfile.c: In function ‘main’:
smallshellfile.c:13:21: error: invalid type argument of unary ‘*’ (have ‘int’)
smallshellfile.c:13:5: warning: passing argument 1 of ‘execvp’ makes pointer from integer without a cast [enabled by default]
/usr/include/unistd.h:575:12: note: expected ‘const char *’ but argument is of type ‘char’
誰かが問題が何であるか知っていますか?