FTP Userdatenabfrage kompiliert nicht



  • #include <windows.h>
    #include <wininet.h>
    #include <process.h>
    #include <iostream>
    #include <fstream>
    #include <stdio.h>
    #include <conio.h>
    #include  <wininet.h>
    #pragma comment(lib, "Wininet.lib")
    #pragma comment(lib, "ws2_32")
    #pragma comment(lib, "libwininet.a")
    
    using namespace std;
    
    void upload();
    
    int main()
    {
    char server[50];
    char account[50];
    char passwort[50];
    
    cin.getline(server,50);
    cin>>account;
    cin>>passwort;
            upload();
    
    }
    
    void upload(char *server, char *account, char *passwort)
    {
        HINTERNET hOpen, hConnection;
    
        hOpen = InternetOpen("FTP Upload", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
    
        hConnection = InternetConnect(hOpen, server, INTERNET_DEFAULT_FTP_PORT,
                                         account, passwort, INTERNET_SERVICE_FTP, 0, 0);
    
        FtpPutFile(hConnection, "C:\\upload.txt", "//upload.txt",
                      FTP_TRANSFER_TYPE_ASCII, 0);
    
        InternetCloseHandle(hConnection);
        InternetCloseHandle(hOpen);
    }
    

    Fehlermeldung: undefined reference to `upload()'
    Nutze Code:Blocks als Compiler. Was mache ich falsch?



  • #include <windows.h>
    #include <wininet.h>
    #include <process.h>
    #include <iostream>
    #include <fstream>
    #include <stdio.h>
    #include <conio.h>
    #include  <wininet.h>
    #pragma comment(lib, "Wininet.lib")
    #pragma comment(lib, "ws2_32")
    #pragma comment(lib, "libwininet.a")
    
    using namespace std;
    
    void upload(char *server, char *account, char *passwort);//NUR DAS GEÄNDERT
    
    int main()
    {
    char server[50];
    char account[50];
    char passwort[50];
    
    cin.getline(server,50);
    cin>>account;
    cin>>passwort;
            upload();
    
    }
    
    void upload(char *server, char *account, char *passwort)
    {
        HINTERNET hOpen, hConnection;
    
        hOpen = InternetOpen("FTP Upload", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
    
        hConnection = InternetConnect(hOpen, server, INTERNET_DEFAULT_FTP_PORT,
                                         account, passwort, INTERNET_SERVICE_FTP, 0, 0);
    
        FtpPutFile(hConnection, "C:\\upload.txt", "//upload.txt",
                      FTP_TRANSFER_TYPE_ASCII, 0);
    
        InternetCloseHandle(hConnection);
        InternetCloseHandle(hOpen);
    }
    


  • #include <windows.h>
    #include <wininet.h>
    #include <process.h>
    #include <iostream>
    #include <fstream>
    #include <stdio.h>
    #include <conio.h>
    #include  <wininet.h>
    #pragma comment(lib, "Wininet.lib")
    #pragma comment(lib, "ws2_32")
    #pragma comment(lib, "libwininet.a")
    
    using namespace std;
    
    void upload(char *server, char *account, char *passwort);//NUR DAS GEÄNDERT
    
    int main()
    {
    char server[50];
    char account[50];
    char passwort[50];
    
    cin.getline(server,50);
    cin>>account;
    cin>>passwort;
            upload();
    
    }
    
    void upload(char *server, char *account, char *passwort)
    {
        HINTERNET hOpen, hConnection;
    
        hOpen = InternetOpen("FTP Upload", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
    
        hConnection = InternetConnect(hOpen, server, INTERNET_DEFAULT_FTP_PORT,
                                         account, passwort, INTERNET_SERVICE_FTP, 0, 0);
    
        FtpPutFile(hConnection, "C:\\upload.txt", "//upload.txt",
                      FTP_TRANSFER_TYPE_ASCII, 0);
    
        InternetCloseHandle(hConnection);
        InternetCloseHandle(hOpen);
    }
    

    Habs versucht zu kompilieren, allerdings spuckt der Compiler wieder fehler raus:
    **
    too few arguments to function `void upload(char*, char*, char*)'

    |26|error: at this point in file**
    😕



  • too few arguments to function

    Guck mal im Wörterbuch nach, was few auf deutsch bedeutet, falls du es nicht weißt.



  • Luckie schrieb:

    too few arguments to function

    Guck mal im Wörterbuch nach, was few auf deutsch bedeutet, falls du es nicht weißt.

    Und wieso sagt er das? Bin Neuling und will es kompiliert haben.



  • skullyan schrieb:

    Luckie schrieb:

    too few arguments to function

    Guck mal im Wörterbuch nach, was few auf deutsch bedeutet, falls du es nicht weißt.

    Und wieso sagt er das? Bin Neuling und will es kompiliert haben.

    WEIL DU IN ZEILE 26 TOO FEW ARGUMENTS, NÄHMLICH KEINE, TO DER FUNCTION GEBEN TUHST.



  • volkard schrieb:

    skullyan schrieb:

    Luckie schrieb:

    too few arguments to function

    Guck mal im Wörterbuch nach, was few auf deutsch bedeutet, falls du es nicht weißt.

    Und wieso sagt er das? Bin Neuling und will es kompiliert haben.

    WEIL DU IN ZEILE 26 TOO FEW ARGUMENTS, NÄHMLICH KEINE, TO DER FUNCTION GEBEN TUHST.

    Jo, stimmt. Läuft.



  • #include <windows.h>
    #include <wininet.h>
    #include <process.h>
    #include <iostream>
    #include <fstream>
    #include <stdio.h>
    #include <conio.h>
    #include <wininet.h>
    
    using namespace std;
    
    void upload(char *server, char *account, char *passwort);//NUR DAS GEÄNDERT
    
    int main()
    {
    char server[50];
    char account[50];
    char passwort[50];
    
    cin.getline(server,50);
    cin>>account;
    cin>>passwort;
    upload(server, account, passwort);
    
    }
    
    void upload(char *server, char *account, char *passwort)
    {
        HINTERNET hOpen, hConnection;
    
        hOpen = InternetOpen("FTP Upload", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
    
        hConnection = InternetConnect(hOpen, server, INTERNET_DEFAULT_FTP_PORT,
                                         account, passwort, INTERNET_SERVICE_FTP, 0, 0);
    
        FtpPutFile(hConnection, "C:\\upload.txt", "//upload.txt",
                      FTP_TRANSFER_TYPE_BINARY, 0);
    
        InternetCloseHandle(hConnection);
        InternetCloseHandle(hOpen);
    }
    

    Ich will jetzt noch eine Abfrage zum Quell- und Zielpfad einbauen. Wie mache ich das am elegantesten? Ich habs mit cin.getline(); probiert, ging aber nicht. Vielen Dank.



  • upload(server.c_str(),accunt.c_str(), passwort.c_str());



  • #include <string>
    
    ...
    
    std::string Line; // Hier steht die zeile dann drinn
    std::getline(std::cin,Line);
    
    ...
    

    std:: kannst eigentlich weglassen da du using namespace verwendest.#

    zum konvertieren von string nach char* verwendet man Line.c_str();


Anmelden zum Antworten