Skip to content

Commit

Permalink
bug fix for cmd arguments.
Browse files Browse the repository at this point in the history
  • Loading branch information
youssefmattar committed Aug 18, 2022
1 parent b4e84aa commit 5d883b5
Showing 1 changed file with 41 additions and 27 deletions.
68 changes: 41 additions & 27 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,38 +23,52 @@ int main(int argc, char* argv[])
sumc++;
}
cmdBuff = (char*)malloc(sumc+1 * sizeof(char));
int iii;
for (iii = 1; iii < argc; iii++)

if (argc == 2)
{
strcpy(cmdBuff, argv[1]);
}


else
{
if (iii == 1)
{
strcpy(cmdBuff, argv[iii]);

strcat(cmdBuff, " ");
}

else if (iii == argc-1)
{
strcat(cmdBuff, argv[iii]);
}

else
{
strcat(cmdBuff, argv[iii]);

strcat(cmdBuff, " ");
}

int iii;
for (iii = 1; iii < argc; iii++)
{
if (iii == 1)
{
strcpy(cmdBuff, argv[iii]);

strcat(cmdBuff, " ");
}



else if (iii == argc - 1)
{
strcat(cmdBuff, argv[iii]);
}

else
{
strcat(cmdBuff, argv[iii]);

strcat(cmdBuff, " ");
}


}
}
printBanner(cmdBuff);
//printf("%d", sumc);
free(cmdBuff);
printBanner(cmdBuff);
//printf("%d", sumc);
free(cmdBuff);

printf("\npress any key to exit\n");
getch();
return(0);
//printf("\npress any key to exit\n");
//getch();
return(0);

}

else //if there are no args it will ask the user for input
{
char* sBuff = (char*)malloc(MAX_Buff_SZ);
Expand Down

0 comments on commit 5d883b5

Please sign in to comment.