Bleh. I'm not really sure what the difference is between a 'string' and a 'c string' and I was having troubles from before that unfortunately haven't been resolved. (The previous thread is at http://cboard.cprogramming.com/showthread.php?t=59458)
I was wondering if it's more practical to use the old C strings than it is to use a class of strings.
I -think- a C string is really just a pointer to the first element in an array of characters, whereas a C++ string is a class.
If that's the case, wouldn't it be better to use the class string? I know that can really only be answered in context, but take for example the program I was writing that used the class string for file i/o.
One particular reply made it seem that C++ strings weren't used as often as C strings. If someone could point out the pros and cons of each, or direct me to some sort of site that can help me with this, that'd be great. =)
I'm a beginner, and if you look at the code (attatched to the aforementioned thread) you can probably tell. =P The program works for the most part; the only thing wrong with it is saving a list. Sometimes the lists save properly, but in other cases it wil duplicate the list instead of writing over it.
The way it's supposed to save is look through the lists that are already saved, and if it's a new list it just adds it to the file. This works fine. If it's an already existing list, it reads the old lists into a representation of the new lists, and excludes the old list.
At this point the representation (done with vectors) contains the rest of the lists, and not the old list. Then, it adds the list being saved to the end, just as if it were a new list.
It determines which list to exclude by comparing the names of the lists, and if they match, it skips over it while reading into the representation (rather, reads it, but discards it).
For some reason that only works once! If the list being over written is any list but the first list, this won't work.
Any help is welcome. O.o
Thanks in advance.