Langagec

Bonjour,
svp j ai un pb avec l'execution de mon tp en langage c pouvez vous m aidez?
Configuration: Windows 2000
Firefox 2.0.0.14

9 réponses

  • Votes
  • Date
  • Date décroissante
  1. je veux bien t'aider mais je e sais comment programmer on m'a dit mais je ne comprends pas ils m'ont dit de telecharger PSPAD c'est un logiciel de programmtion mais je ne sais pas l'utiliser
    1. en fait j ecris un programme qui permet de decoder une chaine de bit entrée poar un utilisateur .voici le code mais un message d'erreur s 'affiche je ne sais prkoi
      #include<stdio.h>
      #include<string.h>
      #include<conio.h>
      #include<math.h>
      //FONCTION DE VERIFICATION DE TAILLE D UNE CHAINE
      //il retourne 1 si la taille est egale a celle du type sinon 0
      int verif ( char*s,int l)
      {
      if (l==(strlen(s)-1))
      return 1;
      else
      return 0;
      }

      //FONCTION DE VERIFICATION DE LA TAILLE POUR LES TYPES CHAINE DE CARACTERE
      int verif_char( char *s)
      {if (((strlen(s)-1)%8)==0)
      return 1;
      else
      return 0;
      }
      //FONCTION QUI PERMET D'EXTRAIRE UNE CHAINE DE CARACTERE
      char *extract ( char*s,int deb,int fin){
      char *ch=NULL;
      int i;
      if ((s!=NULL)&&(deb<fin)){
      ch=malloc(sizeof(*ch)*(fin-deb+2));
      if (ch!=NULL)
      {for(i=deb;i<=fin;i++)
      {ch[i-deb]=s[i];
      }
      ch[i-deb]='\0';
      }
      else
      printf("erreur");

      return(ch);
      }
      }
      //FONCTION QUI DECODE UN ENTIER
      int decode_int(char*s){
      int val=0,i,l=strlen(s);
      i=l-1;
      while(i>=0){
      if (s[i]==1)
      {val=val+pow(2,i-l+1);
      i++;}
      i++;
      }
      }
      //FONCTION QUI DECODE UNE CHAINE EN ENTIER DECIMAL NON SIGNE
      int decode_uns(char *s)
      { int i,val,l=strlen(s);
      char c;
      for(i=l-1;i>=0;i++)
      { if (s[i]!=0)
      val=val+pow(2,i-l+1);
      }
      }
      //FONCTION QUI DECODE UNE CHAINE EN ENTIER DECIMAL SIGNE CPLMENT A 2
      char *decode_cpl2 (char *s){
      int j,i,l=strlen(s),val=0;
      char *c,*c1;
      c=(char*)malloc(sizeof(char));
      c1=(char*)malloc(sizeof(char));
      while(s!=NULL){
      if (s[0]==1){
      c="-";
      val= decode_uns(s);
      strcat(c,"val");
      }
      { c="+";
      i=l-1;
      while((i>0)&&(s[i]==0)){i++;}
      val+=pow(2,i-l+1);
      for(j=i-1;j>0;j++){
      if(s[i]==0)
      val+=pow(2,i-l+1);
      }
      strcat(c,"val");
      }
      }
      return(c);
      }
      //FONCTION QUI DECODE UNE CHAINE E ENTIER DECIMAL SIGNE CPLMENT 1

      char *decode_cpl1(char*s){
      int i,val=0,l=strlen(s);
      char*c;
      c=(char*)malloc(sizeof(char));
      if (s[0]==1)
      { c="+";
      i=l-1;
      while(i>0){
      if(s[i]==0)
      {
      val+=pow(2,i-l+1);
      }
      i++;
      }
      strcat(c,"val");
      }
      {
      c="-";
      strcat(c,"val");
      }
      return(c);
      }
      //FONCTION QUI DECODE UNE CHAINE EN REEL
      char *decode_real1(char*s){
      char*c1,*c2,*c3;
      c1=(char*)malloc(sizeof(char));
      c2=(char*)malloc(sizeof(char));
      c3=(char*)malloc(sizeof(char));
      int l=strlen(s),i=0,j,k,e,m;
      if (s[i]==0){
      c1="+";
      }
      c1="-";
      j=2;k=9;
      c2=extract(s,j,k);
      e=decode_int(c2);
      strcat(c1,c2);
      if (s[10]==0)
      {c3="+";}c3="-";
      strcat(c1,c3);
      for(i=11;i<=32;i++){
      m+=pow(2,-i-1);}
      strcat(c1,"m");
      return(c1);
      }
      //FONCTION QUI DECODE UNE CHAINE EN CARACTERE
      char decode_char(char*s) {
      int n,val;
      char c;
      val=decode_int(s);
      c=val;
      return(val);
      }
      //FONCTION QUI DECODE UNE CHAINE EN CHAINE DE CARATERE
      char *decode_chaine(char *s){
      int i=0,j=7,val,l=strlen(s);
      char*c1,c2,c3,*c4;
      c4=(char*)malloc(sizeof(char));
      c1=extract(s,i,j);
      c2=decode_char(c1);
      c4="c2";
      while ((i<j)&&(j<l))
      { i+=8;
      j+=8;
      c1=extract(s,i,j);
      c3=decode_char(s);
      strcat(c4,"c3");
      }
      return(c4);
      }
      //FONCTION QUI DECODE UN FLOTTANT 2

      int main(){
      char*sh,type,*c,c1;
      int i,j,l,v;
      c=(char*)malloc(sizeof(char));
      sh=(char*)malloc(sizeof(char));
      printf("\t ENTRER VOTRE TYPE:\n\n");
      scanf("%c",&type);
      printf("\n entrer votre chaine ");
      scanf("%s",&sh);
      //printf("la chane est %s",sh);
      if(type=='u'){
      l=sizeof(unsigned int)*8;
      v=verif (sh,l);
      printf("alors la %d",v);
      if(v==1){
      i=decode_int(sh);
      printf("le code est %d\n:",i);
      }
      printf("erreur dans le code");
      }
      else
      if(type=='b'){
      l=sizeof(int)*8;
      v=verif (sh,l);
      if(v==1){
      c=decode_cpl1(sh);
      printf("le code est %s\n:",c);
      }
      printf("erreur dans le code");
      }
      else
      if(type='d'){
      l=sizeof(int)*8;
      v=verif (sh,l);
      printf("je suis %d",v);
      if(v==1){
      c=decode_cpl2(sh);
      printf("le code est %s\n:",c);
      }
      printf("erreur dans le code");
      }
      else
      if (type=='c'){
      l=sizeof(char)*8;
      v=verif (sh,l);
      if(v==1){
      c1=decode_char(sh);
      printf("le code est %c\n:",c1);
      }
      printf("erreur dans le code");
      }
      else
      if (type=='s')
      {v=verif_char(sh);
      if(v==1){
      c=decode_chaine(sh);
      printf("le code est %s\n:",c);
      }
      printf("erreur dans le code");
      }
      return 1;
      getch();
      getch();
      }
    2. @mypej ai un message d erreur au niveau de l 'execution
    3. @alicia85je ne comprend pas ce que tu écris par exemple si moi je veux créer un logiciel j'écris :
      antivirus très puissant
      s'accompagne d'un pare-feu
      antitrojan
      antirookit
      antispywares
      antimalwares
  2. Ben dis déjà ton pb sinon on peut rien faire on est pas devin..
    1. en fait j ecris un programme qui permet de decoder une chaine de bit entrée poar un utilisateur .voici le code mais un message d'erreur s 'affiche je ne sais prkoi
      #include<stdio.h>
      #include<string.h>
      #include<conio.h>
      #include<math.h>
      //FONCTION DE VERIFICATION DE TAILLE D UNE CHAINE
      //il retourne 1 si la taille est egale a celle du type sinon 0
      int verif ( char*s,int l)
      {
      if (l==(strlen(s)-1))
      return 1;
      else
      return 0;
      }

      //FONCTION DE VERIFICATION DE LA TAILLE POUR LES TYPES CHAINE DE CARACTERE
      int verif_char( char *s)
      {if (((strlen(s)-1)%8)==0)
      return 1;
      else
      return 0;
      }
      //FONCTION QUI PERMET D'EXTRAIRE UNE CHAINE DE CARACTERE
      char *extract ( char*s,int deb,int fin){
      char *ch=NULL;
      int i;
      if ((s!=NULL)&&(deb<fin)){
      ch=malloc(sizeof(*ch)*(fin-deb+2));
      if (ch!=NULL)
      {for(i=deb;i<=fin;i++)
      {ch[i-deb]=s[i];
      }
      ch[i-deb]='\0';
      }
      else
      printf("erreur");

      return(ch);
      }
      }
      //FONCTION QUI DECODE UN ENTIER
      int decode_int(char*s){
      int val=0,i,l=strlen(s);
      i=l-1;
      while(i>=0){
      if (s[i]==1)
      {val=val+pow(2,i-l+1);
      i++;}
      i++;
      }
      }
      //FONCTION QUI DECODE UNE CHAINE EN ENTIER DECIMAL NON SIGNE
      int decode_uns(char *s)
      { int i,val,l=strlen(s);
      char c;
      for(i=l-1;i>=0;i++)
      { if (s[i]!=0)
      val=val+pow(2,i-l+1);
      }
      }
      //FONCTION QUI DECODE UNE CHAINE EN ENTIER DECIMAL SIGNE CPLMENT A 2
      char *decode_cpl2 (char *s){
      int j,i,l=strlen(s),val=0;
      char *c,*c1;
      c=(char*)malloc(sizeof(char)); c1=(char*)malloc(sizeof(char));
      while(s!=NULL){
      if (s[0]==1){
      c="-";
      val= decode_uns(s);
      strcat(c,"val");
      }
      { c="+";
      i=l-1;
      while((i>0)&&(s[i]==0)){i++;}
      val+=pow(2,i-l+1);
      for(j=i-1;j>0;j++){
      if(s[i]==0)
      val+=pow(2,i-l+1);
      }
      strcat(c,"val");
      }
      }
      return(c);
      }
      //FONCTION QUI DECODE UNE CHAINE E ENTIER DECIMAL SIGNE CPLMENT 1

      char *decode_cpl1(char*s){
      int i,val=0,l=strlen(s);
      char*c;
      c=(char*)malloc(sizeof(char));
      if (s[0]==1)
      { c="+";
      i=l-1;
      while(i>0){
      if(s[i]==0)
      {
      val+=pow(2,i-l+1);
      }
      i++;
      }
      strcat(c,"val");
      }
      {
      c="-";
      strcat(c,"val");
      }
      return(c);
      }
      //FONCTION QUI DECODE UNE CHAINE EN REEL
      char *decode_real1(char*s){
      char*c1,*c2,*c3; c1=(char*)malloc(sizeof(char)); c2=(char*)malloc(sizeof(char)); c3=(char*)malloc(sizeof(char));
      int l=strlen(s),i=0,j,k,e,m;
      if (s[i]==0){ c1="+";
      } c1="-";
      j=2;k=9; c2=extract(s,j,k);
      e=decode_int(c2);
      strcat(c1,c2);
      if (s[10]==0)
      {c3="+";}c3="-";
      strcat(c1,c3);
      for(i=11;i<=32;i++){
      m+=pow(2,-i-1);}
      strcat(c1,"m");
      return(c1);
      }
      //FONCTION QUI DECODE UNE CHAINE EN CARACTERE
      char decode_char(char*s) {
      int n,val;
      char c;
      val=decode_int(s);
      c=val;
      return(val);
      }
      //FONCTION QUI DECODE UNE CHAINE EN CHAINE DE CARATERE
      char *decode_chaine(char *s){
      int i=0,j=7,val,l=strlen(s);
      char*c1,c2,c3,*c4;
      c4=(char*)malloc(sizeof(char)); c1=extract(s,i,j); c2=decode_char(c1);
      c4="c2";
      while ((i<j)&&(j<l))
      { i+=8;
      j+=8; c1=extract(s,i,j); c3=decode_char(s);
      strcat(c4,"c3");
      }
      return(c4);
      }
      //FONCTION QUI DECODE UN FLOTTANT 2

      int main(){
      char*sh,type,*c,c1;
      int i,j,l,v;
      c=(char*)malloc(sizeof(char));
      sh=(char*)malloc(sizeof(char));
      printf("\t ENTRER VOTRE TYPE:\n\n");
      scanf("%c",&type);
      printf("\n entrer votre chaine ");
      scanf("%s",&sh);
      //printf("la chane est %s",sh);
      if(type=='u'){
      l=sizeof(unsigned int)*8;
      v=verif (sh,l);
      printf("alors la %d",v);
      if(v==1){
      i=decode_int(sh);
      printf("le code est %d\n:",i);
      }
      printf("erreur dans le code");
      }
      else
      if(type=='b'){
      l=sizeof(int)*8;
      v=verif (sh,l);
      if(v==1){
      c=decode_cpl1(sh);
      printf("le code est %s\n:",c);
      }
      printf("erreur dans le code");
      }
      else
      if(type='d'){
      l=sizeof(int)*8;
      v=verif (sh,l);
      printf("je suis %d",v);
      if(v==1){
      c=decode_cpl2(sh);
      printf("le code est %s\n:",c);
      }
      printf("erreur dans le code");
      }
      else
      if (type=='c'){
      l=sizeof(char)*8;
      v=verif (sh,l);
      if(v==1){ c1=decode_char(sh);
      printf("le code est %c\n:",c1);
      }
      printf("erreur dans le code");
      }
      else
      if (type=='s')
      {v=verif_char(sh);
      if(v==1){
      c=decode_chaine(sh);
      printf("le code est %s\n:",c);
      }
      printf("erreur dans le code");
      }
      return 1;
      getch();
      getch();
      }
  3. poste ton code aussi pour qu'on voit ;)
    1. voici mon code il m 'affiche des message d'erreurs a l'execution
      #include<stdio.h>
      #include<string.h>
      #include<conio.h>
      #include<math.h>
      //FONCTION DE VERIFICATION DE TAILLE D UNE CHAINE
      //il retourne 1 si la taille est egale a celle du type sinon 0
      int verif ( char*s,int l)
      {
      if (l==(strlen(s)-1))
      return 1;
      else
      return 0;
      }

      //FONCTION DE VERIFICATION DE LA TAILLE POUR LES TYPES CHAINE DE CARACTERE
      int verif_char( char *s)
      {if (((strlen(s)-1)%8)==0)
      return 1;
      else
      return 0;
      }
      //FONCTION QUI PERMET D'EXTRAIRE UNE CHAINE DE CARACTERE
      char *extract ( char*s,int deb,int fin){
      char *ch=NULL;
      int i;
      if ((s!=NULL)&&(deb<fin)){
      ch=malloc(sizeof(*ch)*(fin-deb+2));
      if (ch!=NULL)
      {for(i=deb;i<=fin;i++)
      {ch[i-deb]=s[i];
      }
      ch[i-deb]='\0';
      }
      else
      printf("erreur");

      return(ch);
      }
      }
      //FONCTION QUI DECODE UN ENTIER
      int decode_int(char*s){
      int val=0,i,l=strlen(s);
      i=l-1;
      while(i>=0){
      if (s[i]==1)
      {val=val+pow(2,i-l+1);
      i++;}
      i++;
      }
      }
      //FONCTION QUI DECODE UNE CHAINE EN ENTIER DECIMAL NON SIGNE
      int decode_uns(char *s)
      { int i,val,l=strlen(s);
      char c;
      for(i=l-1;i>=0;i++)
      { if (s[i]!=0)
      val=val+pow(2,i-l+1);
      }
      }
      //FONCTION QUI DECODE UNE CHAINE EN ENTIER DECIMAL SIGNE CPLMENT A 2
      char *decode_cpl2 (char *s){
      int j,i,l=strlen(s),val=0;
      char *c,*c1;
      c=(char*)malloc(sizeof(char));
      c1=(char*)malloc(sizeof(char));
      while(s!=NULL){
      if (s[0]==1){
      c="-";
      val= decode_uns(s);
      strcat(c,"val");
      }
      { c="+";
      i=l-1;
      while((i>0)&&(s[i]==0)){i++;}
      val+=pow(2,i-l+1);
      for(j=i-1;j>0;j++){
      if(s[i]==0)
      val+=pow(2,i-l+1);
      }
      strcat(c,"val");
      }
      }
      return(c);
      }
      //FONCTION QUI DECODE UNE CHAINE E ENTIER DECIMAL SIGNE CPLMENT 1

      char *decode_cpl1(char*s){
      int i,val=0,l=strlen(s);
      char*c;
      c=(char*)malloc(sizeof(char));
      if (s[0]==1)
      { c="+";
      i=l-1;
      while(i>0){
      if(s[i]==0)
      {
      val+=pow(2,i-l+1);
      }
      i++;
      }
      strcat(c,"val");
      }
      {
      c="-";
      strcat(c,"val");
      }
      return(c);
      }
      //FONCTION QUI DECODE UNE CHAINE EN REEL
      char *decode_real1(char*s){
      char*c1,*c2,*c3;
      c1=(char*)malloc(sizeof(char));
      c2=(char*)malloc(sizeof(char));
      c3=(char*)malloc(sizeof(char));
      int l=strlen(s),i=0,j,k,e,m;
      if (s[i]==0){
      c1="+";
      }
      c1="-";
      j=2;k=9;
      c2=extract(s,j,k);
      e=decode_int(c2);
      strcat(c1,c2);
      if (s[10]==0)
      {c3="+";}c3="-";
      strcat(c1,c3);
      for(i=11;i<=32;i++){
      m+=pow(2,-i-1);}
      strcat(c1,"m");
      return(c1);
      }
      //FONCTION QUI DECODE UNE CHAINE EN CARACTERE
      char decode_char(char*s) {
      int n,val;
      char c;
      val=decode_int(s);
      c=val;
      return(val);
      }
      //FONCTION QUI DECODE UNE CHAINE EN CHAINE DE CARATERE
      char *decode_chaine(char *s){
      int i=0,j=7,val,l=strlen(s);
      char*c1,c2,c3,*c4;
      c4=(char*)malloc(sizeof(char));
      c1=extract(s,i,j);
      c2=decode_char(c1);
      c4="c2";
      while ((i<j)&&(j<l))
      { i+=8;
      j+=8;
      c1=extract(s,i,j);
      c3=decode_char(s);
      strcat(c4,"c3");
      }
      return(c4);
      }
      //FONCTION QUI DECODE UN FLOTTANT 2

      int main(){
      char*sh,type,*c,c1;
      int i,j,l,v;
      c=(char*)malloc(sizeof(char));
      sh=(char*)malloc(sizeof(char));
      printf("\t ENTRER VOTRE TYPE:\n\n");
      scanf("%c",&type);
      printf("\n entrer votre chaine ");
      scanf("%s",&sh);
      //printf("la chane est %s",sh);
      if(type=='u'){
      l=sizeof(unsigned int)*8;
      v=verif (sh,l);
      printf("alors la %d",v);
      if(v==1){
      i=decode_int(sh);
      printf("le code est %d\n:",i);
      }
      printf("erreur dans le code");
      }
      else
      if(type=='b'){
      l=sizeof(int)*8;
      v=verif (sh,l);
      if(v==1){
      c=decode_cpl1(sh);
      printf("le code est %s\n:",c);
      }
      printf("erreur dans le code");
      }
      else
      if(type='d'){
      l=sizeof(int)*8;
      v=verif (sh,l);
      printf("je suis %d",v);
      if(v==1){
      c=decode_cpl2(sh);
      printf("le code est %s\n:",c);
      }
      printf("erreur dans le code");
      }
      else
      if (type=='c'){
      l=sizeof(char)*8;
      v=verif (sh,l);
      if(v==1){
      c1=decode_char(sh);
      printf("le code est %c\n:",c1);
      }
      printf("erreur dans le code");
      }
      else
      if (type=='s')
      {v=verif_char(sh);
      if(v==1){
      c=decode_chaine(sh);
      printf("le code est %s\n:",c);
      }
      printf("erreur dans le code");
      }
      return 1;
      getch();
      getch();
      }
    2. @alicia85pas besoin de mettre ton code 3 fois
      quelle erreur tu as ?
      et où dans le code a quel niveau ?
    3. @mypestp si tu as devcpp ou autre essaye de le compiler voir
  4. quelle code et ou poster
    1. pas toi sheva je parlais a alicia ;)
      si tu as un probleme crée toi ton propre topic et explique ton probleme...
    2. @mypeje ne sais pas comment creer mon topic stp aides moi
  5. vous etes encore la svp je dois regler ce pb ce soir s il vous plait aidez moi
    1. deja il y a un probleme avec ta variable sh tu la declare comme un char * et tu fais un malloc mais tu lui alloue de l'espace que pour un seul caractere
      sh=(char*)malloc(sizeof(char)); 
      et apres tu essayes d'y stocker une chaine
       scanf("%s",&sh); 
      il faut que tu revoies tes malloc c'est la le probleme
      1. bonjour a vous tous etes vous la pour pouvoir m aider svp
        1. bonjour on me renvoie tjrs des message d'erreur comme quoi "erreur de segmentation"