
DUDA: ¿strupr funciona en Linux?
Publicado por agner alexis (2 intervenciones) el 05/05/2018 21:51:22
Buenas compañeros.
Miren tengo un problema estoy manejando C en Linux específicamente Ubuntu 16.04 LTS y quiero convertir una cadena a mayúsculas pero al compilar me aparecen errores-warnings acerca de la función "strupr" y quisiera saber si existe una solución a ese problema.
En Windows si funciona esa funcion pero me paso a Linux y deja de funcionar esa funcion para convertir las cadenas a mayusculas.
Con solución seria una diferente a convertir carácter por carácter en una función.
Les muestro mi codigo y los warning que me salen.
Adjunto la parte del codigo donde tengo problemas.
Al ejecutar el archivo en la linea de comandos me salen los siguientes mensajes:
(Linea donde compilo mi codigo) gcc Proyecto_Final.c -o Pfinal
Proyecto_Final.c: In function ‘Leer_Materias’:
Proyecto_Final.c:348:5: warning: implicit declaration of function ‘gets’ [-Wimplicit-function-declaration]
gets(apunta->Clave);
^
Proyecto_Final.c:357:28: warning: implicit declaration of function ‘strupr’ [-Wimplicit-function-declaration]
strcpy(apunta->Clave, strupr(apunta->Clave));
^
Proyecto_Final.c:357:28: warning: passing argument 2 of ‘strcpy’ makes pointer from integer without a cast [-Wint-conversion]
In file included from Proyecto_Final.c:3:0:
/usr/include/string.h:125:14: note: expected ‘const char * restrict’ but argument is of type ‘int’
extern char *strcpy (char *__restrict __dest, const char *__restrict __src)
^
Proyecto_Final.c: In function ‘Eliminar_materia’:
Proyecto_Final.c:423:22: warning: passing argument 2 of ‘strcpy’ makes pointer from integer without a cast [-Wint-conversion]
strcpy(Clave_elim, strupr(Clave_elim));
^
In file included from Proyecto_Final.c:3:0:
/usr/include/string.h:125:14: note: expected ‘const char * restrict’ but argument is of type ‘int’
extern char *strcpy (char *__restrict __dest, const char *__restrict __src)
^
/tmp/ccOZAQjT.o: En la función `Leer_Materias':
Proyecto_Final.c:(.text+0xa21): aviso: the `gets' function is dangerous and should not be used.
Proyecto_Final.c:(.text+0xa87): referencia a `strupr' sin definir
/tmp/ccOZAQjT.o: En la función `Eliminar_materia':
Proyecto_Final.c:(.text+0xbce): referencia a `strupr' sin definir
collect2: error: ld returned 1 exit status
Al mostrar esos Warnings no me compila el programa.
Espero puedan ayudame.
Gracias.
Saludos
Miren tengo un problema estoy manejando C en Linux específicamente Ubuntu 16.04 LTS y quiero convertir una cadena a mayúsculas pero al compilar me aparecen errores-warnings acerca de la función "strupr" y quisiera saber si existe una solución a ese problema.
En Windows si funciona esa funcion pero me paso a Linux y deja de funcionar esa funcion para convertir las cadenas a mayusculas.
Con solución seria una diferente a convertir carácter por carácter en una función.
Les muestro mi codigo y los warning que me salen.
Adjunto la parte del codigo donde tengo problemas.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
typedef struct datos{
char Clave[9];
char Nombre[51];
int Nivel;
int Creditos;
struct datos *sig;
}catalogo;
/*
La funcion de tipo catalogo es para leer el datos de una materia y para guardar los datos en una lista ligada-enlazada simple, recibe
*/
catalogo *Leer_Materias(catalogo *inicio){
catalogo *apunta;
catalogo *actual;
catalogo *compara;
char opc;
int tam;
int Existe;
do{
apunta= (catalogo *) malloc(sizeof(catalogo));
if (apunta==NULL)
printf ("\nNo se pudo asignar espacio.");
else{
//Lectura de la clave de la materia
do{
fflush(stdin);
printf("\nInserte la Clave de la materias (Ejemplo: FGUS 001):\n");
gets(apunta->Clave);
printf("\n\tPresione enter para continuar.");
getchar();
tam = strlen(apunta->Clave);
printf("\nTamaño: %d\n", tam);
puts(apunta->Clave);
if(tam != 8)
printf("\n\tError: La matricula debe de contener 8 caracteres.\n");
else{
strcpy(apunta->Clave, strupr(apunta->Clave));
compara = inicio;
Existe = Existe_Clavemat(apunta, compara);
}
}while(tam != 8 || Existe != 0);
//Lectura de el nombre de la materia
/*Existe = 0;
do{
fflush(stdin);
printf("\nInserta el nombre de la materia:\n->");
gets(apunta->Nombre);
printf("\n\tPresione enter para continuar.");
getchar();
compara = inicio;
Existe = Existe_NombreMat(apunta, compara);
} while(Existe != 0);
//Lectura del nivel de la materias
do{
fflush(stdin);
printf("\nInserta el nivel de la materia 1 = Basico, 2 = Formativo\n->");
scanf("%d", &apunta->Nivel);
if((apunta->Nivel != 1) && (apunta->Nivel != 2))
printf("\n\tError: Nivel de la materia invalido. Intentelo nuevamente.\n");
}while((apunta->Nivel != 1) && (apunta->Nivel != 2));
//Lectura de los creditos de la materia
do{
fflush(stdin);
printf("\nInserta los creditos de la materia (4 o 6):\n->");
scanf("%d", &apunta->Creditos);
if(apunta->Creditos != 4 && apunta->Creditos != 6)
printf("\n\tError: Creditos invalidos. Intentelo nuevamente.\n");
}while(apunta->Creditos != 4 && apunta->Creditos != 6);
*/
apunta->sig = NULL;
if (inicio==NULL)
inicio=apunta;
else{
actual = inicio;
while(actual->sig != NULL) {
actual=actual->sig;
}
actual->sig = apunta;
}
opc = Repetir();
if(opc == 's' || opc == 'S')
printf("\n\tInserte el dato siguiente: \n");
}
}while(opc == 's' || opc == 'S');
return (inicio);
}
Al ejecutar el archivo en la linea de comandos me salen los siguientes mensajes:
(Linea donde compilo mi codigo) gcc Proyecto_Final.c -o Pfinal
Proyecto_Final.c: In function ‘Leer_Materias’:
Proyecto_Final.c:348:5: warning: implicit declaration of function ‘gets’ [-Wimplicit-function-declaration]
gets(apunta->Clave);
^
Proyecto_Final.c:357:28: warning: implicit declaration of function ‘strupr’ [-Wimplicit-function-declaration]
strcpy(apunta->Clave, strupr(apunta->Clave));
^
Proyecto_Final.c:357:28: warning: passing argument 2 of ‘strcpy’ makes pointer from integer without a cast [-Wint-conversion]
In file included from Proyecto_Final.c:3:0:
/usr/include/string.h:125:14: note: expected ‘const char * restrict’ but argument is of type ‘int’
extern char *strcpy (char *__restrict __dest, const char *__restrict __src)
^
Proyecto_Final.c: In function ‘Eliminar_materia’:
Proyecto_Final.c:423:22: warning: passing argument 2 of ‘strcpy’ makes pointer from integer without a cast [-Wint-conversion]
strcpy(Clave_elim, strupr(Clave_elim));
^
In file included from Proyecto_Final.c:3:0:
/usr/include/string.h:125:14: note: expected ‘const char * restrict’ but argument is of type ‘int’
extern char *strcpy (char *__restrict __dest, const char *__restrict __src)
^
/tmp/ccOZAQjT.o: En la función `Leer_Materias':
Proyecto_Final.c:(.text+0xa21): aviso: the `gets' function is dangerous and should not be used.
Proyecto_Final.c:(.text+0xa87): referencia a `strupr' sin definir
/tmp/ccOZAQjT.o: En la función `Eliminar_materia':
Proyecto_Final.c:(.text+0xbce): referencia a `strupr' sin definir
collect2: error: ld returned 1 exit status
Al mostrar esos Warnings no me compila el programa.
Espero puedan ayudame.
Gracias.
Saludos
Valora esta pregunta


0