www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/09/18/08:00:28

From: firewind <firewind AT metroid DOT dyn DOT ml DOT org>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: please I need help on this!
Date: 18 Sep 1997 00:08:33 GMT
Organization: Netcom
Lines: 42
Message-ID: <5vpre1$bj7@dfw-ixnews8.ix.netcom.com>
References: <5vnb5e$qt7 AT bgtnsc03 DOT worldnet DOT att DOT net>
NNTP-Posting-Host: elp-tx2-02.ix.netcom.com
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

David Lenk <lenkd AT pltpub DOT com> 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 <stdio.h>
> #include <conio.h>

> void main()
  ^^^^
main() *must* be declared as returning int.

> {
> int nRanda, table,A, B;  

> for (table = 1; table <9; table++)
> {
> nRanda = (rand() % 99999999);
> {
> char A[] = "this will be in the file.";
> char B = nRanda; // B should hold the file name

Okay, let me see if I understand. You got a random number from rand() and
want to create a string from it? The guy you're looking for is gcvt().

> FILE*fp;
> fp = fopen(B, "w");
> fwrite(A, sizeof A, 1, fp);
> fclose(fp);
> }
> }
> }

Your brace style could use a lot of work as well; many find such a "flat"
style exceedingly hard to read and keep track of. 

-- 
[- 				 firewind	                            -]
[-   email: firewind AT metroid DOT dyn DOT ml DOT org (home), firewind AT aurdev DOT com (work)  -]
[- 	    "You're just jealous because the voices talk to -me-."          -]

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019