home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / lang / cplus / 18824 < prev    next >
Encoding:
Text File  |  1993-01-07  |  974 b   |  32 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!malgudi.oar.net!news.ysu.edu!do-not-reply-to-path
  3. From: af458@yfn.ysu.edu (Jon K. Salmon)
  4. Subject: How to limit string output length w/ stream manips?
  5. Message-ID: <1993Jan8.025836.10039@news.ysu.edu>
  6. Sender: news@news.ysu.edu (Usenet News Admin)
  7. Nntp-Posting-Host: yfn.ysu.edu
  8. Organization: Youngstown State University/Youngstown Free-Net
  9. Date: Fri, 8 Jan 1993 02:58:36 GMT
  10. Lines: 20
  11.  
  12.  
  13. NetHeads,
  14.  
  15. I would like to limit the output length of a string sent to an
  16. output stream.  For example, given a string...
  17.  
  18.   const char *Bob = "1234567890ABCDEF";
  19.  
  20. are there any manipulators or combination of manipulators which
  21. would allow
  22.  
  23.   cout << [manip [manip [...]]] << Bob;
  24.  
  25. to output "12345"?  I have tried combinations of setw(), setfill(),
  26. and setprecision() to no avail.  Anyone know what will?  Or am I
  27. resigned to either a) limiting the string length itself, or
  28. b) writing my own manipulator?
  29.  
  30. -- Jon
  31. -- 
  32.