How can i save an array to a file? Thanks guys ;) :D
Printable View
How can i save an array to a file? Thanks guys ;) :D
try this:
Code:char** MyArray = {"Hi there", "And again", "Different"};
ofstream MyFile("c:\myfile.txt");
for(int i = 0; i < 3; i++) {
MyFile << MyArray << endl;
}
sorry Im pretty new to C++ but what does char** do?
Sorry...well, a pointer to char is char*, which means that:
me now points to the first character, and (*me), when dereferenced, is equal to 'H'. If you add another *, then you are taking a pointer to a pointer to char, basically getting a multidimensional array.Code:char* me = "Hello";
so Char** me = "Hello" would get "He"?
sorry I just wanted to make sure it wasn't math...
No. char** me would give an error...
Do you get the picture? Likewise:Code:char* it = "It's string";
char* that = "Another string";
char** both = {it, that};
then I can do:Code:char* it = "It's string";
char* that = "Another string";
char** both = {it, that};
char** opp = {that, it};
char*** all = {both, opp};
to print "It's string"Code:cout << all[0][0][0] << endl;