c++ logging help

Microsoft Windows xp professional w/serv...
July 23, 2010 at 00:55:57
Specs: Windows XP
im not sure if this is the place to ask but ill give it a shot here is my code:
#include <iostream.h>
#include <fstream.h>
#include <iomanip.h>

using namespace std;

int main(){
string log;
int date;

cout<< "enter the date of defrag EX:(MM/YY/YY)\n";
cin>>date;
log+=date;

ofstream myfile;
myfile.open ("justin's log.txt");
myfile <<log;
myfile.close();
system ("pause");
}

now i am making a c++ program and all it does is records the info given and stores it in a .txt file but when i look into the .txt file that my program made its all
hexed out or somthing. it looks like this ΓΏ
now im confused because i use log+="blahblah"; it shows up in the .txt and its all fine.
wats my error that i cant see?
oh and thanks in adv. =)


See More: c++ logging help

Report •

#1
July 23, 2010 at 06:00:32
i use log+="blahblah"; it shows up in the .txt and its all fine.
That's because there is a big difference between 5 and '5'. The former has the value of well, 5. The latter has a value of 53.

If you're not going to modify the date, then there's no reason to convert it to an int. Just make date a string.


Report •

#2
July 23, 2010 at 10:23:55
oh makes sense

Report •
Related Solutions


Ask Question