|
-
Aug 22nd, 2000, 12:53 AM
#1
Thread Starter
Frenzied Member
How can i save an array to a file? Thanks guys
-
Aug 22nd, 2000, 01:42 PM
#2
Monday Morning Lunatic
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;
}
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Aug 22nd, 2000, 05:01 PM
#3
Thread Starter
Frenzied Member
sorry Im pretty new to C++ but what does char** do?
-
Aug 22nd, 2000, 05:08 PM
#4
Monday Morning Lunatic
Sorry...well, a pointer to char is char*, which means that:
Code:
char* me = "Hello";
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.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Aug 22nd, 2000, 05:14 PM
#5
Thread Starter
Frenzied Member
so Char** me = "Hello" would get "He"?
sorry I just wanted to make sure it wasn't math...
-
Aug 22nd, 2000, 05:24 PM
#6
Monday Morning Lunatic
No. char** me would give an error...
Code:
char* it = "It's string";
char* that = "Another string";
char** both = {it, that};
Do you get the picture? Likewise:
Code:
char* it = "It's string";
char* that = "Another string";
char** both = {it, that};
char** opp = {that, it};
char*** all = {both, opp};
then I can do:
Code:
cout << all[0][0][0] << endl;
to print "It's string"
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|