in_stream.get(char) question

This is a discussion on in_stream.get(char) question within the C++ Programming forums, part of the General Programming Boards category; ok i have a .bin file full of bytes, and i wrote a program to put the max product of ...

  1. #1
    Registered User
    Join Date
    Nov 2001
    Posts
    11

    in_stream.get(char) question

    ok i have a .bin file full of bytes, and i wrote a program to put the max product of 5 consecutive bytes in max. everything works good when i tested it however i reallized that its not reading everything. When i hex edited file.bin there is 10000 bytes and when i outputted all the products to a file for debugging i found only 4382 bytes searched through?
    when i did "in_stream.get(next);" from the file.bin does it skip certain numbers like CR etc? is there another command to pull any value so i can get all the values from the file???

    thanks
    ...

  2. #2
    Registered User
    Join Date
    Nov 2001
    Posts
    17
    in_stream.read((char*)buffer, sizeof(buffer));
    -----------------------------------------------
    everready

    To code, or not to code, that is the question.

    Well the answer is 'TO CODE' of cause

  3. #3
    Registered User
    Join Date
    Nov 2001
    Posts
    11
    ok i just converted the program with that method however it is producing the same results heh.
    is in_stream.read((char*)buffer, sizeof(buffer)); different from
    in_stream.read((char),count); where as count =1 to get the next char into buffer[x] because char=&buffer[x]
    i'm not really sure how to use the syntax you showed me :P
    ...

  4. #4
    Registered User
    Join Date
    Nov 2001
    Posts
    17
    The (char*) is used to cast the var. that the data will be read into 1 byte, and the sizeof(buffer) is used to ensure that the correct number of bytes are read into the specified var.

    As for "is in_stream.read((char*)buffer, sizeof(buffer)); different from in_stream.read((char),count); where as count =1 to get the next char into buffer[x] because char=&buffer[x]" I think so.
    -----------------------------------------------
    everready

    To code, or not to code, that is the question.

    Well the answer is 'TO CODE' of cause

  5. #5
    Registered User
    Join Date
    Nov 2001
    Posts
    11
    i changed to the syntax you showed me i think
    in_stream.read((char),sizeof(counter)); char counter; char=&buffer[x];
    however still when i do out_stream<<*char; it matches the file in the beginning however throughout the file bytes are still missing like they are not being read. only 4386 of the 10000 bytes are copied.
    ...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Alice....
    By Lurker in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 06-20-2005, 02:51 PM
  2. Debugging question
    By o_0 in forum C Programming
    Replies: 9
    Last Post: 10-10-2004, 05:51 PM
  3. Question about pointers #2
    By maxhavoc in forum C++ Programming
    Replies: 28
    Last Post: 06-21-2004, 12:52 PM
  4. Question...
    By TechWins in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 07-28-2003, 09:47 PM
  5. Question, question!
    By oskilian in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 12-24-2001, 12:47 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21