I am making a command line program in C using Xcode. When you run the program, it initially does what it should do (asks me for the path to the file). However, when I enter a valid and existing file path, it causes the following error:
Program received signal: "EXC_BAD_ACCESS". sharedlibrary apply-load-rules all (gdb)
I have two warnings in my program, each of which is associated with the strcat function. Warnings:
warning: implicit declaration of function 'strcat'
and
warning: incompatible implicit declaration of built-in function 'strcat'
I am wondering why my program is not executing properly.
Thanks Mike
My code is published below:
#include "stdlib.h"
int main (void)
{
char *string1;
printf("Type in your file path: ");
scanf("%s", string1);
char *string2 = "tar czvf YourNewFile.tar.gz ";
strcat(string2, string1);
system(string2);
}
Maybe this is due to the distribution of characters?
source
share