User Profile
Collapse
-
Steve Chang replied to I am trying to write a string to a file, but the file contains random codes instead.in CGreat! It works perfectly now. Thanks for your prompt help in this matter. Have a great day! -
Steve Chang started a topic I am trying to write a string to a file, but the file contains random codes instead.in CI am trying to write a string to a file, but the file contains random codes instead.
#include <cstdlib>
#include <iostream>
#include <fstream>
using namespace std;
int main(int argc, char *argv[])
{
ofstream file;
// string a;
string a ("file contents\n\0");
cout<<a<<endl;
file.open("http ://bytes.com/store.txt",ios: :out);
file.write((cha r*)&a,sizeof(a) );
file.flush();...
No activity results to display
Show More
Leave a comment: