Ver Mensaje Individual
  #2 (permalink)  
Antiguo 27/08/2014, 22:41
Avatar de Drewermerc
Drewermerc
 
Fecha de Ingreso: febrero-2014
Mensajes: 185
Antigüedad: 10 años, 2 meses
Puntos: 5
Respuesta: Dudas de un trabajo

Hola amigo.
Bueno pues lo único que te hace falta son las librerías y en la formas como usas un printf por lo que tu código quedaría así.
app.h
Código C:
Ver original
  1. #ifndef APP_H_
  2. #define APP_H_
  3.  
  4. #include <stdio.h>
  5. #include <string.h>
  6.  
  7. #define MAX_CAD 256
  8.  
  9. typedef char Cadena[MAX_CAD];
  10. typedef enum {ANDROID, IOS, WINDOWS} TipoSO;
  11.  
  12. TipoSO cadenaAtipoSO(const Cadena soCad);
  13.  
  14. #endif /* APP_H_ */

app.c
Código C:
Ver original
  1. #include "app.h"
  2. #include <stdio.h>
  3. #include <string.h>
  4. #include <stdlib.h>
  5. TipoSO cadenaAtipoSO(const Cadena soCad){
  6.    TipoSO res;
  7.    if(strcmp(soCad, "ANDROID") == 0){
  8.       res = ANDROID;
  9.    }
  10.    else if(strcmp(soCad, "IOS") == 0){
  11.       res = IOS;
  12.    }
  13.    else if(strcmp(soCad, "WINDOWS") == 0){
  14.       res = WINDOWS;
  15.    }else{
  16.       printf("\nSistema operativo erróneo***");
  17.       exit(-1);
  18.    }
  19.    return res;
  20. }

test.c
Código C:
Ver original
  1. #include "app.h"
  2. #include <stdio.h>
  3.  
  4. void testcadenaAtipoSO();
  5.  
  6. int main(void){
  7.    testcadenaAtipoSO();
  8.    return 0;
  9. }
  10.  
  11. void testcadenaAtipoSO(){
  12.    Cadena str = "WINDOWS";
  13.    TipoSO n;
  14.     n =cadenaAtipoSO(str);
  15.    printf("%d\n",n);
  16.    printf("COMPLETADO\n");
  17. }

Bueno espero te sea de ayuda.
Saludos.
Drewermerc.