C++
Hors lignePayppm Le 04/06/2009 à 11:00 Profil de Payppm Configuration de Payppm

Bonjour a tous,
bonjour a toi qui lit ce poste voila je vous explique la situation:

Jesuis actuellment en stage loing de mon ecloe (Avignon/Toulouse) et mon professeur ne me repond pas depuis deja 2 semaines.J'ai deja fait une parti de mon code, ne vous inquitez pas je vai pas vous demander de faire mon travail ;)

Mon problem c'est que j'arrive pas a faire retourné l'adresse enregistrer dans le menu pour effectuer le ping...car le ping prend la valeur du ad_ipA ou ad_ip2 a la place et non pas la valeur enregistrer
Essayez le il tourne pour le moment mais pas comme il devrai ^^'

Le voici le code original:




#include <cstdlib>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>


using namespace std;

int menu(){  // Création du menu.

          printf("\n\n***********\n menu\n***********\n\n\n");   // Création des options du menu.
          printf("1:Entrer l'adresse IP a pinger\n\n");
          printf("2:Entrer Nom DNS a pinger\n\n");
          printf("3:Sortie\n\n\n\n");    // Création de fin du programme.


int choix;
          printf("\n\n Quel est votre choix : \n");
          scanf("%d",&choix);
          return choix;
             }

int main(){   // Initialisation des valeur.

int choix;
choix=menu();
char ad_ip1[20],ad_ip2[20];


while(choix!=3){

if(choix==1){  // Premier choix possible

           printf("veuillez taper l'adresse IP::\n");//Adresse du ping IP
           scanf("%s", &ad_ip1);
           int main();
           system ("ping ""&ad_ip1");

              }
      else if(choix==2)  // Deusieme choix possible
{
           printf("veuillez taper le Nom DSN::\n");
           scanf("%s", &ad_ip2);
           int main();

         system ("ping ""ad_ip2"); //Adresse du ping Dns
}
      else if(choix==3)  // Troisieme choix possible
      {    }


else {
        printf("---------------------------------------------\n***Ce choix n'existe pas***\n Seul les choix 1, 2, 3 et 4 sont disponibles\n---------------------------------------------");
}
      choix=menu();
           }

system("pause");
return 0;
}


Et voila a se a quoi je pensai: (mais sa marche pas    :(  )




#include <cstdlib>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>


using namespace std;

int menu(){  // Création du menu.

          printf("\n\n***********\n menu\n***********\n\n\n");   // Création des options du menu.
          printf("1:Entrer l'adresse IP a pinger\n\n");
          printf("2:Entrer Nom DNS a pinger\n\n");
          printf("3:Sortie\n\n\n\n");    // Création de fin du programme.


int choix;
          printf("\n\n Quel est votre choix : \n");
          scanf("%d",&choix);
          return choix;
             }

int main(){   // Initialisation des valeur.

int choix;
choix=menu();
char ad_ip1[20],ad_ip2[20];
char str[80];

while(choix!=3){

if(choix==1){  // Premier choix possible

           printf("veuillez taper l'adresse IP::\n");//Adresse du ping IP
           scanf("%s", &ad_ip1);
           int main();
           strcpy (str,"ping ");
           strcat (str,"ad_ip1 ");
           system ("ping str");
              }
      else if(choix==2)  // Deusieme choix possible
{
           printf("veuillez taper le Nom DSN::\n");
           scanf("%s", &ad_ip2);
           int main();
          strcpy (str2,"ping ");
           strcat (str2,"ad_ip2 ");
           system ("ping str2"); //Adresse du ping Dns
}
      else if(choix==3)  // Troisieme choix possible
      {  // mettre ici la fonction de sorti de menu  }


else {
        printf("---------------------------------------------\n***Ce choix n'existe pas***\n Seul les choix 1, 2, 3 et 4 sont disponibles\n---------------------------------------------");
}
      choix=menu();
           }

system("pause");
return 0;
}






J'ai besoin d'aide pitier...bhououuuuu!!!!
Hors ligneEndiku Le 04/07/2009 à 01:48 Profil de Endiku Configuration de Endiku

Bonjour,

tu ecris a tort la variable entre guillemets et donc le compilateur ne considere pas la variable mais le nom de la variable:

tu as écris:
strcat (str,"ad_ip1");

mais tu dois ecrire plutot:
strcat (str,ad_ip1);


Endiku
Vous avez résolu votre problème avec VIC ? Faites-le savoir sur les réseaux sociaux !
Vulgarisation-informatique.com
Cours en informatique & tutoriels