Path: utzoo!utgpu!news-server.csri.toronto.edu!helios.physics.utoronto.ca!ists!yunexus!racine From: racine@yunexus.yorku.ca (Jeff Racine) Newsgroups: comp.lang.c Subject: Creating files with variable suffixes at run time Summary: Dynamic file creation - number not known at run time - how? Keywords: fopen(), variable suffixes, dynamic Message-ID: <22418@yunexus.YorkU.CA> Date: 16 Apr 91 14:20:45 GMT References: <1991Apr12.103621.8907@umiami.ir.miami.edu> Sender: news@yunexus.YorkU.CA Organization: York University, Toronto, Ont. Lines: 27 Hi. I have a program which creates a data file. The user (at run time) enters the number of variables. When the program runs, it generates a data file which contains (in column form) the first variable, some `stuff' for the first variable, the second variable, some stuff for the second, and so on. Currently this is all dumped to one `mega' file. I would like to create separate files for each variable with names like foo1.dat, foo2.dat, and so forth. The problem is that the number of variables is variable, so I cannot hard code a number of files to be open. The solution can open a file, write data, close the file, open the next, write data, close the file etc. that is, the files do not have to be open simultaneously. I hope this description is sufficient. Has anyone done this successfully? If so would you kindly outline your solution? If not can someone see an easy way of doing this? Thanks for your time and effort. -------------------------------------------------------------------- Jeff Racine racine@nexus.yorku.ca racine@yunexus.UUCP