Join us at IRC!
Hacking isn't just Computers & Exploits. It's a Philosophy. - Mr_Cheese
Thursday, May 24, 2012
Navigation
Members Online
Total Online: 33
Web Spiders: 15
Guests Online: 31
Members Online: 2

Registered Members: 70189
Newest Member: CrownClown
Latest Articles
View Thread

HellBound Hackers | Events | General

Page 1 of 2 1 2 >
Author

how to create a text file in C++

CyberSpider
Member



Posts: 156
Location: Unknown
Joined: 15.05.07
Rank:
Monster
Posted on 11-07-07 14:03
hi,
i want to create a c++ program to create a text file to be outputted onto the desktop but am not sure what the code is to do that, anyone know?



Author

RE: how to create a text file in C++

Zureck
Member

Posts: 13
Location:
Joined: 07.03.07
Rank:
Newbie
Posted on 11-07-07 14:16
i dont know of the code... but i will look after this post... BUT..to start off with instead of putting it on A desktop put it one everybodys desktop... it is easier.. and quickeer....

C:\docuemnts and settings\allusers\desktop

OR you could use the short crap

C:\DOCU~!\ALL U~!\Desktop\


i WILL have the code in a few monis hold on
Author

RE: how to create a text file in C++

Zureck
Member

Posts: 13
Location:
Joined: 07.03.07
Rank:
Newbie
Posted on 11-07-07 14:17
oh what version of C++...
Author

RE: how to create a text file in C++

Zureck
Member

Posts: 13
Location:
Joined: 07.03.07
Rank:
Newbie
Posted on 11-07-07 14:19
OKAY!

it was ONE simpkle google search ¬_¬..

// text_write.cpp
// compile with: /clr
using namespace System;
using namespace System::IO;

int main()
{
String^ fileName = "textfile.txt";

StreamWriter^ sw = gcnew StreamWriter(fileName);
sw->WriteLine("A text file is born!";);
sw->Write("You can use WriteLine";);
sw->WriteLine("...or just Write";);
sw->WriteLine("and do {0} output too.", "formatted";);
sw->WriteLine("You can also send non-text objects:";);
sw->WriteLine(DateTime::Now);
sw->Close();
Console::WriteLine("a new file ('{0}';) has been written", fileName);

return 0;
}


THATS FOR VISUAL C++
Author

RE: how to create a text file in C++

Zureck
Member

Posts: 13
Location:
Joined: 07.03.07
Rank:
Newbie
Posted on 11-07-07 14:21
// text_write.cpp
// compile with: /clr
using namespace System;
using namespace System::IO;

int main()
{
String^ fileName = "textfile.txt";

StreamWriter^ sw = gcnew StreamWriter(fileName);
sw->WriteLine("A text file is born!");
sw->Write("You can use WriteLine");
sw->WriteLine("...or just Write");
sw->WriteLine("and do {0} output too.", "formatted");
sw->WriteLine("You can also send non-text objects:");
sw->WriteLine(DateTime::Now);
sw->Close();
Console::WriteLine("a new file ('{0}') has been written", fileName);

return 0;
}


SORRY FOR POSTING LOADS I AM ONLY TRY TO HELP
Author

RE: how to create a text file in C++

Zureck
Member

Posts: 13
Location:
Joined: 07.03.07
Rank:
Newbie
Posted on 11-07-07 14:24
How to write to an exsisting tex file....
// basic file operations
#include <iostream>
#include <fstream>
using namespace std;

int main () {
ofstream myfile;
myfile.open ("example.txt");
myfile << "Writing this to a file.\n";
myfile.close();
return 0;
}
Author

RE: how to create a text file in C++

CyberSpider
Member



Posts: 156
Location: Unknown
Joined: 15.05.07
Rank:
Monster
Posted on 11-07-07 14:35
Thanks for the help Zureck :)



Author

RE: how to create a text file in C++

Zureck
Member

Posts: 13
Location:
Joined: 07.03.07
Rank:
Newbie
Posted on 11-07-07 14:38
YAY! he fancies me


