ptr=strrchr(path,'\\');
strncpy(path1,path,ptr-path);
path1[ptr-path]='\0';
strcat(path1,"\\file.txt");
output_file=fopen(path1,"w");
here path is some path of an input file. this code works fine for me in borlandc. when i use gcc it shows "Segmentation fault (core dumped)" error.