Hello guys. I am working on the code below. I am trying to create my own shell. The code compiles without errors, but when I execute it though it doesn't output anything. I have tried it with /bin/ls as input and it doesn't work. Any suggestions?
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
int main(int argc, char **argv, char **envp)
{
char line[50];
int length = 50;
int i = 0, j = 0, k = 0;
system("clear");
printf("[m_shell ] ");
fgets(line, length, stdin);
while(line[k] != '\0')
{
argv[i] = (char *)malloc(sizeof(char) * 11);
while(line[k] != ' ')
{
argv[i][j] = line[k];
k ++;
j ++;
}
argv[i][j] = '\0';
j = 0;
k ++;
i ++;
}
execve(argv[0], argv, envp);
return 0;
}