Q:

Look in execvp();

I'm new trying to learn the function of fork() and the system calls, now I'm using execvp() trying to make a bash, but I have the problem that when I write a correct command, the program ends and I want to make a loop for using my bash until the person write "exit" in my command line.
The code that I used is: 
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <string.h>

int main()
{
    char cadena[100];
    char *array[100];
    char *ptr;
    int i=1;
    pid_t pid;
    pid = fork();

    if (pid < 0) {
        perror("Error en la llamada a fork().");
        return -1;
    }
    else if (pid == 0) {
        do {
            printf("prompt$ ");
            fgets(cadena, 100, stdin); 
            ptr = strtok(cadena, " \n");
            array[0] = ptr;
            while( (ptr = strtok( NULL, " \n" )) != NULL ){
                array[i] = ptr;
                i++;
            }
            array[i]=NULL;
            execvp(array[0],array);
            perror("Execvp failed"); 
        } while(array[0] != "exit");
    }
    else {                                           
        wait(NULL);
    }
    return 0;
}

I'm using the iterative structure do-while for trying to loop, but it did not work, because when I write a correct commando the program ends, and I need to keep writting commandos because I need to do a list with all the commands that I wrote after the program ends. 

A:

You have a general design problem: except when there is a call error, none of the exec functions return to caller. The common design for a shell is in pseudo code:
loop
  prompt for a command
  read a command line
  parse the command line
  if exit
     then exit loop
  else
     fork (a child to execute the command, detailed below)
     if pid is 0 (child)
        then exec command
     else
        wait for the child to end

