home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!brunix!cs.brown.edu!rbb
- From: rbb@cs.brown.edu (Robert Baynes)
- Subject: Re: Creating a directory
- Message-ID: <1992Nov5.131530.18265@cs.brown.edu>
- Sender: news@cs.brown.edu
- Organization: Brown Computer Science Dept.
- Date: Thu, 5 Nov 1992 13:15:30 GMT
- Lines: 50
-
- Sometime ago I posted a request for help on creating a
- directory name which needed to contain integers. I received
- many responses and wish to thank everyone for their
- suggestions. The one that worked very well (and is
- enclosed below) uses the streams of C++ (which I was
- looking for):
-
- ostrstream outd;
-
-
- outd<< "./"<<"IA"<<IAID<<ends;
- mkdir(outd.str,mode);
-
-
- ------------------------old article-------------------------------
-
-
- In article <1992Oct27.161738.3863@cs.brown.edu> I wrote:
-
- >I am writing a routine to create a directory. Part of the
- >name of the directory is an integer that must be converted
- >to chars. I am using mkdir.
-
-
- > Example:
-
- > int IAID = 244;
- >
- > char *path;
- > char *slash = "/";
- > strcat(path, slash);
- > strcat(path, IAID);
-
- > mkdir (path, mode);
-
- >The problem is that IAID needs to be a char * to be strcat'ed to path.
- >But how can this be done?? Does anyone know of a routine to convert
- >an integer to a char * with out complaints at run time? If I cast
- >IAID (char *)IAID, at run time I get an invalid address for the
- >result.
-
-
- Again, thanks to everyone you responded.
- --
- *******************************************************************************
- Bob Baynes Department Of Computer Science
- rbb@cs.brown.edu Box 1910, 115 Waterman Street
- (401)863-7684 Brown University
- Providence, RI 02912
- *******************************************************************************
-