From: "Mark S. Novojilov" Newsgroups: comp.os.msdos.djgpp Subject: Re: please I need help on this! Date: Fri, 19 Sep 1997 01:23:18 +0200 Organization: Universitaet Trier Lines: 65 Message-ID: <3421B7E6.AC8EF79E@explorer.uni-trier.de> References: <5vnb5e$qt7 AT bgtnsc03 DOT worldnet DOT att DOT net> NNTP-Posting-Host: sliphost4177.uni-trier.de Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk David Lenk wrote: > This is the of code from a program that I have been trying to write. I > need a way of makeing a filename and storing it in a variable so that it > can be used in a fprintf or fwrite command. I ask if you could please > anotate the source if you decide to post any. > > #include > #include > > void main() > { > int nRanda, table,A, B; what are you A,B of type integer declaring for?? > > > for (table = 1; table <9; table++) > { > nRanda = (rand() % 99999999); 9 times assigning a random value in nRanda, purpose? > { > char A[] = "this will be in the file."; better devlare this A at start of main, instead ofstrange A,B of type integer. > char B = nRanda; // B should hold the file name Man, B must be a string, an array of chars!!!Not a character. > FILE*fp; > fp = fopen(B, "w"); > fwrite(A, sizeof A, 1, fp); > fclose(fp); > } > } > } > > PS I write for DOS. > -- > Thanks in advance for all your help! > > David Lenk, ~SamWise~ > lenkd AT pltpub DOT com > www.pltpub.com/lenkd Here look, a code for generating random filename into FileName: char FileName[13]; int i; for (i=0;i<8;i++) FileName[i]=rand()%('z'-'a'+1)+'a'; FileName[8]='.'; for (i=9;i<12;i++) FileName[i]=rand()%('z'-'a'+1)+'a'; FileName[12]='\0'; thats it. - Mark