The use of ctype in c ++

-2
#include<iostream>
#include<ctype>
using namespace std;
int main()
{
double cuota,dscto, importe=0;
char colegio, categoria;
int sw=0;
cout<<"Ingresar colegio de procedencia (N)acional,(P)articular:";
cin>>colegio;
cout<<" Ingresar categoria (A,B,C):";
cin >>categoria;
cout<<"Ingresar cuota:";
cin>>cuota;
colegio=tolower(colegio);
categoria=tolower(categoria);
siwtch (colegio)
{
    case ´n´
        break;
    }
        switch (categoria)
        {
            case ´a´: dscto=.50*cuota;break;
            case ´b´: dscto=.40*cuota;break;
            case ´c´: dscto=.30*cuota;break;
            default: cout<<"Opcion no contemplada";
            sw=1;

        }
        break;
        case ´p´:
            switch(categoria)
            {case ´a´:dscto=.25*cuota;break;
         case ´b´:dscto=.20*cuota;break;
         case ´c´:dscto=.15*cuota;break;
         sw=1;
            }
        break;
        default: cout<<"Opcion no contemplada";
            sw=1;

    }
        if (sw==0)
        {
        importe=cuota-dscto;
        cout<<"El importe a pagar es:"<<importe;
    }
        cout<<endl;
}

When compiling I get it:

  

[Error] ctype: No such file or directory compilation terminated.

What am I doing wrong?

    
asked by juan 27.08.2018 в 20:45
source

1 answer

0

The libraries inherited from C are in two formats:

  • old name, the same as in C: stdio.h
  • new name, the extension disappears and a c is added to the start: cstdio

Now, the library ctype , in C is with this name: ctype.h , then to use it in C ++ we can use:

#include <ctype.h> // Nombre C
#include <cctype>  // Nombre C++

On the other hand, your program has several errors in the code:

  • siwtch should be switch

    siwtch (colegio) // <<--- MAL
    switch (colegio) // <<--- BIEN
    
  • Characters are indicated with the character ' instead of ´ . The cases, in addition, also go with two points:

    case ´n´  // <<--- MAL
    case 'n': // <<--- BIEN
    
  • It is not recommended to nest instructions switch . It is preferable to divide the code into functions

  • Keep an eye on the keys. There is break and instructions case outside of switch :

    switch (colegio)
    {
      case 'n':
        break;
    }
    
    switch (categoria)
    {
        case 'a': dscto=.50*cuota;break;
        case 'b': dscto=.40*cuota;break;
        case 'c': dscto=.30*cuota;break;
        default: cout<<"Opcion no contemplada";
        sw=1;
    
    }
    break; // <<--- Por ejemplo este
    
answered by 28.08.2018 в 07:34