4 Replies - 9253 Views - Last Post: 10 December 2010 - 06:34 AM

#1 rumbitas   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 98
  • Joined: 07-December 10

Read/Write Visual C++

Posted 10 December 2010 - 01:26 AM

Hi, can someone tell me some tutorial (if possible source code included) where you can learn to make a program to read and write a file in Visual C 2008?

Thanks a lot.
Is This A Good Question/Topic? 0
  • +

Replies To: Read/Write Visual C++

#2 janotte   User is offline

  • code > sword
  • member icon

Reputation: 991
  • View blog
  • Posts: 5,141
  • Joined: 28-September 06

Re: Read/Write Visual C++

Posted 10 December 2010 - 02:10 AM

Read and enjoy
http://www.cprogramm...c/lesson10.html

EDIT
The above is for C (as per the body of your post)

This is for C++ (as per the heading of your post)
http://www.cplusplus...tutorial/files/

You do have to be very clear which language you are asking for help with.
C and C++ are different languages.
You need to be precise and pay careful attention to detail to be a programmer.

This post has been edited by janotte: 10 December 2010 - 02:37 AM

Was This Post Helpful? 1
  • +
  • -

#3 rumbitas   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 98
  • Joined: 07-December 10

Re: Read/Write Visual C++

Posted 10 December 2010 - 05:20 AM

View Postjanotte, on 10 December 2010 - 09:10 AM, said:

Read and enjoy
http://www.cprogramm...c/lesson10.html

EDIT
The above is for C (as per the body of your post)

This is for C++ (as per the heading of your post)
http://www.cplusplus...tutorial/files/

You do have to be very clear which language you are asking for help with.
C and C++ are different languages.
You need to be precise and pay careful attention to detail to be a programmer.



Sorry Janotte, It is for Visual C++ 2008, It's fault of my dark side ^^. Thanks you.

Thanks for the reply, but what I want to know is how to distribute that source code in Visual C++ to do the same but in a window. I want to learn how I can do a GUI for that code. I don't kwow If I explain.
Was This Post Helpful? 0
  • +
  • -

#4 JackOfAllTrades   User is offline

  • Saucy!
  • member icon

Reputation: 6246
  • View blog
  • Posts: 24,014
  • Joined: 23-August 08

Re: Read/Write Visual C++

Posted 10 December 2010 - 05:45 AM

Using .NET? Here's the place to start
Was This Post Helpful? 0
  • +
  • -

#5 rumbitas   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 98
  • Joined: 07-December 10

Re: Read/Write Visual C++

Posted 10 December 2010 - 06:34 AM

I have this code

#pragma endregion
	private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
				Stream^ myStream;
				string completo, parte1, parte2, parte3, parte4;
				OpenFileDialog^ openFileDialog1 = gcnew OpenFileDialog;

				openFileDialog1->InitialDirectory = "c:\\";
				openFileDialog1->Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
				openFileDialog1->FilterIndex = 2;
				openFileDialog1->RestoreDirectory = true;

				if ( openFileDialog1->ShowDialog() == System::Windows::Forms::DialogResult::OK )
				{
					if ( (myStream = openFileDialog1->OpenFile()) != nullptr )
					{
						
					}
				}

			 }
	private: System::Void button2_Click(System::Object^  sender, System::EventArgs^  e) {
				Stream^ myStream;
				SaveFileDialog^ saveFileDialog1 = gcnew SaveFileDialog;
				saveFileDialog1->Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
				saveFileDialog1->FilterIndex = 2;
				saveFileDialog1->RestoreDirectory = true;
				if ( saveFileDialog1->ShowDialog() == ::DialogResult::OK )
				{
					if ( (myStream = saveFileDialog1->OpenFile()) != nullptr )
					{

		            // Code to write the stream goes here.
				    myStream->Close();
				}
      }


In C++, I sent each line to a save function with a string and then, modify the line before saving. But in Visual C++ I'm lost, I don't know how to do that in the above code. Only read a txt file, modify line by line and save line by line.

Thank you for your guidance
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1