Foro de elhacker.net

Programación => Programación C/C++ => Mensaje iniciado por: Chazy Chaz en 17 Octubre 2011, 13:46 pm



Título: error de compilacion
Publicado por: Chazy Chaz en 17 Octubre 2011, 13:46 pm
Hola, uso el programa Code::Blocks 10 y el compilador de Microsoft Visual C++ 2005/2008 y me da el siguiente error al compilar:

D:\color menu c\test.c|13|error C2143: error de sintaxis : falta ';' delante de 'tipo'|
D:\color menu c\test.c|23|error C2065: 'tecla' : identificador no declarado|
D:\color menu c\test.c|24|error C2065: 'tecla' : identificador no declarado|
D:\color menu c\test.c|26|error C2065: 'tecla' : identificador no declarado|
||=== Build finished: 4 errors, 0 warnings ===|

Esta es la primera linea del build log: cl : L¡nea de comandos warning D9007 : '/EHc' requiere '/EHa, /EHs o /GX'; opci¢n omitida
test.c De eso yo ya no entiendo xD


El codigo lo cree hace un par de años cuando usaba el dev c++ con la libreria conio2 pero debido a que es un infierno configurarlo y daba errores por la actualizacion de la libreria... que le den xD
Aqui dejo el codigo para que veais que no hay nada mal:

Código:
#include <stdio.h>
#include <conio.h>
#define exit 0
#define enter 1

main()
{
      system("title Program Title ");
      while (enter==1){
      textcolor(70); clrscr();gotoxy(10,2);
      textcolor(120); puts("\t     ****  My Program Title  ****         \t");
      textcolor(70);
      int tecla;

     puts("\n\n\n\t\t  <1> Option 1");
     puts("\n\t\t  <2> Option 2");
     puts("\n\t\t  <3> Option 3");
     puts("\n\t\t  <4> Option 4");
     puts("\n\t\t  <5> Option 5");
     puts("\n\t\t  <6> Option 6");
     puts("\n\n\n\t\t  <0> Exit");
     gotoxy(25,24);puts("*** by ChazyTheBest ***");
     textcolor(240);gotoxy(55,22); printf(">  Count:  "); printf(" <", tecla); textcolor(30);
     tecla=getch();

     switch (tecla){
            int op;
             case '1': textcolor(30);clrscr();gotoxy(15,2);textcolor(240);puts("\t ^-^ \t   Press 1 - Menu\t ^-^\t");textcolor(30);puts("\n\n\t\t Text here...\n\n\t\t press one key..."); op=getch(); break;
             case '2': textcolor(30);clrscr();gotoxy(15,2);textcolor(240);puts("\t ^-^ \t   Press 2 - Menu\t ^-^\t");textcolor(30);puts("\n\n\t\t Text here...\n\n\t\t press one key..."); op=getch(); break;
             case '3': textcolor(30);clrscr();gotoxy(15,2);textcolor(240);puts("\t ^-^ \t   Press 3 - Menu\t ^-^\t");textcolor(30);puts("\n\n\t\t Text here...\n\n\t\t press one key..."); op=getch(); break;
             case '4': textcolor(30);clrscr();gotoxy(15,2);textcolor(240);puts("\t ^-^ \t   Press 4 - Menu\t ^-^\t");textcolor(30);puts("\n\n\t\t Text here...\n\n\t\t press one key..."); op=getch(); break;
             case '5': textcolor(30);clrscr();gotoxy(15,2);textcolor(240);puts("\t ^-^ \t   Press 5 - Menu\t ^-^\t");textcolor(30);puts("\n\n\t\t Text here...\n\n\t\t press one key..."); op=getch(); break;
             case '6': textcolor(30);clrscr();gotoxy(15,2);textcolor(240);puts("\t ^-^ \t   Press 6 - Menu\t ^-^\t");textcolor(30);puts("\n\n\t\t Text here...\n\n\t\t press one key..."); op=getch(); break;
             case '0': return 0;break;
             default: gotoxy(40,21);puts("fock ur focking fingers! only 0 to 6!!!"); getch(); enter==0; break;
             }
             }
     getch();
}

Whats wrong in the code??

salu2
dew ;D


Título: Re: error de compilacion
Publicado por: Eternal Idol en 17 Octubre 2011, 14:28 pm
Cambiale la extension al archivo a .cpp, no podes declarar variables en cualquier parte en C, tienen que estar siempre al comienzo de un bloque y tecla no lo esta.

Por otro lado el codigo no es standard ni mucho menos al depender de conio ...