Thread: Assignment Help (II)

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User camel-man's Avatar
    Join Date
    Jan 2011
    Location
    Under the moon
    Posts
    693
    Our TA's showed us this exactly. The value of i is in the for loop im pretty sure.
    The for loop comes after your declaration of your array, so how could it possibly know the value of i? Either your TA's made a mistake or they are testing you and waiting on you to catch it on your own.

  2. #2
    Registered User
    Join Date
    Nov 2012
    Posts
    29
    Quote Originally Posted by camel-man View Post
    The for loop comes after your declaration of your array, so how could it possibly know the value of i? Either your TA's made a mistake or they are testing you and waiting on you to catch it on your own.
    They demonstrated and it worked fine.. Unless it should be declared as dashes[7] (since there can only be 6 dashes maximum) and my mind conveniently swapped that out with "i"

  3. #3
    Registered User camel-man's Avatar
    Join Date
    Jan 2011
    Location
    Under the moon
    Posts
    693
    Quote Originally Posted by ADH94 View Post
    .. Unless it should be declared as dashes[7] (since there can only be 6 dashes maximum) and my mind conveniently swapped that out with "i"

    That seems more likely.

  4. #4
    Registered User
    Join Date
    Nov 2012
    Posts
    29
    Ok so I've done some tinkering and most of the issues lie in the draw function. Here's what i've done.. sorry if it offends your expert eyes haha

    Code:
    #include <stdio.h>#include <string.h>
    
    
    int draw_guess(int length, char guess, char word[]) //the function draws the unguessed letters (dashes) and updates it when guessed correctly
    {
        //Draws the dashes
        int i, startup;
        char display[7];
        
        if(startup != 1)
            startup = 0;
    
    
        //Updates the dashes with the properly guessed letters 
        if((startup = 1))//only goes after the initial dashes are printed
        {   
            for(i=0; i<length; i++)
            {
                if(word[i] == guess)
                {
                    display[i] = guess;
                    
                    printf("%s", display[i]);
                }
                
                else return 1; //if an incorrect letter is guessed, the function returns 1
        }
    
    
        else//this is just to print the initial dashes
        {
            for(i=0; i<length; i=i+)
            {
                display[i] = 'i';
                
                printf("%s", display[i]);
            }
        }
        startup = 1;
        
    }
    Since each possibility needs a return value, but I only care about when it is false, would just assigning a different return value change what the "correct guess" part of the assignment displays?

    My compiler is giving some warnings that I dont quite understand either..

    A syntax error in line 30 before the ) token

    both printf("%s blah blah) parts come up saying argument is not a pointer

    line 37 type defaults to "int" in declaration of startup
    Last edited by ADH94; 11-24-2012 at 09:10 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Assignment help
    By Rastafarian in forum C# Programming
    Replies: 3
    Last Post: 01-09-2011, 07:33 AM
  2. Replies: 3
    Last Post: 04-26-2009, 08:54 AM
  3. First assignment help
    By FirstC++ in forum C++ Programming
    Replies: 7
    Last Post: 07-01-2004, 07:57 AM
  4. Help With Assignment Please
    By MegaVortex in forum C++ Programming
    Replies: 8
    Last Post: 03-24-2004, 09:40 PM
  5. course assignment
    By kesam in forum C Programming
    Replies: 1
    Last Post: 01-06-2003, 01:51 PM