Thread: Opinions

  1. #1
    _B-L-U-E_ Betazep's Avatar
    Join Date
    Aug 2001
    Posts
    1,412

    Opinions

    I did a test with buffer.getline(*char, count, termchar) utilizing an ifstream buffer.

    I always assumed that a null pointer was written after the last character of the established array only.

    I was doing a test to check for this character and found it in every array position past my data.


    For example...

    char array[25];

    cin.getline(array, 24, '\n'); // only I was using a different char buffer

    ....

    I found that if I typed (or read in) 1234 that array[3]=='4' and array[4]=='\0' ... and that was to be expected.

    But then I found array[5] through array[24] where also equal to '\0'. (I only picked a couple to look at, so there may be an error in my findings)

    This is something that I didn't know. Do the test for yourself if you do not know the reasons for this already. Why do you think that it would be such? What is the point of overwriting the entire array with null values after the data? What is your opinion on this? Am I wrong?
    Blue

  2. #2
    of Zen Hall zen's Avatar
    Join Date
    Aug 2001
    Posts
    1,007
    It depends where your buffer is allocated and how it is initialised. If it's unintialised on the stack or has previous data in it then they'll it shouldn't be full of null characters.
    zen

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Opinions on custom system build
    By lightatdawn in forum Tech Board
    Replies: 2
    Last Post: 10-18-2005, 04:15 AM
  2. Opinions?
    By Decrypt in forum C++ Programming
    Replies: 1
    Last Post: 09-18-2005, 05:29 PM
  3. Opinions on where to start?
    By mitchell_annix in forum C++ Programming
    Replies: 3
    Last Post: 05-03-2005, 10:18 PM
  4. Favors and Opinions
    By sean in forum A Brief History of Cprogramming.com
    Replies: 6
    Last Post: 08-01-2003, 10:04 PM
  5. C++ Opinions
    By Cgawd in forum C++ Programming
    Replies: 15
    Last Post: 10-28-2002, 06:01 PM