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
September 9, 2009 at 10:57 pm
#3609
GWILouisaxwzkla
Participant
could just do this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | <br /> /****************************************************************<br /> * File Name : c:programstempCG.cpp<br /> * Date : September,9,2009<br /> * Comments : new project<br /> * Compiler/Assembler : Visual C++ 6.0<br /> * Modifications :<br /> *<br /> *<br /> *<br /> *<br /> *<br /> * Program Shell Generated At: 6:23:04 p.m.<br /> =-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/<br /> <br /> <br /> #include < stdio.h ><br /> #include < string.h ><br /> #include < stdlib.h ><br /> //#include < math.h ><br /> //#include < iomanip ><br /> //#include < ctype.h ><br /> <br /> <br /> <br /> //main function ******************************<br /> <br /> int main ( )<br /> {<br /> <br /> char str [ 20 ];<br /> char numberStr [ 10 ];<br /> <br /> strcpy ( str , "c:\data\file" );<br /> <br /> int stringLength = strlen ( str );<br /> <br /> int j = 0;<br /> while ( j < 10 )<br /> {<br /> <br /> itoa ( j , numberStr, 10 );<br /> strcpy ( str + stringLength , numberStr );<br /> printf ( "%s" , str );<br /> printf ( "n" );<br /> FILE * file = fopen ( str , "a" );<br /> //..................<br /> j ++;<br /> }<br /> return 0 ;<br /> }<br /> <br /> <br /> |