Ver Mensaje Individual
  #1 (permalink)  
Antiguo 03/09/2013, 08:18
fcosun
 
Fecha de Ingreso: octubre-2011
Mensajes: 153
Antigüedad: 12 años, 6 meses
Puntos: 7
mostrar string distinto en una misma variable en C ?

hola, como puedo hacer que al ingresar un numero, muestre un string ? me dice error, aca tengo el código.

Código C:
Ver original
  1. #include <stdio.h>
  2. #include <conio.h>
  3. #include <string.h>
  4.  
  5. int main() {
  6.    
  7.     int sexo = 0;
  8.     char tiposexo[10];
  9.    
  10.     printf("Ingrese un sexo: \"1\" para Hombre \"2\" para Mujer: ");
  11.     scanf("%d", & sexo);   
  12.    
  13.     if(sexo == 1){
  14.         tiposexo = "Hombre";
  15.     }else
  16.     {
  17.         tiposexo = "Mujer";
  18.     }  
  19.    
  20.     printf("El sexo es: %s ", tiposexo);
  21.    
  22.     return 0;
  23. }
__________________
Mi mail: [email protected]