我是系统调用和C编程的新手,正在完成我的大学任务.
我想调用'ls'命令并让它打印目录.
我有什么:(我添加了评论,这样你就可以看到我看到的每个变量.
int execute( command* cmd ){
char full_path[50];
find_fullP(full_path, p_cmd);
//find_fullP successfully updates full_path to /bin/ls
char* args[p_cmd->argc];
args[0] = p_cmd->name;
int i;
for(i = 1; i < p_cmd->argc; i++){
args[i] = p_cmd->argv[i];
}
/*
* this piece of code updates an args variable which holds arguments
* (stored in the struct) in case the command is something else that takes
* arguments. In this case, it will hold nothing since the command
* will be just 'ls'. …Run Code Online (Sandbox Code Playgroud) 在下面的代码中,如果字符是大写字母,则打印第一个语句,但是对于小写字母,打印第二个语句.这是什么原因?我正在使用dev c ++编译我的代码.
#include<stdio.h>
#include<conio.h>
#include<ctype.h>
int main()
{
char c;
printf("enter a character\n");
scanf("%c",&c);
int i;
i=isalpha(c);
if(i==1)
printf("entered character is an alphabet\n");
else
printf("entered character is not an alphabet\n");
getch();
return 0;
}
Run Code Online (Sandbox Code Playgroud)