magus54
Messages postés
41
Date d'inscription
mardi 4 janvier 2005
Statut
Membre
Dernière intervention
29 avril 2006
26 janv. 2005 à 21:38
Bon, j'ai lu ton truc. Je pense qu'il y a plein de problèmes !! Voici la source modifiée (j'ai mis en gras les modifs), elle se compile sans soucis sous dev.
#include <windows.h>
#include <stdio.h>
#include <winsock2.h>
#include <ws2tcpip.h>
#include <WinINet.h>
#define MAIN_LEN 100
using namespace std;
main()
{
char *Buffer = (char *) calloc(sizeof (char), MAIN_LEN+1);
char NameServeurFtp[MAIN_LEN+1]="199.100.100.4";
char LoginFtp[MAIN_LEN+1]="FTPLOG";
char PwdFtp[MAIN_LEN+1]="FTPLOG";
bool ResultFtp;
char DirToRecupFile[MAIN_LEN+1]="";
char szLine[500];
char szFind[500];
char filename[260];
char caract,adresse;
char fullpath[260];
char caractere;
char fullpath1[260];
char fullpath2[260];
int i,j,longueur_txt_2,longueur_txt_1,RepRecherche;
char texte_1 [500];
char texte_2 [500];
char echange;
HINTERNET hinetopen, hinetconnect, hftpfirst;
WIN32_FIND_DATA struct_dir;
HKEY RegLogin, RegPass, RegServer;
DWORD Disposition, DispositionPass, DispositionServer;
DWORD Ltype;
char RLogin[100], RPasswd[100], RFtpServer[100];
LPTSTR lpRLogin = "01/01/01";
LPTSTR lpRPasswd = "01/01/01";
LPTSTR lpRFtpServer = "200.050.050.9";
/* Les handles */
HINTERNET hInternetSession; /* handle to internet connection */
HINTERNET hFTPSession;
hInternetSession = InternetOpen ( NULL,INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
if ( hInternetSession == NULL )
{
/* Erreur dans l'ouverture de la connexion */
exit (1);
}
/* Connexion au serveur FTP */
hFTPSession = InternetConnect ( hInternetSession, NameServeurFtp, INTERNET_DEFAULT_FTP_PORT, LoginFtp, PwdFtp, INTERNET_SERVICE_FTP, 0, 0);
if ( !hFTPSession )
{
exit(1);
}else{
debut_boucle2 :
system("cls");
printf(" ***************************************************************\n");
printf(" * *\n");
printf(" * MOTEUR DE RECHERCHE D'INFORMATIONS DIVERS DANS LES ARCHIVES *\n");
printf(" * *\n");
printf(" ***************************************************************\n\n");
printf ("saisie le jour demander (exemple 01/02/02 = 010202) ou CTRL+C pour sortir : \n");
gets (texte_1);
strcpy(texte_2,texte_1);
longueur_txt_2 = strlen (texte_2);
j = longueur_txt_2 - 1;
longueur_txt_1 = strlen(texte_1);
for(i=0; i<longueur_txt_1; i+=2)
{
if(i+1<longueur_txt_1)
{
texte_2[i] = texte_1[longueur_txt_1-i-2];
texte_2[i+1] = texte_1[longueur_txt_1-i-1];
}else{
texte_2[i] = texte_1[longueur_txt_1-i-1];
}
texte_2[longueur_txt_1] = '\0';
}
strcpy(fullpath2, ".log");
strcat(texte_2,fullpath2);
strcpy(fullpath, "date");
strcat(fullpath,texte_2);
system("cls");
FILE * lecture;
LPCSTR DirFile;
debut_boucle :
lecture = fopen(fullpath, "r");
ResultFtp = FtpGetFile ( hFTPSession, DirFile, DirToRecupFile, NULL, NULL,FTP_TRANSFER_TYPE_ASCII, NULL);
if ( ResultFtp )
{
putchar(caract);
}else{
printf( "Erreur de date!!!!","Erreur");
}
printf("\n\nApuyez sur retour.");
fflush(stdin); scanf("%c",&caract);
}
}
Pour le compiler, tu fais
1 =>Nouvo projet=>App console
2=>tu colles le code dans la main.cpp
3=>Tu ajoutes les libs (projet->options->param->Ajouter lib)
Dev-Cpp/lib/libwsock32.a
Dev-Cpp/lib/libwininet.a
4=>F9
Moi j'ai pas de problème de compilation (a part quelques warnings à cause des NULL), mais le programme ne fais rien !! (il est censé faire quoi à la base)
Programming4ever