SoloCodigo
Programación General => C/C++ => Mensaje iniciado por: macht en Lunes 15 de Diciembre de 2008, 23:02
Título:
Como validar datos en c/c++
Publicado por:
macht
en
Lunes 15 de Diciembre de 2008, 23:02
He estado probando códigos y e logrado validar números enteros pero no e podido lograr que diferencie entre letras mayúsculas y minúsculas como hago
Título:
Re: Como validar datos en c/c++
Publicado por:
shakka
en
Martes 16 de Diciembre de 2008, 05:29
Código: C
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char
*
toUpper
(
const
char
*
string
)
{
char
*
c
;
int
top
;
int
i
;
c
=
NULL
;
if
(
string
!=
NULL
)
{
top
=
strlen
(
string
)
;
c
=
(
char
*
)
malloc
(
(
top
+
1
)
*
sizeof
(
char
*
)
)
;
i
=
0
;
while
(
i
<
top
)
{
if
(
(
string
[
i
]
>=
'a'
)
&&
(
string
[
i
]
<=
'z'
)
)
c
[
i
]
=
(
string
[
i
]
-
32
)
;
else
c
[
i
]
=
string
[
i
]
;
i
=
(
i
+
1
)
;
}
c
[
i
]
=
''
;
}
return
c
;
}
Ya sabras como implementarlo -_-
Código: C
int
main
(
)
{
char
*
s
;
int
i
;
i
=
0
;
s
=
toUpper
(
"algo"
)
;
// mmm ...
while
(
i
<
strlen
(
s
)
)
{
printf
(
"%c"
,
s
[
i
]
)
;
i
=
(
i
+
1
)
;
}
return
0
;
}
Título:
Re: Como validar datos en c/c++
Publicado por:
shakka
en
Martes 16 de Diciembre de 2008, 06:16
Código: C
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char
*
toUpper
(
const
char
*
string
)
{
char
*
c
;
int
top
;
int
i
;
c
=
NULL
;
if
(
string
!=
NULL
)
{
i
=
0
;
top
=
strlen
(
string
)
;
c
=
(
char
*
)
malloc
(
(
top
+
1
)
*
sizeof
(
char
*
)
)
;
if
(
c
!=
NULL
)
{
while
(
i
<
top
)
{
if
(
(
string
[
i
]
>=
'a'
)
&&
(
string
[
i
]
<
=
'z'
)
)
c
[
i
]
=
(
string
[
i
]
-
32
)
;
else
c
[
i
]
=
string
[
i
]
;
i
=
(
i
+
1
)
;
}
c
[
i
]
=
''
;
}
}
return
c
;
}
ya lo modifique otra vez :brickwall:, que vida que vida !@$ :hitcomp:
Título:
Re: Como validar datos en c/c++
Publicado por:
shakka
en
Martes 16 de Diciembre de 2008, 06:18
para la otra, ya te habras dado cuenta como decia mi profesor que es igual pero diferente :devil: <_<
Título:
Re: Como validar datos en c/c++
Publicado por:
shakka
en
Martes 16 de Diciembre de 2008, 20:21
Corregido
http://radamanthys.homelinux.org/?p=123 (http://radamanthys.homelinux.org/?p=123" onclick="window.open(this.href);return false;)
Título:
Re: Como validar datos en c/c++
Publicado por:
macht
en
Miércoles 17 de Diciembre de 2008, 14:12
Gracias por los ejemplos y el consejo hasta la proxima