Was wondering if someone could assist me in elaborating the c_str() function...
I understand that it returns a pointer to an array that contains a null-terminated sequence of character but could someone further elaborate upon this, perhaps with a simple example.
Edited 2 Years Ago by Tycellent
Well, there are many types of strings. In standard C and C++ they are null terminated char arrays, meaning the null char needs to be the last char of the characters stored in the array. These strings can be manipulated by a number of standard functions. std:strings objects are instances of the string class found in the string class found in the string libraray of the Standad C++ library. String objects have a number of member variables, one of which is an array of char. However, the array of char in a std:string need not be null terminated. A number of functions need a null terminated char array as input. You can extract the char array of a std:string and use it as a null terminated char array by calling the c_str() method on a std:string object. For example, using appropriate headers in the program, the following should print Hello to the screen.
string string2 = "Hello";
cout << string1;
i am using visual studio 2015 and trying to export data which i am importing through excel by the user selected Excel file. Now the importing part has been successfully completed i am using OLEDB Connection but Stuck in exporting the same data to a new Excel file. tried ...
I am creating a program that when you print an author, you must show all the information of all the books that the author has written. Add a new attribute in the Author class that will be "BooksWriting: List (Book)".
I have expanded the program so that it also ...
I am currently creating a simulation of a pizza ordering system in object oriented program. I have some question. the instruction and guideline is long but I will try and cut it down a lot. the instruction is to create a program that simulate a pizza restaurant using ...