Thread: Please can someone help me with this!?

  1. #1
    RobertsQuestion
    Guest

    Please can someone help me with this!?

    All I need is a small piece of code that sends a file called "C:/Windows/Temp/sample.txt" to the same location but to my computer (maybe just cin (input) the IP address in the executable). Can anyone help me please! The file does not have to be "C:/Windows/Temp/sample.txt", maybe also just the sample.txt file in the folder that the .exe file is. My main question is how do you transfer files from one computer to another or to an e-mail. If anyone is kind enough to write a piece of code for this...could you please send it to [email protected].
    I know this is real advanced C++ programming, but there might be a person who can do it :-)

  2. #2
    RobertsQuestion
    Guest
    All i got so far:

    Code:
    #include <iostream>
    #include <fstream>
    #include <string>
    014using namespace std;
    
    void main()
    {
       ofstream file;
       string filename = "sample.txt";
       file.open(filename.data());
       file << "Hello World!";
       // This is the part where we send it to my PC
    }
    Please, oh PLEASE help me someone!

  3. #3
    RobertsQuestion
    Guest
    All i got so far:

    Code:
    #include <iostream>
    #include <fstream>
    #include <string>
    using namespace std;
    
    void main()
    {
       ofstream file;
       string filename = "sample.txt";
       file.open(filename.data());
       file << "Hello World!";
       // This is the part where we send it to my PC
    }
    Please, oh PLEASE help me someone!

  4. #4
    Open to suggestions Brighteyes's Avatar
    Join Date
    Mar 2003
    Posts
    204
    >My main question is how do you transfer files from one computer to another or to an e-mail.
    What you're talking about is working with sockets. To get started with this not so simple aspect of programming, go here.

    >If anyone is kind enough to write a piece of code for this...
    Not likely, this isn't a trivial program for many people.

    >I know this is real advanced C++ programming, but there might be a person who can do it :-)
    There are plenty who can do it, but here we help you with your problems, we don't do all of the work for you.
    p.s. What the alphabet would look like without q and r.

  5. #5
    RobertsQuestion
    Guest
    But could you please help me!? I need at least a start!

  6. #6
    Open to suggestions Brighteyes's Avatar
    Join Date
    Mar 2003
    Posts
    204
    I've already helped you and given you a start, read the page I linked you to.
    p.s. What the alphabet would look like without q and r.

  7. #7
    RobertsQuestion
    Guest
    OK, thanks a lot...I'll try to get this into working code now

  8. #8
    RobertsQuestion
    Guest
    Man, I get nothing of this socket stuff...could i, uhh, have some more help please?

  9. #9
    Registered User
    Join Date
    May 2003
    Posts
    3
    i am not totally sure if I understand what your asking but if your asking what i think you are then u need to add a code to open up the output file then when doin the cout<< after just do NameoffileOut<< and that will output it to the file. and when finished make sure to close both files example here:
    not sure if this helps but I think this may be what you were asking about
    --------------------------------------------------------------------------------
    #include <iostream>
    #include <fstream>
    #include <string>
    using namespace std;

    void main()
    {
    ofstream file;
    string filename = "sample.txt";
    name_of_filein.open(filename.data());
    name_of_fileout.open(filename.data())
    name_of_filein>>"hello world \n";
    name_of_fileout<<"Hello world \n";
    cout<<"hello world \n";
    name_of_filein.close(filename.data());
    name_of_fileout.close;
    system("PAUSE");
    clrscr();
    }

  10. #10
    RobertsQuestion
    Guest
    Thank You vVv, now this is a lot easier to understand

  11. #11
    RobertsQuestion
    Guest
    I still did not manage to transfer any data to an e-mail or to another PC!

  12. #12
    RobertsQuestion
    Guest
    Thanks for you help vVv :-D I really appreciated it

Popular pages Recent additions subscribe to a feed