Home Forums C Programming need help in adding a charecter to the file name Re: Re: need help in adding a charecter to the file name

#3609
GWILouisaxwzkla
Participant

could just do this:


/****************************************************************
* File Name : c:programstempCG.cpp
* Date : September,9,2009
* Comments : new project
* Compiler/Assembler : Visual C++ 6.0
* Modifications :
*
*
*
*
*
* Program Shell Generated At: 6:23:04 p.m.
=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/


#include < stdio.h >
#include < string.h >
#include < stdlib.h >
//#include < math.h >
//#include < iomanip >
//#include < ctype.h >



//main function ******************************

int main ( )
{

char str [ 20 ];
char numberStr [ 10 ];

strcpy ( str , "c:\data\file" );

int stringLength = strlen ( str );

int j = 0;
while ( j < 10 )
{

itoa ( j , numberStr, 10 );
strcpy ( str + stringLength , numberStr );
printf ( "%s" , str );
printf ( "n" );
FILE * file = fopen ( str , "a" );
//..................
j ++;
}
return 0 ;
}