Follow us on Twitter!
Your life is ending one minute at a time. If you were to die tomorrow, what would you do today?
Thursday, April 24, 2014
Navigation
Home
HellBoundHackers Main:
HellBoundHackers Find:
HellBoundHackers Information:
Learn
Communicate
Submit
Shop
Challenges
HellBoundHackers Exploit:
HellBoundHackers Programming:
HellBoundHackers Think:
HellBoundHackers Track:
HellBoundHackers Patch:
HellBoundHackers Other:
HellBoundHackers Need Help?
Other
Members Online
Total Online: 20
Guests Online: 19
Members Online: 1

Registered Members: 82889
Newest Member: Geriztul
Latest Articles
View Thread

HellBound Hackers | Events | General

Page 1 of 2 1 2 >
Author

how to create a text file in C++


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
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++


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
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++


Member

Your avatar

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

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


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
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!"Wink;
sw->Write("You can use WriteLine"Wink;
sw->WriteLine("...or just Write"Wink;
sw->WriteLine("and do {0} output too.", "formatted"Wink;
sw->WriteLine("You can also send non-text objects:"Wink;
sw->WriteLine(DateTime::Now);
sw->Close();
Console::WriteLine("a new file ('{0}'Wink has been written", fileName);

return 0;
}


THATS FOR VISUAL C++
Author

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


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 11-07-07 14:21
Code
// 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++


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 11-07-07 14:24
How to write to an exsisting tex file....
Code
// 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++


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 11-07-07 14:35
Thanks for the help Zureck Smile


Author

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


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
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++


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
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

Your avatar

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


www.hellboundhackers.org/sig/r/16019.png

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:
Newbie
Posted on 11-07-07 14:52
Hi,

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

Code
#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


www.trovatel.net/img/userbar.gif
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++


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 11-07-07 14:57
returned with error "std:Shockfstream MyFile' has initializer but incomplete type"


Author

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

mido
Member

Your avatar

Posts: 613
Location: Cairo, Egypt
Joined: 27.01.07
Rank:
Monster
Posted on 11-07-07 14:58
hmmm... heres a summary:
http://www.cplusp. . .files.html


www.hellboundhackers.org/sig/r/16019.png

mido_eg3[at]hotmail.com
Author

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


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 11-07-07 15:03
Thanks mido Wink done it now Grin


Author

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

mikispag
Member



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


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

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

mido
Member

Your avatar

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


www.hellboundhackers.org/sig/r/16019.png

mido_eg3[at]hotmail.com
Author

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


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 11-07-07 16:18
thanks to mikispag aswell :happy:


Author

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

mido
Member

Your avatar

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


www.hellboundhackers.org/sig/r/16019.png

mido_eg3[at]hotmail.com
Author

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


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 11-07-07 16:32
yep, be a while yet only just started learning C++ monday Smile


Author

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

mido
Member

Your avatar

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


www.hellboundhackers.org/sig/r/16019.png

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