I wrote this simple C program and couldn't quite figure out this bizarre behavior of strcat
long sum(long col, char* path, char* path2){
printf("%s\n",path2);
strcat(path,".endlines");
printf("%s\n",path2);
return 0;
}
int main(int argc, char* argv[]) {
int n=atoi(argv[1]);
sum(n,argv[2],argv[3]);
exit(EXIT_SUCCESS);
}
strcat is applied on path, but path2 is eventually modified as well. I would very much appreciate if someone let me know what was happening :) thanks
Run
./program 3 example/mountdir/location2.csv example/rootdir/location2.csv
output:
example/rootdir/location2.csv
endlines