I get [Error] expected unqualified-id before '\ x72677629' [closed]

0

This is the code:

/* Programa 01
creado por: Julio Cesar Rodriguez Cardenas
MMXVI*/
#include <iostream>
#include <string>
#include <math.h>
using namespace std;

'int main (int argc, char** argv)':
 {
    char  algoritmo;
    string nombre   =   0;
    double libras   =   0;
    double pies =   0;
    double kg   =   0;
    double metros   =   0;
    int voto    =   1;
    int* cand   =   NULL;
    string mayor    =   0;
    int i   =   0;
    int g   =   0;
    int total   =   0;
    int porc    =   0;
    int llamadasr   =   0;
    int min =   0;
    double tarea    =   0;
    double totaltotal   =   0;
    double pllamada =   0;
    int area    =   0;
    double t12  =   0;
    int ll12    =   0;
    double t15  =   0;
    int ll15    =   0;
    double t18  =   0;
    int ll18    =   0;
    double t19  =   0;
    int ll19    =   0;
    double t23  =   0;
    int ll23    =   0;
    double t25  =   0;
    int ll25    =   0;
    double t29  =   0;
    int ll29    =   0;
    cout<<"producto integrador unidad II."<<endl;
    cout<<"dame una opcion, para saber que algoritmo resolver:";
    cin>>algoritmo;
    switch (algoritmo)
     {
        case 1:
            cout<<"El algoritmo oso";
            cout<<"¿Cuál es el nombre del oso polar?";
            cin >>nombre;
            cout<<"¿Cuántas libras pesa el oso polar?";
            cin >>libras;
            cout<<"¿Cuántos pies mide el oso polar?";
            cin>>pies;
            kg = libras*0.454;
            metros = pies*0.348;
            cout<<"el oso"<<nombre<<"tiene un peso de"<<kg<<"kiogramos y mide"<<metros<<"metros."<<endl;
            break;
        case 2:
            cout<<"El algortimo de los votos";
            switch (voto = !0)
            {
            cout<<"¿cual es tu voto?";
            cin>>voto;
            for ("voto";) {
                case 1:;
                        cand[1]+1;
                        break;
                case 2:;
                        cand[2]+1;
                        break;
                case 3:;
                        cand[3]+1;
                        break;
                case 4:;
                        cand[4]+1;
                        break;
                case 5:;
                        cand[5]+1;
                        break;
                case 6:;
                        cand[6]+1;
                        break;
            };
                default:
                    cout<<"Opcion no valida."<<endl;
                break;
            break;
            for (i=1; i<6; i++){
            total   =   total+cand[i];
            (cand[i] =  mayor);
            mayor   =   cand[i];
            g   =   i;
            break;
        }
            porc    =   mayor*100/total;
            cout<<"hubo"<<total<<"votos";
            for (i=1; i<=6; i++) {
                cout<<"el candidato"<<i<<"obtuvo"<<cand[i]<<"votos";
                break;
            cout<<"el ganador fue el candidato"<<g<<"con un porcentaje de"<<porc<<"porciento del total";
        }
        case 7 : "el algoritmo de las llamadas";
                cout<<"algoritmo de llamadas";
                cout<<"¿cuantas llamadas se hicieron?";
                cin>>llamadasr;
                for (i=1; i<=llamadasr; i++){
                    cout<<"¿cuantos minutos duro la llamada?";
                    cin>>min;
                    cout<<"¿a que area se hicieron las llamadas?";
                    cin>>area;
                    switch (area){
                    case 1:
                        pllamada    =   min*2.20;
                        t12 =   pllamada+t12;
                        totaltotal  =   t12+totaltotal;
                        ll12    =   ll12+1;
                        break;
                    case 2:
                        pllamada    =   min*2.80;
                        t15 =   pllamada+t15;
                        totaltotal  =   t15+totaltotal;
                        ll15    =   ll15+1;
                        break;
                    case 3:
                        pllamada    =   min*4.75;
                        t18 =   pllamada+t18;
                        totaltotal  =   t18+totaltotal;
                        ll18    =   ll18+1;
                        break;
                    case 4:
                        pllamada    =   min*3.65;
                        t19 =   pllamada+t19;
                        totaltotal  =   t19+totaltotal;
                        ll19    =   ll19+1;
                        break;
                    case 5:
                        pllamada    =   min*6.25;
                        t23 =   pllamada+t23;
                        totaltotal  =   t12+totaltotal;
                        ll23    =   ll23+1;
                        break;
                    case 6:
                        pllamada    =   min*6.25;
                        t25 =   pllamada+t25;
                        totaltotal  =   t25+totaltotal;
                        ll25    =   ll25+1;
                        break;
                    case 7:
                        pllamada    =   min*5.15;
                        t29 =   pllamada+t29;
                        totaltotal  =   t29+totaltotal;
                        ll29    =   ll29+1;
                        break;
                    default:
                        cout<<"Opcion no valida";
                        break;
                    }
                }
                cout<<"se realizaron"<<llamadasr<<"llamadas";
                cout<<ll12<<"llamadas al area 12 para un total de"<<t12<<"pesos";
                cout<<ll15<<"llamadas al area 12 para un total de"<<t15<<"pesos";
                cout<<ll18<<"llamadas al area 12 para un total de"<<t18<<"pesos";
                cout<<ll19<<"llamadas al area 12 para un total de"<<t19<<"pesos";
                cout<<ll23<<"llamadas al area 12 para un total de"<<t23<<"pesos";
                cout<<ll25<<"llamadas al area 12 para un total de"<<t25<<"pesos";
                cout<<ll29<<"llamadas al area 12 para un total de"<<t29<<"pesos";
                cout<<"para todas las llamadas fueron"<<totaltotal<<"pesos";
            break;
        }
        default:
            cout <<"Opcion invalida"<<endl;     
    }

    system ("PAUSE");
    return 0;   
    }
    
