ofstream help plz
Hi, I need to display the contents of pointer s2 into the file data.txt:
std::ofstream cached ("data.txt");
const char *s2 = r._return.resultElements.__ptr.URL;
printf("\tURL = %s\n", s2?s2:"<NONE>");
Now what? "cached << *s2;" doesnt work...
What do you mean by "doesn't work"? Assuming that s2 is a properly null-terminated string, there should be no problem.
Quote:Original post by Thunder_HawkThe way he has it puts the first character of the string.
What do you mean by "doesn't work"? Assuming that s2 is a properly null-terminated string, there should be no problem.
EDIT: NM, works now! Thx :) I felt kinda stupid... wtf lol.... haven't programmed in a while...
Quote:Original post by xtrmntrYeah, my mistake. [wink]
Wouldn't it put the first character of s2 in the file?
Quote:Original post by HuangdiA \0 char at the end. Any string with double quotes (") will be null-terminated, eg const char * moo = "This is a null-terminated string.";
wait... what do u mean by null terminated?
Quote:Original post by RaQuote:Original post by Thunder_HawkThe way he has it puts the first character of the string.
What do you mean by "doesn't work"? Assuming that s2 is a properly null-terminated string, there should be no problem.
lol...My eyes are starting to get to me. [wink]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement