Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
1229 connectés 

  FORUM HardWare.fr
  Programmation
  C++

  besoin d'aide pour resolution d'erreur sous visual c++

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

besoin d'aide pour resolution d'erreur sous visual c++

n°373549
darkthunde​r
Posté le 27-04-2003 à 21:45:10  profilanswer
 

voilà jai fait ce petit programme et mon compilateur m'indique les erreurs suivantes:
--------------------Configuration: 3 - Win32 Debug--------------------
Compiling...
5.cpp
E:\26042003bis\3\5.cpp(45) : error C2601: 'main' : local function definitions are illegal
E:\26042003bis\3\5.cpp(76) : error C2958: the left parenthesis '(' found at 'E:\26042003bis\3\5.cpp(49)' was not matched correctly
E:\26042003bis\3\5.cpp(81) : fatal error C1004: unexpected end of file found
Error executing cl.exe.
 
3.exe - 3 error(s), 0 warning(s)
 
 

Code :
  1. #include<stdio.h>
  2. int tab[4][3];
  3. int nand (int a,int b){
  4. if (a==0||b==0)return 1;
  5.  else return 0;
  6. }
  7. int and (int a, int b){
  8. if(a==0||b==0)return 0;
  9. else return 1;
  10. }
  11. int or(int a, int b){
  12. if (a==1||b==1)return 1;
  13. else return 0;
  14. }
  15. int nor(int a, int b){
  16. if (a==1||b==1)return 0;
  17. else return 1;
  18. }
  19. void tab_bin(void){
  20. tab[0][0]=0;
  21. tab[0][1]=0;
  22. tab[1][0]=0;
  23. tab[1][1]=1;
  24. tab[2][0]=1;
  25. tab[2][1]=0;
  26. tab[3][0]=1;
  27. tab[3][1]=1;}
  28. void affichage (){ int j;
  29. printf("|  A  |  B  |  Q  |\n" );
  30. printf("-------------------\n" );
  31. for (j=0;j<4;j++)
  32. {printf("|                 |\n" );
  33. printf("|  %d  |  %d  |  %d  |\n",tab[j][0],tab[j][1],tab[j][2]);
  34. printf("-------------------\n" );}
  35. int main (){
  36. int j,rep;
  37. printf(("1.NAND\n2.AND\n3.OR\n4.NOR\n" );
  38. scanf("%d",&rep);
  39. switch(rep){
  40. case'1':for (j=0;j<4;j++)
  41.  tab[j][2]= nand(tab[j][0],tab[j][1]);
  42.  affichage();break;
  43. case'2':
  44.  for (j=0;j<4;j++)
  45.  tab[j][2]= and(tab[j][0],tab[j][1]);
  46.  affichage();break;
  47. case'3':
  48.  for (j=0;j<4;j++)
  49.  tab[j][2]= or(tab[j][0],tab[j][1]);
  50.  affichage();break;
  51. case'4':
  52.  for (j=0;j<4;j++)
  53.  tab[j][2]= nor(tab[j][0],tab[j][1]);
  54.  affichage();break;
  55. }
  56.  return (0);
  57. }

mood
Publicité
Posté le 27-04-2003 à 21:45:10  profilanswer
 

n°373557
MagicBuzz
Posté le 27-04-2003 à 21:56:54  profilanswer
 

printf(("1.NAND\n2.AND\n3.OR\n4.NOR\n" );
 
Y'a une ( en trop.

n°373585
darkthunde​r
Posté le 27-04-2003 à 22:16:51  profilanswer
 

ok merci mais il me reste encore la premiere et derniere erreurs.

n°373609
Harkonnen
Modérateur
Un modo pour les bannir tous
Posté le 27-04-2003 à 22:55:39  profilanswer
 

darkthunder a écrit :

ok merci mais il me reste encore la premiere et derniere erreurs.


Corrige donc la parenthèse, et tu verras que ces erreurs disparaitront.
La C2601 se produit quand du définis une fonction dans une fonction, et la C1004 se produit quand le compilo détecte une mauvaise construction à la fin du source (parenthèse fermante manquante, ou crochet, fin de commentaire, etc...)


---------------
J'ai un string dans l'array (Paris Hilton)
n°373622
darkthunde​r
Posté le 27-04-2003 à 23:16:37  profilanswer
 

il me reste toujours l'erreur C2601.
il manque une accolade à la fin et une parenthese en trop.

n°373629
Harkonnen
Modérateur
Un modo pour les bannir tous
Posté le 27-04-2003 à 23:24:55  profilanswer
 

Ben oui !
L'accolade fermante de affichage(), tu l'as mise à la fin de main().
Et place le return(0) dans main() aussi.


Message édité par Harkonnen le 27-04-2003 à 23:25:06

---------------
J'ai un string dans l'array (Paris Hilton)

Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  C++

  besoin d'aide pour resolution d'erreur sous visual c++

 

Sujets relatifs
[vbscript]- erreur dans la recherche de chaines de caractèreTrouver et télécharger la MSDN Visual C++
apache/mod ssl besoin d'aide sous win32 ?Comment ça marche le timer dans Visual Basic 6 [ newbie inside ]
[Visual Basic] Ajouter des boutons dynamiquement (et qu'ils restent)java aide,question facile
Déclarer un tableau à l'aide d'une variable..Un peu d'aide s'il vous plait ! (ASM)
[edit] aide java (comment inserer une image dans une fenetre ??) 
Plus de sujets relatifs à : besoin d'aide pour resolution d'erreur sous visual c++


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR