diff --git a/main.c b/main.c index 57b5fb4..b71b64c 100644 --- a/main.c +++ b/main.c @@ -81,8 +81,12 @@ int getUserName(char* name) int status; pid_t pid; char* path = (char *)malloc(sizeof(char)); + char* exe = (char *)malloc(sizeof(char)); + strcpy(exe,args[0]); strcpy(path, PATH); - strcat(path, args[0]); + strcat(path, exe); + + printf("try: %s \n",args[0]); pid = fork(); @@ -134,7 +138,6 @@ int getUserName(char* name) tok = strtok(NULL, " \n"); } - if(wordCnt == 0) //if there are no "words" in input - return null return NULL; @@ -150,7 +153,9 @@ int getUserName(char* name) tok = strtok(input," \n"); while (tok != NULL) { - returnArr[i] = tok; + returnArr[i] = (char *)malloc(strlen(tok)*sizeof(char)); + //returnArr[i] = tok; + strcpy(returnArr[i], tok); if(wordCnt == 1) checkIfQuit(tok); tok = strtok(NULL, " \n");