Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

256
Vistas
How to add default in every case in c++

how do i add default in every case? it does not allow me to do it like this and will error in the second default,

switch (select)
{
    
    case 1:
        here1:
        cout<<"statement"<<endl;
        
    default:
        cout<<"statement"<<endl;
        goto here1;         

        break;
        

    case 2:
        here2:
        cout<<"statement"<<endl;
        
    default:
        cout<<"statement"<<endl;
        goto here2;         

        break;
        

i need default inside every case, how am i gonna do that?

over 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

it looks like you are trying to execute the same piece of code for every case so why can't you just do so.

default just works if "incase nothing works" and if something works default doesn't execute.

over 4 years ago · Santiago Trujillo Denunciar

0

well you really cant do this because "default" considered as a case itself so you cant make two cases in one. but instead if you want so mimic it you can use an "if statement " with the condition you want.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda