Thread: read specific number of chars from stream

  1. #1
    Newbeer ch4's Avatar
    Join Date
    Jan 2007

    read specific number of chars from stream

    Is there any function or way to read from a stream a specific number of characters and flush the stream ?

    Need to read only 6 characters into string test

    Input : blablablablabla
    test : blabla


  2. #2
    Registered User
    Join Date
    Dec 2006
    Scranton, Pa
    Use a for loop, reading in 1 char at a time into the string, or read in the entire string and truncate it to the desired length.

  3. #3
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Rishon LeZion, Israel
    6,794 - read could specify nCount - get could specify nCount - getline could specify nCount - ignore - could specify ncount and delimiter

    Are you sure you have read istream spec and havn't found anything matching your needs?
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    David J. Wheeler

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help with this compiler error
    By Evangeline in forum C Programming
    Replies: 7
    Last Post: 04-05-2008, 09:27 AM
  2. unknown number of chars
    By Garfield in forum C Programming
    Replies: 16
    Last Post: 10-31-2001, 05:46 AM
  3. read data
    By in_need in forum C Programming
    Replies: 2
    Last Post: 10-30-2001, 08:10 AM
  4. Array of boolean
    By DMaxJ in forum C++ Programming
    Replies: 11
    Last Post: 10-25-2001, 11:45 PM
  5. Help! Can't read decimal number
    By Unregistered in forum C Programming
    Replies: 2
    Last Post: 09-07-2001, 02:09 AM