Thread: Need some help:(

  1. #1
    Registered User
    Join Date
    Jun 2008
    Posts
    114

    Need some help:(

    Code:
    for(;;)
       {
           if(gender =='F')
           {
              Sleep(2000);
              system("cls"); //Old man says players gender
              size=strlen(oldman1); 
              for(x=0;x<size;x++) 
              {   
                Sleep(50);  
                printf("%c",oldman1[x]);
                
              }
               size=strlen(daughter);
                for(x=0;x<size;x++)          
                {
                    printf("%c",daughter[x]);
                    Sleep(50);                 
                }  
                break;                                     
           }
           else if(gender =='M')
           {
              Sleep(2000);
              system("cls"); //Old man says players gender
              size=strlen(oldman1); 
              for(x=0;x<size;x++) 
              {   
                 Sleep(50);  
                 printf("%c",oldman1[x]);
                
              }
              size=strlen(son);
                for(x=0;x<size;x++)          
                {
                    printf("%c",son[x]);
                    Sleep(50);                 
                } 
                break;
           }
       }
      size=strlen(oldman2); 
      for(x=0;x<size;x++) 
      {   
           Sleep(50);  
           printf("%c",oldman2[x]); 
      }
    For some reason it only says the first 3 letters on the oldman char string and goes to the next one
    Last edited by Nathan the noob; 02-08-2009 at 11:32 PM.

  2. #2
    Registered User
    Join Date
    Jun 2008
    Posts
    114
    Nvm fixed

  3. #3
    Registered User QuestionKing's Avatar
    Join Date
    Jan 2009
    Posts
    68
    Well there areas of code not posted which could cause that. For example you are using the length of 'oldman1' to run your loop, at the time the loop is ran, what is the value of 'oldman1'...?

  4. #4
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    5,108
    Code:
              size=strlen(oldman1); 
              for(x=0;x<size;x++) 
              {   
                Sleep(50);  
                printf("%c",oldman1[x]);
              }
    Code:
                size=strlen(daughter);
                for(x=0;x<size;x++)          
                {
                    printf("%c",daughter[x]);
                    Sleep(50);                 
                }
    Code:
              size=strlen(oldman1); 
              for(x=0;x<size;x++) 
              {   
                 Sleep(50);  
                 printf("%c",oldman1[x]);
              }
    Code:
                size=strlen(son);
                for(x=0;x<size;x++)          
                {
                    printf("%c",son[x]);
                    Sleep(50);                 
                }
    Code:
      size=strlen(oldman2); 
      for(x=0;x<size;x++) 
      {   
           Sleep(50);  
           printf("%c",oldman2[x]); 
      }
    Seriously?! O_o

    Don't you think that just maybe that deserves a function unto itself? O_o

    Even something casually dangerous would be better than writing nearly the same thing over and over.

    Soma

    Code:
    int slowprintf
    (
       unsigned int msdelay_f,
       const char * format_f,
       ...
    )
    {
       char message_buffer[1024];
       char * character = message_buffer;
       int characters_written;
       va_list vargs;
       if(0 == format_f)
       {
          return(-1);
       }
       va_start(vargs, format_f);
       characters_written = vsprintf(message_buffer, format_f, vargs);
       if(0 < characters_written)
       {
          while(0 != *character)
          {
             fputc(*character, stdout);
             mydelay(msdelay_f);
             ++character;
          }
       }
       va_end(vargs);
       return(characters_written);
    }

  5. #5
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    And why is this on C++?
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

Popular pages Recent additions subscribe to a feed