I want to make a C program which will be called with some parameters; Each parameter will represent a filename and I want to write some stuffs in each of them.
FILE * h0;
h0 = fopen(argv[0],"w");
char buffer[100] = "something here\n";
fprintf(h0,buffer);
fclose(h0);
For C++ there is something called c_str() but I didn’t manage to use it here.
Any tips how to handle it?
A file name is exactly a C string (null terminated array of char) and you’ve already answered your own question (you don’t need anything like c_str in C), since you open the file and you write in it. The
argctells you how many arguments there are in the command line, the name of the program inclusive and it is atargv[0]. So you need a loop, likeor something like that.