I've seen programmers use .c_str() when opening up a file...notably in SDL. The def of .c_str() is a function that converts a string variable into a null-terminated array of characters...but I don't understand that. Why do programmers use this function to open up files instead of just typing in the file path? Thanks
Sorry but I'm still not understanding. When should a programmer use the .c_str() function instead of the file name? It kind of sound like you are saying .c_str() serves as a middle man until the programmer is ready to specify the file name
When should a programmer use the .c_str() function instead of the file name?
It's got nothing at all to do with file names.
The c_str() function is used to get a c-style pointer-to-char C-string from a proper C++ string. Use it when you have a C++ string, but you need a C-style pointer-to-char.
It's got nothing at all to do with file names. You might as well ask why programmers store numbers when they could just type in the numbers.
Oh ok. I thought it had something to do with the file name because the person I am learning from [lazy foo] all of a sudden started using .c_str() in place of the file name to upload pictures. Thanks to both. I understand a little more. Thanks!