Code:
#include <stdio.h>
#include <string.h>
int main ()
{
int i;
int j;
char ip[5];
FILE *fp;
char filename[25] ;
for (i = 0; i < 10; i++)
{
for (j = 0; j<3; j++)
{
sprintf(ip,"%d",j);
if(i == 0)
{
strcpy(filename, "injection-0");
if (j==0)
strcat(filename,"_11.txt");
else if (j==1)
{
strcat (filename,ip);
strcat (filename,".txt");
}
else if (j==2)
strcat (filename,"_12.txt");
}
if ((fp = fopen(filename, "w")) != NULL)
{
fprintf(fp, "mass_part mass_flow_part diam_part accretion surf_ID cel_ID temp vel_abs vel_nor vx vy vz Ax Ay Az Angle Wa Wb Wc WEAR\n");
fclose(fp);
}
}
}
getchar();
return 0;
}
This is what u wanted. Now dont just copy the code and paste it. Go through it again, Look at the chnages make. And see why the changes has been made. If you still dont understand ask questions.
ssharish2005