Jump to content

Erro no código


rjsma
 Share

Recommended Posts

fiz este programa mas da me erro

queria saber se alguem podia me ajudar

#include<iostream>
#include<stdlib.h>
#include<conio.h>

using namespace std;

int main()
{
    char letra;
    cout<<"Introduza letra (L/D/F) :";
    cin>> letra;
    
    switch(letra)
    {
                 case 'L' ;
                 cout<<"ligar";
                 break;
                 
                 case 'D';
                 cout<<"desligar";
                 break;
                 
                 case 'F';
                 cout<<"Furar";
                 break;
                 
                 default:
              cout<<"operacao invalida";
                         }
                         getch();
                        }
Link to comment
Share on other sites

Estás a programar em Windows ou Linux? Porque a biblioteca conio.h, da qual faz parte a função getch(), só existe em Windows.

❝The idea that I can be presented with a problem, set out to logically solve it with the tools at hand, and wind up with a program that could not be legally used because someone else followed the same logical steps some years ago and filed for a patent on it is horrifying.❞- John Carmack on software patents

A list  of command line apps

Link to comment
Share on other sites

Ah, depois de cada 'case', é suposto usares dois pontos e não ponto e vírgula:

case 'teste':
     codigo;

❝The idea that I can be presented with a problem, set out to logically solve it with the tools at hand, and wind up with a program that could not be legally used because someone else followed the same logical steps some years ago and filed for a patent on it is horrifying.❞- John Carmack on software patents

A list  of command line apps

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.