Foro de elhacker.net

Programación => Programación C/C++ => Mensaje iniciado por: qwertyui en 22 Mayo 2016, 04:22 am



Título: Error en codigo c++ ISO c++ forbids comparision between pointer and integer
Publicado por: qwertyui en 22 Mayo 2016, 04:22 am
Código
  1. #include <iostream>
  2. #include <string>
  3. #include <cstdlib>
  4. #include <stdio.h>
  5. #include <conio.h>
  6. #include <stdlib.h>
  7. #include <windows.h>
  8. #include <fstream>
  9. #define USER "admin"
  10. #define PASS "pavisb6"
  11. #define ENTER 13
  12. #define BACKSPACE 8
  13. FILE *archivo;
  14.  
  15. using namespace std;
  16.  
  17. int main(void)
  18. {
  19.    system("color 0B");
  20.   string usuario, password;
  21.   int contador = 0;
  22.   bool ingresa = false;
  23.  
  24.            do {
  25.            system("cls");
  26.            cout << "\t\t\tCyber Card" << endl;
  27.            cout << "\n\tUsuario: ";
  28.            getline(cin, usuario);
  29.  
  30.            cout << "\tPassword: ";
  31.  
  32.            char caracter;
  33.            caracter = getch();
  34.  
  35.            password = "";
  36.  
  37.            while (caracter != ENTER) {
  38.  
  39.             if (caracter != BACKSPACE) {
  40.         password.push_back(caracter);
  41.         cout << "*";
  42.  
  43. } else {
  44.            if (password.length() > 0) {
  45.            cout << "\b \b";
  46.            password = password.substr(0, password.length() - 1);
  47.            }
  48. }
  49.  
  50. caracter = getch();
  51.            }
  52.  
  53.  
  54.            if (usuario == USER && password == PASS) {
  55.            ingresa = true;
  56.            } else {
  57.            cout << "\n\n\tEl usuario y/o clave de acceso son incorrectos" << endl;
  58.            cin.get();
  59.            contador++;
  60.            }
  61.            } while (ingresa == false && contador < 3);
  62.  
  63.            if (ingresa == false) {
  64.            cout << "\n\tUsted no pudo ingresar al sistema. ADIOS" << endl;
  65.            return 0;
  66.            }
  67.            else
  68.            {
  69.            cout << "\n\n\tBienvenido al sistema" << endl;
  70.            system("PAUSE");
  71.            }
  72.  
  73.            {
  74.  
  75.            system("cls");
  76.  
  77.            int opcion;
  78.                }
  79.  
  80.    char decidir;
  81.    int opcion;
  82.    int opcion2;
  83.    char regisc [20];
  84.    char fechav [10];
  85.    char tic [15];
  86.    char pagop [10];
  87.    char pregunta;
  88.    char respuesta;
  89.    bool regresar= false;
  90.    char clientep [50];
  91.    int opcion3;
  92.    bool modificar=true;
  93.    char codip [5];
  94.    bool encontrado=true;
  95.    do
  96.    {
  97.        Menu3:
  98.        system("cls");
  99.        cout << "Menu principal" << endl << "-----------------------" << endl;
  100.        cout << "[1] Registrar pago con tarjeta y numero de tarjeta" << endl;
  101.        cout << "[2] Modificar regristro de pago y  numero de tarjeta" << endl;
  102.        cout << "[3] Consultar registro de pagos y tarjeta" << endl;
  103.        cout << "[4] Eliminar pago con tarjeta" << endl;
  104.        cout << "[5] imprimir recibos de confirmación de pago con tarjeta" << endl;
  105.        cout << "[6] salir" << endl;
  106.        cout << "-------------------------" << endl<< endl;
  107.        cout << "Seleccione una opcion: ";
  108.        cin >> opcion;
  109.  
  110.        switch(opcion)
  111.  
  112.  
  113.  
  114.  
  115.        {
  116.            case 1:
  117.            {
  118.            Menu1:
  119.           system ("title Registro");
  120.           system ("cls");
  121.           cout << "registros" <<endl << "____________________________________" <<endl;
  122.           cout << "[7] resgistrar pago y tarjeta" <<endl;
  123.           cout << "[8] menu principal" << endl << "_____________________________" <<endl;
  124.           cout << "Elige una opcion" <<endl;
  125.           cin >> opcion2;
  126.            }
  127.               switch (opcion2)
  128.  
  129.  
  130.        {
  131.            case 7:
  132.            Menu2:
  133.            {
  134.            system ("title saber card");
  135.            system ("cls");
  136.            archivo = fopen ("registro.dat","a");
  137.            cout <<" escriba un codigo para el registro" <<endl;
  138.            cin.getline (codip, 5) >> codip;
  139.            fprintf(archivo, "%s\n", codip);
  140.            cout << "escribe el  numero de la tarjeta:" <<endl;
  141.            cin.getline (regisc, 25) >> regisc;
  142.            fprintf(archivo, "%s\n", regisc);
  143.            cout <<"escribe la fecha de pago:" <<endl;
  144.            cin.getline (fechav, 10) >> fechav;
  145.            fprintf(archivo, "%s\n", fechav);
  146.            cout << "escribe el tipo de tarjeta:"<< endl;
  147.            cin.getline (tic, 15) >> tic;
  148.            fprintf(archivo, "%s\n", tic);
  149.            cout<< "escribe el nombre del cliente" << endl;
  150.            cin.getline (clientep, 50) >> clientep;
  151.            fprintf (archivo, "%s\n", clientep);
  152.            cout << "escribe el monto a pagar del ariculo:" <<endl;
  153.            cin.getline (pagop, 25) >> pagop;
  154.            fprintf(archivo, "%s\n", pagop);
  155.            cout << "Desea agregar otro registro? (s/n)";
  156.            cin >> pregunta;
  157.  
  158.            fclose(archivo);
  159.            if (pregunta == 's' || pregunta == 'S'){ goto Menu2;}
  160.            else{
  161.            cout<< "Desea realizar otra operacion? (s/n)" <<endl;
  162.            cin>> respuesta;
  163.            if (respuesta == 's' || respuesta == 'S')
  164.            {
  165.             goto Menu1;
  166.            }
  167.  
  168.            else{
  169.            system ("cls");
  170.            cout << "adios que vuelva pronto" <<endl;
  171.  
  172.            exit (0);
  173.            }
  174.            break;
  175.            }
  176.            case 8:
  177.            {
  178.            goto Menu3;
  179.            }
  180.            }
  181.            }
  182.  
  183.  
  184.  
  185.  
  186.            {
  187.            case 2:
  188.            {
  189.  
  190.            Menu4:
  191.            system("title Modificar");
  192.            system("cls");
  193.  
  194.            cout<<"Modificar"<<endl<<"------------------------"<<endl;
  195.            cout<<"[9]Modificar regristro de pago y/o numero de tarjeta"<<endl;
  196.            cout<<"[10]Menu principal" <<endl;
  197.            cout<<"Elige una opcion"<<endl;
  198.            cin>>opcion3;
  199.            }
  200.  
  201.            {
  202.  
  203.            switch(opcion3)
  204.  
  205.            case 9:{ofstream aux;
  206.            ifstream lectura;
  207.             system("title modificar registro");
  208.             system ("cls");
  209.             encontrado=false;
  210.             int auxcodip=0;
  211.             char auxnombre [30];
  212.             char auxnumtarjeta;
  213.             aux.open("aux.dat",ios::out);
  214.             lectura.open("registro.dat",ios::in);
  215.             if(aux.is_open() && lectura.is_open()){
  216.             cout<< "insgresa la clave del registro que desea modificar";
  217.             cin>>auxcodip;
  218.             lectura>>codip;
  219.             while(!lectura.eof()){
  220.             lectura>>regisc>>fechav>>tic>>clientep>>pagop;
  221.    [u][b] if(auxcodip==codip){[/b][/u]
  222.                    encontrado=true;
  223.                    cout<<"____________________________"<<endl;
  224.                    cout<<"codigo:"<<codip<<endl;
  225.                    cout<<"num.tarjeta:"<<regisc<<endl;
  226.                    cout<<"fecha:"<<fechav<<endl;
  227.                    cout<<"tipo de tarjeta:"<<tic<<endl;
  228.                    cout<<"nom. cliente:"<<clientep<<endl;
  229.                    cout<<"pago:"<<pagop<<endl;
  230.                    cout<<"____________________________"<<endl;
  231.                    cout<<"ingresa el nuevo nombre del cliente con codigo"<<codip;
  232.                    aux <<codip" "<<regisc<<" "<<fechav<<" "<< tic<<" "<< auxnombre <<" "<<pagop<<endl;
  233.  
  234.                }else{
  235.                     aux <<codip" "<<regisc<<" "<<fechav<<" "<<tic<<" "<<clientep<<" "<<pagop<<endl;
  236.                }
  237.                lectura>>codip;
  238.            }
  239.            }else{
  240.                cout<<"no se a podido abrir el archivo o aun no ha sido creado"<<endl;
  241.                }
  242.                if(encontrado==false)
  243.                cout<<"no se encontro ningun registro con esa clave"<<auxcodip<<endl;
  244.  
  245.            }
  246.  
  247.            }
  248.            }
  249.            }
  250.            }while (opcion=true);
  251.  
  252.  
  253. }


Mod: Los códigos deben ir en etiquetas GeSHi


Título: Re: Error en codigo c++ ISO c++ forbids comparision between pointer and integer
Publicado por: class_OpenGL en 22 Mayo 2016, 08:19 am
No me he fijado mucho en el código, así que no he buscado errores salvo el descrito.
El error está en la línea 221, en if(auxcodip==codip). Aquí estás comparando un entero (auxcodip) con un arreglo de caracteres (codip). Eso no lo puedes hacer.

La próxima vez, indica la línea en la que está el error


Título: Re: Error en codigo c++ ISO c++ forbids comparision between pointer and integer
Publicado por: qwertyui en 22 Mayo 2016, 08:45 am
muchas gracias ya resolvimos el error