home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / lang / cplus / 15820 < prev    next >
Encoding:
Text File  |  1992-11-05  |  1.7 KB  |  61 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!brunix!cs.brown.edu!rbb
  3. From: rbb@cs.brown.edu (Robert Baynes)
  4. Subject:  Re: Creating a directory
  5. Message-ID: <1992Nov5.131530.18265@cs.brown.edu>
  6. Sender: news@cs.brown.edu
  7. Organization: Brown Computer Science Dept.
  8. Date: Thu, 5 Nov 1992 13:15:30 GMT
  9. Lines: 50
  10.  
  11. Sometime ago I posted a request for help on creating a
  12. directory name which needed to contain integers. I received
  13. many responses and wish to thank everyone for their 
  14. suggestions. The one that worked very well (and is 
  15. enclosed below) uses the streams of C++ (which I was
  16. looking for): 
  17.  
  18. ostrstream outd;
  19.  
  20.  
  21.      outd<< "./"<<"IA"<<IAID<<ends;
  22.     mkdir(outd.str,mode);
  23.  
  24.  
  25. ------------------------old article-------------------------------
  26.  
  27.  
  28. In article <1992Oct27.161738.3863@cs.brown.edu> I wrote:
  29.  
  30. >I am writing a routine to create a directory. Part of the 
  31. >name of the directory is an integer that must be converted
  32. >to chars. I am using mkdir.
  33.  
  34.  
  35. >       Example:
  36.  
  37. >       int IAID = 244;
  38. >    
  39. >       char *path;
  40. >       char *slash = "/";
  41. >       strcat(path, slash);
  42. >       strcat(path, IAID);
  43.  
  44. >       mkdir (path, mode);
  45.  
  46. >The problem is that IAID needs to be a char * to be strcat'ed to path.
  47. >But how can this be done?? Does anyone know of a routine to convert
  48. >an integer to a char * with out complaints at run time? If I cast
  49. >IAID (char *)IAID, at run time I get an invalid address for the
  50. >result.
  51.  
  52.  
  53. Again, thanks to everyone you responded.
  54. -- 
  55. *******************************************************************************
  56.     Bob Baynes        Department Of Computer Science
  57.     rbb@cs.brown.edu    Box 1910, 115 Waterman Street
  58.     (401)863-7684        Brown University
  59.                 Providence, RI 02912
  60. *******************************************************************************
  61.