ABC
 All Classes Files Functions Variables Pages
Utilerias.hpp
Go to the documentation of this file.
1 #ifndef __Utilerias__
2 #define __Utilerias__
3 
4 #include <stdio.h>
5 #include <stdlib.h>
6 
8 
16 class Utilerias
17 {
18 
19 public:
20 
25  Utilerias(void)
26  {
27  }
28 
30  void leerNumero(int &num)
31  {
32  char cad[100];
33  int lg = 99;
34  int i = 0;
35  char c;
36 
37  while (i < lg)
38  {
39  scanf("%c", &c);
40  if (c == '\n') break;
41  cad[i] = c;
42  i++;
43  }
44  cad[i] = 0;
45  num = atoi(cad);
46  }
47 
49  void leerNumero(double &num)
50  {
51  char cad[100];
52  int lg = 99;
53  int i = 0;
54  char c;
55 
56  while (i < lg)
57  {
58  scanf("%c", &c);
59  if (c == '\n') break;
60  cad[i] = c;
61  i++;
62  }
63  cad[i] = 0;
64  num = atof(cad);
65  }
66 
67 
68 
70  void leerCadena(char *cad, int lg)
71  {
72  int i = 0;
73  char c;
74 
75  while (i < lg)
76  {
77  scanf("%c", &c);
78  if (c == '\n') break;
79  cad[i] = c;
80  i++;
81  }
82  cad[i] = 0;
83  }
84 
85 };
86 
87 
88 #endif
Clase de utilerias.
Definition: Utilerias.hpp:16
Utilerias(void)
Definition: Utilerias.hpp:25
void leerNumero(int &num)
Leer un numero entero del teclado.
Definition: Utilerias.hpp:30
void leerNumero(double &num)
Leer un numero double del teclado.
Definition: Utilerias.hpp:49
void leerCadena(char *cad, int lg)
Lee una cadena del teclado.
Definition: Utilerias.hpp:70