Any time Mr spider
Author

RE: how to create a text file in C++

CyberSpider
Member



Posts: 156
Location: Unknown
Joined: 15.05.07
Rank:
Monster
Posted on 11-07-07 14:41
dident work came up with 21 errors lool am using dev c++



Author

RE: how to create a text file in C++

mido
Member

Posts: 613
Location: Cairo, Egypt
Joined: 27.01.07
Rank:
God
Posted on 11-07-07 14:42
cause "i think" the last posts were on VC++



mido_eg3[at]hotmail.com
Author

RE: how to create a text file in C++

mikispag
Member



Posts: 43
Location: Italy
Joined: 14.11.06
Rank:
God
Posted on 11-07-07 14:52
Hi,

if you simply want a code snipped in standard C++ (not tested):

#include <iostream>
#include <fstream>
using namespace std;

int main () {
ofstream MyFile;
MyFile.open ("test.txt");
MyFile << "Writing this to a file.\n";
MyFile.close();
return 0;
}


This link could be very useful: http://www.learn-programming.za.net/programming_cpp_learn09.html



Code is written, future is not


Edited by mikispag on 11-07-07 15:03
http://www.trovatel.net
Author

RE: how to create a text file in C++

CyberSpider
Member



Posts: 156
Location: Unknown
Joined: 15.05.07
Rank:
Monster
Posted on 11-07-07 14:57
returned with error "std::ofstream MyFile' has initializer but incomplete type"



Author

RE: how to create a text file in C++

mido
Member

Posts: 613
Location: Cairo, Egypt
Joined: 27.01.07
Rank:
God
Posted on 11-07-07 14:58
hmmm... heres a summary:
http://www.cplusplus.com/doc/tutorial/files.html



mido_eg3[at]hotmail.com
Author

RE: how to create a text file in C++

CyberSpider
Member



Posts: 156
Location: Unknown
Joined: 15.05.07
Rank:
Monster
Posted on 11-07-07 15:03
Thanks mido ;) done it now :D



Author

RE: how to create a text file in C++

mikispag
Member



Posts: 43
Location: Italy
Joined: 14.11.06
Rank:
God
Posted on 11-07-07 15:04
Updated code. Now it is tested on my Linux box (using g++)! ;)



Code is written, future is not
http://www.trovatel.net
Author

RE: how to create a text file in C++

mido
Member

Posts: 613
Location: Cairo, Egypt
Joined: 27.01.07
Rank:
God
Posted on 11-07-07 16:07
@CyberSpider:
np man, youre welcome :)



mido_eg3[at]hotmail.com
Author

RE: how to create a text file in C++

CyberSpider
Member



Posts: 156
Location: Unknown
Joined: 15.05.07
Rank:
Monster
Posted on 11-07-07 16:18
thanks to mikispag aswell :happy:



Author

RE: how to create a text file in C++

mido
Member

Posts: 613
Location: Cairo, Egypt
Joined: 27.01.07
Rank:
God
Posted on 11-07-07 16:21
So, dude, you may include some GUI (API) to it, to become nicer :)
but this when you get farther in C++



mido_eg3[at]hotmail.com
Author

RE: how to create a text file in C++

CyberSpider
Member



Posts: 156
Location: Unknown
Joined: 15.05.07
Rank:
Monster
Posted on 11-07-07 16:32
yep, be a while yet only just started learning C++ monday :)



Author

RE: how to create a text file in C++

mido
Member

Posts: 613
Location: Cairo, Egypt
Joined: 27.01.07
Rank:
God
Posted on 11-07-07 16:36
Good luck, C++ is interesting :)



mido_eg3[at]hotmail.com
Page 1 of 2 1 2 >
Guest
Username

Password

Remember Me


Bookmark This Page
Affiliates
Adverts

 

 

Links
By using, viewing or obtaining any information contained on this site, you agree to the disclaimer.

© HellBound Hackers 2008- 2009. Since 3rd December 2004.