Mit C ein Txt-Dokument auf einen FTP-Server uploaden
-
Na, wenn dein Compiler den Code so durchgehen lässt, dann ist der ka-budd!
Da muss doch wenigstens main stehen, irgendwo...oder wusstest du das nicht?
Gru-huß,
b.b.
-
Compiler: Default compiler Building Makefile: "C:\Users\Robin\Pictures\Desktop\Medien\C . C++\Makefile.win" Führt make... aus make.exe -f "C:\Users\Robin\Pictures\Desktop\Medien\C . C++\Makefile.win" all make.exe: Nothing to be done for `all'. Ausführung beendet Kompilierung erfolgreich
grüße.
-
ja, nagut, mit nem c++ compiler mag das gehen. ich sehe aber in deinem code nirgends funktionsaufrufe, hast du die auch aufgerufen?
-
Ich dachte das habe ich gemacht?
Bzw. wir muss ich sie den aufrufen?
Sorry, bin noch nicht solange mit C
zugange.Grüße.
-
Hallo
Naja, schau dir lieber nochmal die Grundlagen an... Du deklarierst ne Funktion:
void HansJuergen(const char *Status) { std::cout<< Status; };
Und rufst sie, nach der Deklaration auf:
HansJuergen("Noob");
Wird dir aber nicht viel weiter helfen, weil du die Grundlagen nicht drauf hast.
way
-
Hallo alle zusammen.
Ich versuche das ganze nochmal klar darzustellen.
Ich bin nicht gut in C, da ich ansonsten auch nicht damit arbeite.Muss jetzt aber ein Programm in C schreiben und bin an einem
Problem hängen geblieben. Das Problem ist:Das ich gerne hätte, das ein Prozess eine TxT Datei im Hintergrund
(ohne sichtbarem Dos-Fenster o.ä.) auf meinen FTP-Server lädt.Dazu habe ich folgende Source geschrieben. Ich weiß nicht genau,
was ihr meint mit Funktion ausführen. Könnte mir bitte jemand,
einen Code so schreiben, das es klappt bzw. sagen, was ich veränden
muss, damit es klappt?Code:
char *host={"ftp.r0biin93.r0.funpic.de"}; printf("Schritt 1 - Geklappt"); char *user={"r0biin93"}; char *password={"12345678"}; char *inputfile={"C:/Users/Robin/Pictures/Desktop/Medien/g5ed2sd2d.txt"}; char *path={"g5ed2sd2d.txt"}; netbuf **nControl; ftp FtpConnect int FtpConnect(const char *host, netbuf **nControl); int FtpLogin(const char *user, const char *password, netbuf *nControl); int FtpPut(const char *inputfile, const char *path, char mode, netbuf *nControl); void FtpQuit(netbuf *nControl);
Grüße,
Hans Jürgen!
-
Hallo
Wie ich bereits gesagt habe , musst du die Funktionen aufrufen. Wie das geht, habe ich dir schon in Form von Code gezeigt.
way
-
Du meinst dann vom Prinzip her so:
char *host={"ftp.r0biin93.r0.funpic.de"}; printf("Schritt 1 - Geklappt"); char *user={"***********"}; char *password={"**********"}; char *inputfile={"C:/Users/Robin/Pictures/Desktop/Medien/g5ed2sd2d.txt"}; char *path={"g5ed2sd2d.txt"}; netbuf **nControl; int FtpConnect(const char *host, netbuf **nControl); int FtpLogin(const char *user, const char *password, netbuf *nControl); int FtpPut(const char *inputfile, const char *path, char mode, netbuf *nControl); void FtpQuit(netbuf *nControl); FtpConnect; FtpLogin; FtpPut; FtpQuit;
oder ??
Grüße.
-
Hallo
Nicht ganz. So würden man einfache Datentyp-Deklarationen (normale Variablen) aufrufen. Funktionen ruft man immer mit den Klammern auf. Du hast jetzt sogar noch Parameter, die definiert werden müssen. Parameter sind die Variablen zwischen den "()" Klammern.
Ich bin mal so gnädig und schreibe dir den richtigen Code:
char *host={"ftp.r0biin93.r0.funpic.de"}; char *user={"***********"}; char *password={"**********"}; char *inputfile={"C:/Users/Robin/Pictures/Desktop/Medien/g5ed2sd2d.txt"}; char *path={"g5ed2sd2d.txt"}; netbuf **nControl; int FtpConnect(const char *host, netbuf **nControl); int FtpLogin(const char *user, const char *password, netbuf *nControl); int FtpPut(const char *inputfile, const char *path, char mode, netbuf *nControl); void FtpQuit(netbuf *nControl); FtpConnect(host, nControl); FtpLogin(user, password, nControl); FtpPut(inputFile, path, //Hier musst du schauen welche Modi es in der lib gibt); FtpQuit(nControl);
Falls du das in C++ machen möchtest oder portierst, ist es sinnvoll es in der OOP, sprich mit Klassen (übersichtlicher, strukturierter) zu machen.
way
-
Hallo,
Vielen Dank erst mal, das du mir so ausdauernd
hilfst. Und mir den Code so vorgeschrieben hast.Habe das jetzt so ergänzt:
char *host={"ftp.r0biin93.r0.funpic.de"}; char *user={"*****"}; char *password={"*****"}; char *inputfile={"C:/Users/Robin/Pictures/Desktop/Medien/g5ed2sd2d.txt"}; char *path={"g5ed2sd2d.txt"}; netbuf **nControl; char mode=FTPLIB_ASCII; int FtpConnect(const char *host, netbuf **nControl); int FtpLogin(const char *user, const char *password, netbuf *nControl); int FtpPut(const char *inputfile, const char *path, char mode, netbuf *nControl); void FtpQuit(netbuf *nControl); FtpConnect(host, nControl); FtpLogin(user, password, *nControl); FtpPut(inputfile, path, FTPLIB_ASCII, *nControl); FtpQuit(*nControl);
Aber, trotzdem kommt folgender Fehler, weiß aber nicht genau, was er meint.
Wenn du mir sagen könntest welcher Verwies gemeint ist, vielleicht "*nControl"?, wäre das sehr freundlich.char *host={"ftp.r0biin93.r0.funpic.de"};
char *user={"r0biin93"};
char *password={"robin1993"};
char *inputfile={"C:/Users/Robin/Pictures/Desktop/Medien/g5ed2sd2d.txt"};
char *path={"g5ed2sd2d.txt"};
netbuf **nControl;
char mode=FTPLIB_ASCII;int FtpConnect(const char *host, netbuf **nControl);
int FtpLogin(const char *user, const char *password, netbuf *nControl);
int FtpPut(const char *inputfile, const char *path, char mode,
netbuf *nControl);
void FtpQuit(netbuf *nControl);FtpConnect(host, nControl); FtpLogin(user, password, *nControl); FtpPut(inputfile, path, FTPLIB_ASCII, *nControl); FtpQuit(*nControl);
Grüße.
-
Hoppala,
doch glatt das falsche reinkopiert,
schau nochmal hier das ist der Fehler
vom Compiler:Upload2.o(.text+0x5f):Upload2.c: undefined reference to `FtpConnect' Upload2.o(.text+0x7a):Upload2.c: undefined reference to `FtpLogin' Upload2.o(.text+0x9d):Upload2.c: undefined reference to `FtpPut' Upload2.o(.text+0xaa):Upload2.c: undefined reference to `FtpQuit'
Grüße.
-
Hallo
Wenn das der komplette code ist, ist es klar, da Funktion nicht lokal deklariert und aufgerufen werden können.
Aber moment mal, da ist ja ein Zeiger auf nen Zeiger.
So müsste es gehen:
char *host={"ftp.r0biin93.r0.funpic.de"}; char *user={"*****"}; char *password={"*****"}; char *inputfile={"C:/Users/Robin/Pictures/Desktop/Medien/g5ed2sd2d.txt"}; char *path={"g5ed2sd2d.txt"}; netbuf **nControl; char mode=FTPLIB_ASCII; int FtpConnect(const char *host, netbuf **nControl); int FtpLogin(const char *user, const char *password, netbuf *nControl); int FtpPut(const char *inputfile, const char *path, char mode, netbuf *nControl); void FtpQuit(netbuf *nControl); FtpConnect(host, *nControl); FtpLogin(user, password, nControl); FtpPut(inputfile, path, FTPLIB_ASCII, nControl); FtpQuit(nControl);
Das ist ja nicht der gesamte Code, ne?
way
-
Der gesamte Code ist dieser:
#include <stdio.h> #include <stdlib.h> #include <ftplib.h> int main(int argc, char *argv[]) { //Selbst geschrieben ab hier! char *host={"ftp.r0biin93.r0.funpic.de"}; char *user={"*****"}; char *password={"*****"}; char *inputfile={"C:/Users/Robin/Pictures/Desktop/Medien/g5ed2sd2d.txt"}; char *path={"g5ed2sd2d.txt"}; netbuf **nControl; char mode=FTPLIB_ASCII; int FtpConnect(const char *host, netbuf **nControl); int FtpLogin(const char *user, const char *password, netbuf *nControl); int FtpPut(const char *inputfile, const char *path, char mode, netbuf *nControl); void FtpQuit(netbuf *nControl); FtpConnect(host, nControl); FtpLogin(user, password, nControl); FtpPut(inputfile, path, FTPLIB_ASCII, nControl); FtpQuit(nControl); system("PAUSE"); return 0; }
-
Habe es jetzt nocheinmal versucht,
und wieder folgende Fehlermeldung erhalten:[code]
Upload2.o(.text+0x5f):Upload2.c: undefined reference toFtpConnect' Upload2.o(.text+0x7a):Upload2.c: undefined reference to
FtpLogin'
Upload2.o(.text+0x9d):Upload2.c: undefined reference toFtpPut' Upload2.o(.text+0xaa):Upload2.c: undefined reference to
FtpQuit'Woran könnte es den noch liegen? Grüße. [Diesen Code hab ich verwendet: [cpp] #include <stdio.h> #include <stdlib.h> #include <ftplib.h> int main(int argc, char *argv[]) { //Selbst geschrieben ab hier! char *host={"ftp.r0biin93.r0.funpic.de"}; char *user={"*****"}; char *password={"*****"}; char *inputfile={"C:/Users/Robin/Pictures/Desktop/Medien/g5ed2sd2d.txt"}; char *path={"g5ed2sd2d.txt"}; netbuf **nControl; char mode=FTPLIB_ASCII; int FtpConnect(const char *host, netbuf **nControl); int FtpLogin(const char *user, const char *password, netbuf *nControl); int FtpPut(const char *inputfile, const char *path, char mode, netbuf *nControl); void FtpQuit(netbuf *nControl); FtpConnect(host, nControl); FtpLogin(user, password, *nControl); FtpPut(inputfile, path, mode, *nControl); FtpQuit(*nControl); system("PAUSE"); return 0; }
-
Hallo
#include <stdio.h> #include <stdlib.h> #include <ftplib.h> int FtpConnect(const char *host, netbuf **nControl); int FtpLogin(const char *user, const char *password, netbuf *nControl); int FtpPut(const char *inputfile, const char *path, char mode, netbuf *nControl); void FtpQuit(netbuf *nControl); int main(int argc, char *argv[]) { char *host={"ftp.r0biin93.r0.funpic.de"}; char *user={"*****"}; char *password={"*****"}; char *inputfile={"C:/Users/Robin/Pictures/Desktop/Medien/g5ed2sd2d.txt"}; char *path={"g5ed2sd2d.txt"}; netbuf **nControl; char mode=FTPLIB_ASCII; FtpConnect(host, nControl); FtpLogin(user, password, *nControl); FtpPut(inputfile, path, mode, *nControl); FtpQuit(*nControl); std::cin.get(); }
way
-
Hallo
Und?
way
-
Hallo.
Wenn ich den Code jetzt so einfüge,
sagt er das in Zeile 26 ( std::cin.get();)
ein syntax-Fehler vor dem : ist.Ich programmiere in C.
Ich habe die Vermutung, das dies ein Befehl
aus c++ ist?Grüße.
-
Hallo
Ja, dann mach ein "return 0;" draus (;.
way
-
Wenn ich ein return 0; draus mache,
kommt folgender Fehler :Upload2.o(.text+0x5f):Upload2.c: undefined reference to `FtpConnect' Upload2.o(.text+0x7a):Upload2.c: undefined reference to `FtpLogin' Upload2.o(.text+0x9d):Upload2.c: undefined reference to `FtpPut' Upload2.o(.text+0xaa):Upload2.c: undefined reference to `FtpQuit'
Grüße.
-
Hallo
Hä?
#include <stdio.h> #include <stdlib.h> #include <ftplib.h> int FtpConnect(const char *host, netbuf **nControl); int FtpLogin(const char *user, const char *password, netbuf *nControl); int FtpPut(const char *inputfile, const char *path, char mode, netbuf *nControl); void FtpQuit(netbuf *nControl); int main(void) { char *host={"ftp.r0biin93.r0.funpic.de"}; char *user={"*****"}; char *password={"*****"}; char *inputfile={"C:/Users/Robin/Pictures/Desktop/Medien/g5ed2sd2d.txt"}; char *path={"g5ed2sd2d.txt"}; netbuf **nControl; char mode=FTPLIB_ASCII; FtpConnect(host, nControl); FtpLogin(user, password, *nControl); FtpPut(inputfile, path, mode, *nControl); FtpQuit(*nControl); return 0; }
way