Three in one.. :)

This is a discussion on Three in one.. :) within the C++ Programming forums, part of the General Programming Boards category; I don't like flooding on forum so I'll ask a series of questions in one thread. 1. How safe is ...

  1. #1
    x4000 Ruski's Avatar
    Join Date
    Jun 2002
    Location
    Outer Space!
    Posts
    542

    Three in one.. :)

    I don't like flooding on forum so I'll ask a series of questions in one thread. 1. How safe is using exit(0); what are the advantages and disadvantages. 2. I have a file buffered in a stringstream. I access that stringstream more than once.. How can I reset the position from where it's being read using the >> operator? 3. About vectors, are they really safe when defining no size?
    what does signature stand for?

  2. #2
    Tropical Coder Darryl's Avatar
    Join Date
    Mar 2005
    Location
    Cayman Islands
    Posts
    503
    Not so sure what you mean by safe, but

    1. Depends on your program, exit does standard cleanup and closes any open files. Also, you can use atexit() to have a function called in conjuction with using exit. That function can then do any "non-standard" cleanup.

    2. seekg / seekp inherited from istream/ostream

    3. again with the safe...hmmm, if you mean guranteed to clean up after themselves then yes they are safe. guaranteed to allocate memory when you properly add an element then yes (barring exceptional circumstance like being out of memory, but that's not vectors fault). If you mean using them in place of a c style array, then I would say they are not safe in the same way that arrays are not safe, since there is no bounds checking. However, when your program crashes cause you step out of bounds, the vector will still clean up after itself, where the array won't.

Popular pages Recent additions subscribe to a feed

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