+ Reply to Thread
Results 1 to 18 of 18

Thread: HERP!!!!     submit to reddit submit to twitter

  1. #1
    Sea Torques
    Join Date
    Jul 2005
    Posts
    641
    BG Level
    5

    HERP!!!!

    Code:
      j=palabrarandom();
      strcpy(pala,pal[j]);//Copies word selected randomly to pala
    When I compile, i get the following msg:

    passing arg 2 of `strcpy' makes pointer from integer without a cast


    >< I can't figure out what's wrong, plz help me!!!!

  2. #2
    Physicist
    Join Date
    Feb 2005
    Posts
    4,493
    BG Level
    7
    FFXIV Character
    Raineer Severus
    FFXIV Server
    Hyperion
    FFXI Server
    Siren
    WoW Realm
    Area 52

    JP Button

  3. #3

    I know this will get said sooner or later but to hell with that.

    Do your own homework.

  4. #4
    Sea Torques
    Join Date
    Jul 2005
    Posts
    641
    BG Level
    5

    Im trying to Elcura, this is why Im asking for help. My programming teacher hasn't arrived and no one knows what's wrong with it. Thus why I sought help here.

  5. #5
    Physicist
    Join Date
    Feb 2005
    Posts
    4,493
    BG Level
    7
    FFXIV Character
    Raineer Severus
    FFXIV Server
    Hyperion
    FFXI Server
    Siren
    WoW Realm
    Area 52

    It looks like a circular reference to me, but christ I don't even know what language you are programming in.

    C++,,VB,Pascal,jesuslolomz it all runs together too much >_<

  6. #6
    Relic Shield
    Join Date
    Apr 2005
    Posts
    1,572
    BG Level
    6

    I'm no fishing expert, but I don't think Strcpy can be caught using Integer bait. I don't know how much Integer costs, but I think you might as well bite the bullet and cast your line and find out.

  7. #7
    Saint Daahan Von Quitter the 1st
    Patron of Yin

    Join Date
    Mar 2005
    Posts
    4,719
    BG Level
    7

    try yelling at it

  8. #8
    Sea Torques
    Join Date
    Jul 2005
    Posts
    641
    BG Level
    5

    it's plain and simple C -.- forgot to mention sorry.

  9. #9

    Quote Originally Posted by Elcura
    I know this will get said sooner or later but to hell with that.

    Do your own homework.
    You can't say that unless you've never asked for help on your own work, ever.

  10. #10

    Would help if you posted more of the program. I don't even know what type that array pal is declared as, or what type pala is.

  11. #11
    Sea Torques
    Join Date
    Jul 2005
    Posts
    641
    BG Level
    5

    Code:
    /*
    PRACTICA 2
    MODULO 1
    Laura Perez Mendoza
    */
    
    #include <stdio.h>
    #include <string.h>
    #include <stdlib.h>
    #include <time.h>
    
    /*Prototipos*/
    void print_monito(int);
    int palabrarandom(void);
    char aleatorio();
    char juego();
     
    /*Variables*/
    int j,h,i,u,p;
    int vidas=5;
    char let; //Caracter ingresado por usuario
    char pala[101]; //Palabra a encontrar
    char temp[101]=""; //Temporal
    char pal[101];
    
    int main()
    {
      system("clear");	
      printf("Este programa fue hecho, deshecho, odiado y aborrecido por Laura Perez Mendoza\n");
      getchar( );
      do{
        printf("COLGADO :D\n\n1.- Comenzar Juego.\n2.- Salir.");
        scanf ("%d", &u);
        switch(u){
        case 1: //Ejecuta el juego
          aleatorio();
          for (h=0;h<strlen(pala);h++) //Imprime '?' de la palabra a buscar
    	{
    	  temp[h]='?';
    	}
          printf ("\n\n");
          juego();
          break;
        case 2: exit(1); //Sale del programa
        default: printf ("Tienes que elegir una de las opciones!!\n"); main(); //En caso de elegir opcion incorrecta
        }	 
      }while(u!=2);
    } 
    
    
    char aleatorio()//Elige una palabra aleatoriamente
    {
      int j;
      char pal[101] = {"mundo", "vertiente", "programa", "casa", "tarjeta", "cosa",
    		  "computadora", "programacion", "", "monitor", "mina", "parka",
    		  "scanner", "nieve", "powpow", "carrete", "ventana", "chao",
    		  "hola", "tarro", "mueble", "bicicleta", "chile", "hola",
    		  "musica", "pantalon", "juegos", "poker", "teclado", "auto"};
    
      j=palabrarandom();
      strcpy(pala,pal[j]);//Copia palabra a encontrar en pala
    }//aleatorio
    
    int palabrarandom(void)
    {
      static int firstcall=1;
      if(firstcall){
        srand((unsigned int) time(NULL));
        firstcall=0;
      }
      return (rand( )%30+1);
    }//random
    
    /*
    PRACTICA 2
    MODULO 2
    */
    
    char juego()
    {
      system("clear");
      printf ("Te quedan %d vidas\n", vidas);
      print_monito(vidas); //Imprime el monito de acuerdo a las vidas que quedan
      printf ("La palabra a descubrir tiene %d letras\n", strlen(pala));
      printf ("Intenta adivinar, ingresa una letra\n");
      for (h=0;h<strlen(pala);h++)
        {
          printf ("%c ",temp[h]);//Imprime los caracteres descubiertos, en caso contrario imprime '?'
        }
      printf ("\n");
      scanf(" %c",&let);
      i=0; //Contador para comprobar si el jugador acierta o no
      for(h=0;h<strlen(pala);h++){
        if (pala[h]==let) //Comprueba si algun caracter de la palabra a buscar es igual al caracter ingresado
          {	
    	temp[h]=let; //Copia el caracter en temp
    	if (strcmp(pala,temp)!=0){
    	  i++;
    	}
    	else{
    	  printf("Ganaste! Felicitaciones\n");
    	  return 0;
    	}
          }
      }
      if (i>0){
        juego(); //Con i mayor a 0 el juego continua
      }
      else{
        vidas--; //Se descuenta una vida
        if (vidas==0)
          {
    	printf ("\n\n");
    	printf ("Perdiste, se acabaron tus vidas, intentalo de nuevo.\n");
    	print_monito(vidas);
    	printf ("La palabra a encontrar era: %s\n\n", pala);
          }
        else juego(); //Si aun quedan vidas, el juego continua
      }
    }//juego
    
    
    
    
    void print_monito(int v) //Imprime el monito
    {
      printf(" ______      \n |");
      if(v<5) printf("    _L_");printf("\n |");
      if(v<5) printf("   /o o\\");printf("\n |");
      if(v<5) printf("   \\___/");printf("\n |");
      if(v<4) printf("     |");printf("\n |");
      if(v<4) printf("   --+");
      if(v<3) printf("--");printf("\n |");
      if(v<2) printf("     |");printf("\n |");
      if(v<2) printf("    /");
      if(v<1) printf(" \\");printf("\n |      \n_|_  /\\/\\/\\   \n\n");
    }//printmonito
    Well I didn't include the code cuz most is in spanish and I figured it wouldn't help if you couldn't understand but uh... commands are same no matter language so maybe you can help.

  12. #12

    lol i didn't want the whole program. just the declarations of those 2 variables.

    Code:
    char pala[101]; //Palabra a encontrar 
    char pal[101]; 
    
    ...
    
    char aleatorio()//Elige una palabra aleatoriamente 
    { 
      int j; 
      char pal[101] = {"mundo", "vertiente", "programa", "casa", "tarjeta", "cosa", 
            "computadora", "programacion", "", "monitor", "mina", "parka", 
            "scanner", "nieve", "powpow", "carrete", "ventana", "chao", 
            "hola", "tarro", "mueble", "bicicleta", "chile", "hola", 
            "musica", "pantalon", "juegos", "poker", "teclado", "auto"}; 
    
      j=palabrarandom(); 
      strcpy(pala,pal[j]);//Copia palabra a encontrar en pala 
    }//aleatorio
    The call to strcpy is using the global variable pal. Change the function aleatorio to be something like this:

    Code:
    char aleatorio()//Elige una palabra aleatoriamente 
    { 
      int j; 
      char pal_local[101] = {"mundo", "vertiente", "programa", "casa", "tarjeta", "cosa", 
            "computadora", "programacion", "", "monitor", "mina", "parka", 
            "scanner", "nieve", "powpow", "carrete", "ventana", "chao", 
            "hola", "tarro", "mueble", "bicicleta", "chile", "hola", 
            "musica", "pantalon", "juegos", "poker", "teclado", "auto"}; 
    
      j=palabrarandom(); 
      strcpy(pala,pal_local[j]);//Copia palabra a encontrar en pala 
    }//aleatorio
    Also there is another syntax error which I don't really know why it's compiling at all. it should be

    Code:
      char* pal_local[101] = {"mundo", "vertiente", "programa", "casa", "tarjeta", "cosa", 
            "computadora", "programacion", "", "monitor", "mina", "parka", 
            "scanner", "nieve", "powpow", "carrete", "ventana", "chao", 
            "hola", "tarro", "mueble", "bicicleta", "chile", "hola", 
            "musica", "pantalon", "juegos", "poker", "teclado", "auto"};

  13. #13
    Sea Torques
    Join Date
    Jul 2005
    Posts
    641
    BG Level
    5

    I tried that and it still gave me the same error

  14. #14

    I just compiled the following code successfully:

    Code:
    void f()
    {
    	int j=5;
    	char* pal_local[101] = {"mundo", "vertiente", "programa", "casa", "tarjeta", "cosa", 
            "computadora", "programacion", "", "monitor", "mina", "parka", 
            "scanner", "nieve", "powpow", "carrete", "ventana", "chao", 
            "hola", "tarro", "mueble", "bicicleta", "chile", "hola", 
            "musica", "pantalon", "juegos", "poker", "teclado", "auto"}; 
    	char pala[101];
    	strcpy(pala, pal_local[j]);
    }
    Are you sure you went through the correct procedure to rebuild the C file into the obj file and everything? Put some junk code that earlier up in the file that you know will fail for a different reason, then recompile and see if it gives you a different error. Just so that you can check if the compiler is even using the correct code. Then copy/paste the function above into your file and see if it works, because I just tested it on my computer and that function worked fine.

  15. #15
    Sea Torques
    Join Date
    Jul 2005
    Posts
    641
    BG Level
    5

    the whole problem was that stupid asterisk. Ty Divisortheory, u just saved my grade.

  16. #16
    Physicist
    Join Date
    Feb 2005
    Posts
    4,493
    BG Level
    7
    FFXIV Character
    Raineer Severus
    FFXIV Server
    Hyperion
    FFXI Server
    Siren
    WoW Realm
    Area 52

    void print_monito(int v) //Imprime el monito
    {
    printf(" ______ \n |");
    if(v<5) printf(" _L_");printf("\n |");
    if(v<5) printf(" /o o\\");printf("\n |");
    if(v<5) printf(" \\___/");printf("\n |");
    if(v<4) printf(" |");printf("\n |");
    if(v<4) printf(" --+");
    if(v<3) printf("--");printf("\n |");
    if(v<2) printf(" |");printf("\n |");
    if(v<2) printf(" /");
    if(v<1) printf(" \\");printf("\n | \n_|_ /\\/\\/\\ \n\n");
    }//printmonito
    This looks like it prints a melee Redmage. Your program fails.

  17. #17
    Sea Torques
    Join Date
    Jul 2005
    Posts
    641
    BG Level
    5

    its a hangman

  18. #18
    Relic Weapons
    Join Date
    Jul 2005
    Posts
    331
    BG Level
    4

    Quote Originally Posted by Raineer
    (" ______ \n |")(" _L_")("\n |")(" /o o\\")("\n |")(" \\___/")("\n |")(" |")("\n |")(" --+")("--")("\n |")(" |")("\n |")(" /")(" \\")
    This looks like it prints a melee Redmage. Your program fails.
    No, it's obviously supposed to be someone dancing, but putting it in SMART PEOPLE SPEAK messed it up. Here, allow me to translate.

    "\(^_____^ "\) ( ^_L_^) "\(n_n"\) ( /o.o\) "\(n_n"\) CHA-CHA-CHA!

Similar Threads

  1. Replies: 38
    Last Post: 2010-08-26, 09:05