Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

writing a fail (CFile ) and setting a variable ?

Status
Not open for further replies.

crach

ISP
May 12, 2002
9
0
0
EE
Hello,
I have two problems, firt i'd like to know how to change the line when im writing into a fail, \n seems not to work (maybe im doing something wrong!).
The second problem is that,how can i make that work when the program writes a text into fail test.txt,after that a messagebox will be opened,and i want it with this text want the program did write to the fail test.txt, i know that i have to make some variables, but how?

here's my code:


void CTextDlg::OnCreateTxt()
{
CFile mFail;
mFail.Open("c:\\test.txt",CFile::modeWrite|CFile::modeCreate|CFile::shareDenyNone);

static const char write_text[] = "here is a example text\n"
"this would be the second line";



mFail.Write(write_text, lstrlen(write_text));


int message;
message = MessageBox("here would be the text what the program did just wrote to the fail test.txt", "Info", MB_OK);

mFail.Close();
}


thanx if somebody can help me:) Silver
crach@jutukas.com
 
I dont see what the problem is. ON you C drive there should be the file you created with the appropriate text inside. Is it not being created? I am not sure if i completely understand what the problem is.

Matt
 
The file is being created, but the text is in 1 line, but i want that in 2line,it should be inside the fail test.txt like this:

here is a example text
this would be the second line


but it is in 1 line like this:

here is a example text this would be the second line

Silver
crach@jutukas.com
 
yep... thats it... i bet if you open the file in MS Word or wordpad it will look fine... in notepad you should see a black rectangle (i think)

Matt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top