If I read a .vcf file, line by line, and output that line after each read without a std::endl, the output is a mash of letters and numbers that mean nothing.
If I read the same file, line by line, and output that line after each read WITH a std::endl, the output is presented fine.
I have a feeling it has something to do with the fact that std::endl; flushes the output buffer, but either confirm, deny or elaborate on that theory.
Is there anything I could try to fix it or to debug exactly what's going wrong?
Ideally, I'd just like to read the file, line by line, into a string buffer and then identify the string as some sort of contact data, and store it in my Contact object. From there, it would just be a matter of re-writting that data in a .csv format and I've created a (crude?) .vcf to csv converter.
Is there anything I could try to fix it or to debug exactly what's going wrong?
Unfortunately memory corruption is one of the very hardest problems to fix. There are tools which can help (such as Valgrind), but I personally don't have a whole lot of experience with them.
Usually when I run into these kinds of problems (which is rare because I'm always SUPER careful when I have to deal with raw pointers) I end up just going back over my code with a fine tooth comb to see if I can spot it, or even just rewriting the "dangerous" portions of my code entirely.
My only advice would be to go back over any portion of your code where you're dealing with arrays and make sure you never step out of bounds. And look at places where you're dealing with raw pointers and make sure your pointers are all valid.
Or better yet, don't use raw pointers or arrays at all, and use container classes so that problems like these are less likely.