I am very new to programming language and need help urgently. I am running a program which gives me one output file for every 5 min simulation. i have to copy and rename the output file in each step so that they can be used in another program . Any suggestions on how to do it with a single code for 10 runs of continuous simulation ? so far i could manage only this which is like this :
FILE *foriginal, *fcopied;
while (fgets(line, 80, foriginal) != NULL)
fprintf(foutp,"%s",line)if(t2[i]==' ') t2[i]='0';
sprintf(c2, "%4i" ,save);
I am not sure if I am going the right way as I am really a beginner in programming world. Please help me out in this matter. thanks.
i have to copy and rename the output file in each step so that they can be used in another program .
"Copy" AND "Rename"? So you start with a file named a.txt and you are supposed to end up with what? one file? Two files? A file named a.txt and a file named b.txt? A file named b.txt and a file named c.txt?
From your description, you may want to make a couple of calls using the system command...
system("cp a.txt b.txt"); // Linux copy
system("mv a.txt b.txt"); // Linux rename
This may or may not be what you are looking for, so you may need to elaborate on the overall goal that you have. The above solution uses system calls to the operating system and avoids the need for any printf, gets, and FILE* code.