Hey, ok that worked, but I found a few more errors. Here is the revised code:
Code:
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
main()
{
char choice[8];
printf(" This program can open applications or delete files\n");
printf(" Please select what you like to do\n");
printf(" enter 'Delete' to delete files, or 'open' to open\n");
scanf(" %s", choice);
if((toupper(choice[0]) == 'O')||(toupper(choice[0]) == 'D'))
{
if(toupper(choice[0]) == 'O')
{
char empty1[25];
char empty2[55];
char applic[15];
printf("Type in the name of the app\n");
scanf(" %s", applic);
sprintf(empty1, "open -a %s", applic);
sprintf(empty2, "%s.app", empty1);
system(empty2);
}
if(toupper(choice[0]) == 'D')
{
char location[35], cdcomm[39], name[23], systemname[28];
printf("Type the location of the file\n");
printf("Ex: Macintosh HD is in the folder 'Desktop'\n");
printf("Keep in mind capitalization DOES COUNT\n");
printf("so now tell me the address of the file\n");
scanf(" %s", location);
sprintf(cdcomm, "cd %s", location);
system("cd ~/");
system(cdcomm);
printf("Now tell me the name and type of file it is\n");
printf("Ex: examplefile.txt\n");
scanf(" %s", name);
printf(" %s", name);
sprintf(systemname, "rm %s", name);
system(systemname);
}
}
else
{
printf("An error occured please restart\n");
}
return 0;
}
The problem is now the cd %s part doesn't work, it won't go to the right directory... do I have to make it all in one system() function command?