asked by tapxdax 21.06.2018 в 08:40
source

1 answer

4

All your error can be reduced to these lines:

'int main (int argc, char** argv)':
{
}

This produces the following error :

prog.cc:1:1: warning: character constant too long for its type
'int main (int argc, char** argv)':
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
prog.cc:1:1: error: expected unqualified-id before '\x72677629'

I do not know what language you think you're programming, but it's not .

In C ++, characters enclosed in single quotes are a multicaracter literal , their support is conditional (compilers they can decide not to support it) and their interpretation depends on the implementation (each compiler can decide to interpret it in their own way).

You accompany the multicaracter literal with colon ( : ), which creates a tag , which can be used in a statement goto or switch , but the literal that you use as a label is not recognized as such, hence the error. Remove the quotes and the colon:

int main (int argc, char** argv)
{
    // código...
}

Other things to consider.

  • You are (presumably) programming in C ++, so you should not use C inclusions, instead of <math.h> you should use <cmath> lee this thread to find out why.
  • In C ++ it is advised that the variables have the smallest possible scope, one of the reasons is that it is easier to reason about the utility of the variables if they are closer to the point where they are used. The same applies to the clause using namespace std; .
  • If you are not using the main parameters, do not define them.
  • Do not abuse std::end , read this thread to find out why.
  • Let your variables breathe, in the 90 we had screens of 80 characters wide and 25 lines high (there was no choice but to compact the code), but for decades we do not have those limitations, put some spaces in the code It will make it easier to read and your future self will thank you.
  • Follow the principle of sole responsibility encapsulating tasks not related to main in individual functions.
  • The names of your variables are confusing, it is difficult to determine your objective when reading your name, avoid using acronyms, acronyms, abbreviations and variables whose name is a single letter.
  • You initialize a std::string with a zero value ( 0 ) which throws an exception of type 'std::logic_error' , initializes with empty string ( "" ) or does not use initializer (trusts the default constructor).
  • The first switch of the algortimo of the votes contains off-label code.
  • The for ("voto";) instruction is nonsense, the (cand[i] = mayor); instruction does not require parentheses.
  • The pointer cand you use without allocating memory, that will cause your program to fail at run time.
  • Use objects to group related information instead of creating an army of variables with no apparent relationship to each other.

Your code is a nightmare.

    
answered by 21.06.2018 в 09:27