FTP in C++ is it possible?

This is a discussion on FTP in C++ is it possible? within the C++ Programming forums, part of the General Programming Boards category; hello, I'm new to C++, and the first program I am trying to write is a basic (and restrictive) FTP ...

  1. #1
    Registered User
    Join Date
    Dec 2006
    Posts
    2

    Question FTP in C++ is it possible?

    hello, I'm new to C++, and the first program I am trying to write is a basic (and restrictive) FTP client called Gsupport. This is what I have done so far...
    Code:
    #include <cstdlib>
    #include <iostream>
    #include <stdlib.h>
    using namespace std;
    
    int main(int argc, char *argv[])
    {
        char name, password, email;
        int true_or_false;
        cout<<"Welcome to Gsupport!\n";
        cout<<"please type in your name\n\n";
        cin>> name;
        cin.ignore();
        cout<<"your name is "<< name << ". OK saving to config file.\n";
        cout<<"what is your email?";
        cin>> email;
        cin.ignore();
        cout<<"thank you. your email address is "<< email << ". This will become your username.\n";
        cout<<"thank you for you patience. What would you like your password to be?";
        cin>> password;
        cin.ignore();
        cout<< "thank you! your user data has been saved to the config file. You have successfully registered... Gsupport is now going to clear this screen (for security reasons) and go to the login page.";
        system("PAUSE");
        //clear screen
        system("cls");
        
        // --------------------------- new screen
        cout<<"Gsupport will now try to  connect to it's server... please wait";
        cout<<"\n";
        // gsupport will now connect to the server with username: other and pass:other
        cout<<"\n";
        // gsupport will then show all files and directories
        //cin.get
        //on enter gsupport will search for the folder/file in the directory and go to it.
        // gsupport will now either loop this process until it finds a downloadable file, or download a file.
        cout<<"downloading file...\n";
        // optional... maybe it should show a percentage... maybe not.
        cout<<"\n";
        cout<<"\n";
        cout<<"your file has been downloaded. Do you want to continue downloading files? (yes = 1,no = 0)";
        cin>> true_or_false;
        cin.ignore();
        cout<<"you entered " << true_or_false << ".\n";
        if (true_or_false == 0) {
                          return 0;
                          }
                          else {
                               cout<<"working on your request...";
                               system("PAUSE");
                               }
        cout<<"working...";
        cout<<"\n";
        cout<<"\n";
        //cin.get;
        // 1 equals go to the start. 0 equals exit.
        system("PAUSE");
        return 0;
    
      
    }
    yes... I know there is still a lot of work to be done, and yes, it probably is really messy... What I would like to know is how I can connect via FTP to... lets say "ftp.gsupport.com" with the username "gsupport" and the password "guest". I am using devC++. I am quite new to programming, so please dont flame me, and use baby steps... because I tend to jump a little far sometimes...

    thanks in advance,
    s0l1dsnak3123

    [edit] I'd also like to know how to use strings like in vb (or the C++ eqivilent)

  2. #2
    l2u
    l2u is offline
    Registered User
    Join Date
    May 2006
    Posts
    630
    You should write something easier for the start.

  3. #3
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,558
    So are you creating a program to drive the system provided FTP program?
    Code:
    > ftp -?
    
    Transfers files to and from a computer running an FTP server service
    (sometimes called a daemon). Ftp can be used interactively.
    
    FTP [-v] [-d] [-i] [-n] [-g] [-s:filename] [-a] [-w:windowsize] [-A] [host]
    
      -v             Suppresses display of remote server responses.
      -n             Suppresses auto-login upon initial connection.
      -i             Turns off interactive prompting during multiple file
                     transfers.
      -d             Enables debugging.
      -g             Disables filename globbing (see GLOB command).
      -s:filename    Specifies a text file containing FTP commands; the
                     commands will automatically run after FTP starts.
      -a             Use any local interface when binding data connection.
      -A             login as anonymous.
      -w:buffersize  Overrides the default transfer buffer size of 4096.
      host           Specifies the host name or IP address of the remote
                     host to connect to.
    
    Notes:
      - mget and mput commands take y/n/q for yes/no/quit.
      - Use Control-C to abort commands.
    > [edit] I'd also like to know how to use strings like in vb (or the C++ eqivilent)
    #include <string>

    Then
    std::string myString = "hello";
    if ( myString == "hello" ) std::cout << "Yay!";
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  4. #4
    Registered User
    Join Date
    Dec 2006
    Posts
    2
    I think thats what I want... so i'd write
    Code:
    FTPhost = ftp.gsupport.com
    ftp-v
    ftp-i
    FTP connect
    or something like that... am i in the right direction?
    please reply,
    snak3
    p.s thanks also for the string code

  5. #5
    Registered User
    Join Date
    Nov 2006
    Posts
    86
    i dont know if their is somthing thats not possible in cpp :P cpp above all.

    *edit* if someone knows somthing thats not possible please tell me lol :P

  6. #6
    Registered User
    Join Date
    Jan 2005
    Location
    Estonia
    Posts
    131
    Quote Originally Posted by epidemic
    i dont know if their is somthing thats not possible in cpp :P cpp above all.

    *edit* if someone knows somthing thats not possible please tell me lol :P
    It's not possible to find something impossible

  7. #7
    The superhaterodyne twomers's Avatar
    Join Date
    Dec 2005
    Location
    Ireland
    Posts
    2,262
    Divide by zero

  8. #8
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,558
    > or something like that... am i in the right direction?
    I think you need to

    a) practice using the FTP program from the command line

    b) practice writing short text files (using notepad) containing your commands, then invoking
    ftp -s:myCommands.txt

    c) then write a program to do the Q/A session to generate a myCommands.txt file from within your C++ program.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to program in unix
    By Cpro in forum Linux Programming
    Replies: 21
    Last Post: 02-12-2008, 09:54 AM
  2. FTP problems...
    By gcn_zelda in forum Tech Board
    Replies: 9
    Last Post: 08-03-2004, 11:05 PM
  3. FTP and Ident Server :: Winsock
    By kuphryn in forum Networking/Device Communication
    Replies: 2
    Last Post: 03-13-2004, 07:16 PM
  4. [C++] FTP client problem (winsock)
    By Niekie in forum Networking/Device Communication
    Replies: 2
    Last Post: 10-19-2003, 09:23 AM
  5. FTP Server :: Winsock
    By kuphryn in forum Windows Programming
    Replies: 2
    Last Post: 10-03-2002, 07:14 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21