passing counters between function

This is a discussion on passing counters between function within the C Programming forums, part of the General Programming Boards category; Hi there, people less ignorant than I. I'm fairly new to programming and am stuck. I sure could use your ...

  1. #1
    Registered User
    Join Date
    Feb 2004
    Posts
    26

    passing counters between function

    Hi there, people less ignorant than I. I'm fairly new to programming and am stuck. I sure could use your help.

    The program below builds a house by asking a user for the number of floors and the type of siding that the user chooses from a menu. The house is then printed out and the user is asked if he wants to build again.
    I had the program complete, but my professor didn't want me to initialize anything globally and instead wants me to do them all in the main. But now I run across the problem of having to initialize in each function the char or int was used in, and this re-initializes my counter, so I can no longer print the correct number of floors. I am guessing I have to use a pointer, but I am having trouble passing it between functions. I have browsed through the pointer tutorial on this site and in my book without help. I'm just completely out of ideas. So I removed the pointers so it would at least compile, and the result is below. Any advice would be helpful. Thanks.
    Code:
    /* Rob  -  Home.c */
    
    #include <stdio.h>
    #include <stdlib.h>
    #include <ctype.h>
    
    void process();      // call for process function
    void intro();        // call for intro function
    void roof();         // call for roof function
    void floors();       // call for floors function
    void ground();       // call for ground function
    void sidingType();   // call for siding type function
    
    int main()           //main function
    {                    //begin intro
    char play;           // initializing characer for play
    
         printf("\tWelcome to...\n");
         printf("\tBUILD YOUR DREAMHOUSE!\n\n");
         printf("\tBy: Rob's Construction Co.\n");
         printf("\tYou plan it, we build it!\n\n");
         printf("\tWant to start planning? y/n ");  //prompt for answer from user
         scanf("%c", &play);     //scanning answer from user
         fflush(stdin);          //flushing keyboard input
              if (play == 'y')     //begin if "yes"
              {
                  process();           //call for process
              } //end if
              else                // begin if "no"
              {
                   system("cls");   // clear screen
                   printf("\t   Thanks for using Rob's Construction.\n");    //ending
                   printf("\tDon't forget to tell your friends about us!\n\n");
    
                   system("PAUSE");
                   return 0;       //end program
              }  //end else
    }      // end main
    
    void process()        // main process
    
    {                     // start process
          intro();        // starting intro and objective
          sidingType();   // call for siding type and conversion
          roof();         // call for roof
          floors();       // call for floors including loop
          ground();       // call for ground
    }                     // end process
    
    void intro()          // intro & objective, and call for floor number
    {
    int numFloors ;   //number of floors
    
         system("cls");
         printf("\t\t BUILD YOUR OWN HOME!!\n\n");     //start objective
         printf("\tThe purpose of this program is to demonstrate the four ways to use\n");
         printf("\ta function(), Switch/Case and pointers. This project will finish the\n");
         printf("\tintroduction of Structure, Selection and Looping you learned in\n");
         printf("\tCOP1000 Data structures and Algorithms class and apply how it\n");
         printf("\tapplies to the C programming language.\n\n");
         printf("\tThis program asks you for the number of floors, and type of siding\n\n");
         printf("\tHow many floors would you like your house to be? "); //prompt for # of floors
         scanf("%d", &numFloors);   // scan # of floors and add to numFloors
         fflush(stdin);
         printf("\t\n\n");
    }  //end intro
    
    void sidingType()   // siding menu and concversion to type char
    {                   //start sidingType
    char siding;         // initializing characer for left side
    char siding2;        // initializing characer for right side
    int sidingChoice;    // storing siding preference
    
         system("cls");      //new screen
         printf("\t PLEASE CHOOSE YOUR SIDING TYPE:  \n\n");       //siding options
         printf("\t  \n");
         printf("\t 1. Straight (boring) siding | | \n");
         printf("\t 2. Brick (hurricane strength) siding [ ] \n");
         printf("\t 3. Log (Lincoln style) siding ( ) \n");
         printf("\t 4. Stucko (too cheap for brick) siding { } \n");
         printf("\t 5. X (whatever this is) siding X X \n");
         printf("\t 6. Shinge (poop on a) siding / \\ \n\n");
         printf("\t Please enter your siding preference:  ");
         scanf("%d", &sidingChoice);    //read user siding preference
         fflush(stdin);
         printf("\t\n\n");
              switch( sidingChoice ) {     //start switch for conversion
              case 1: siding = '|'; siding2 = '|'; break;     // conversion to straight
              case 2: siding = '['; siding2 = ']'; break;     // conversion to brick
              case 3: siding = '('; siding2 = ')'; break;     // conversion to log
              case 4: siding = '{'; siding2 = '}'; break;     // conversion to stucko
              case 5: siding = 'X'; siding2 = 'X'; break;     // conversion to x
              case 6: siding = '/'; siding2 = '\\'; break;    // conversion to shingle
              default: printf("Invalid option selected, straight assigned\n");
              siding = '|'; siding2 = '|';
              }      //end switch
    }            // end siding type
    
    void roof()  // function roof
    {            // start roof
    int numFloors;   //number of floors
         system("cls");
         printf("\t                                                        \n");
         printf("\t                                     ,~ ~~ ,~ ~~~       \n");
         printf("\t                                 ,~ ~~ ~ ~~  ,~ ~~~~~   \n");
         printf("\t                                 ~~~ ,~ ~ ~~  ~  ~~     \n");
         printf("\t                       ^       ,~ ~~ ,~ ~~~     \n");
         printf("\t                      /_\\    _______           \n");
         printf("\t                     /___\\   |__|__|           \n");
         printf("\t                    /__|__\\  |_|__||           \n");
         printf("\t                   /_|___|_\\ |__|__|           \n");
         printf("\t                  /|___|___|\\|_|__||           \n");
         printf("\t                 /|__|___|__|\\__|__|           \n");
         printf("\t                /__|___|___|__\\|__||           \n");
         printf("\t               /_|___|___|___|_\\|__|           \n");
         printf("\t              /|___|___|___|___|\\_||           \n");
         printf("\t             /__|TOTAL FLOORS|___\\_|           \n");
         printf("\t            /__|___|_     _|___|__\\|           \n" );
         printf("\t           /_|___|___|___|___|___|_\\           \n");
         printf("\t          /-------------------------\\          \n");
    }               //end roof
    
    void floors()   //function floors with loop for # of floors
    {
    char siding;         // initializing characer for left side
    char siding2;        // initializing characer for right side
    int floorCount = 1;  // initializing counter to 1
    int numFloors =0;   //number of floors
    
         for( floorCount>1; floorCount < numFloors; floorCount++)  //for loop
            {
            printf("\t          %c                         %c\n", siding, siding2);
            printf("\t          %c                         %c\n", siding, siding2);
            printf("\t          %c     |---|     |---|     %c\n", siding, siding2);
            printf("\t          %c     |   |     |   |     %c\n", siding, siding2);
            printf("\t          %c     |---|     |---|     %c\n", siding, siding2);
            printf("\t          %c                         %c\n", siding, siding2);
            printf("\t          %c                         %c\n", siding, siding2);
            printf("\t          %c                         %c\n", siding, siding2);
            printf("\t          %c                         %c\n", siding, siding2);
            printf("\t          %c-------------------------%c\n", siding, siding2);
            }              //end floor
    }                 // end floors
    
    void ground()     // function ground
    {                 // start ground
    char siding;         // initializing characer for left side
    char siding2;        // initializing characer for right side
    char play;           // initializing characer for play
    
         printf("\t          %c                         %c\n", siding, siding2);
         printf("\t          %c      GROUND FLOOR       %c\n", siding, siding2);
         printf("\t          %c            1            %c\n", siding, siding2);
         printf("\t          %c        /======\\         %c\n", siding, siding2);
         printf("\t          %c         |----|          %c\n", siding, siding2);
         printf("\t          %c         |    |          %c\n", siding, siding2);
         printf("\t          %c         |   .|          %c\n", siding, siding2);
         printf("\t          %c         |    |          %c     \n", siding, siding2);
         printf("\t   @  @   %c         |    |          %c   @  @ \n", siding, siding2);
         printf("\t___|__|___%c-------------------------%c___|__|___ \n", siding, siding2);
         printf("\t '    .    '     . /      \\    '      .   '       \n");
         printf("\t   '         '    /        \\                 .    \n");
         printf("\t .  ~   '   '    /          \\   '   '    '     .  \n");
         printf("\t     '  .      ./            \\    .     .  ~       \n");
         printf("\t  '        '   /              \\    '         '    \n");
         printf("\t  .|Rob|'  '  /                \\.  ~  '|Rob   | \n");
         printf("\t================================================ \n\n\n");
         printf(" Would you like to build another house? y/n  ");
         scanf("%c", &play);     // read  player's response to playing again
         fflush(stdin);
    
              if (play == 'y')       // if statement for play again
              {
                  process();           // call for prosess
              }                    //end if
              else                // statement for not playing again
             {
                 system("cls");
                 printf("\t   Thanks for using Rob's Construction.\n");
                 printf("\tDon't forget to tell your friends about us!\n\n");
    
                 system("PAUSE");
             }  //end else
    }      // end ground

  2. #2
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    Code:
    fflush(stdin);
    Why this is bad

    The are multiple ways to do what you want.
    1) Pass a pointer for the function to change
    2) Have the function return the value.

    As an example lets change the function that gets the number of floors.
    1) Change the prototypes: int intro(void); and void floors(int);
    2) Change the call: num_floors = intro(); (remember to declare num_floors inside of process() )
    3) Change intro() to return the value by putting return numFloors; at the end of the function.
    4) change the call of floors to floors(num_floors)

    If you have a function that needs to modify two variables you can put them inside of a struct or just pass a pointer. For example the sidingType() function

    1) Change the prototype void sidingType(char *, char *);
    2) Change the function call sidingType(&side_left, &side_right); again making sure to declare these two variables in process.
    3) Change sidingTypes():
    a) change the function header to void sidingType(char *l, char *r)
    b) at the end of the function add: (*l)=siding; (*r)=siding2;
    4) Change ground() to accept these:
    a) prototype ground(char, char);
    b) header ground(char siding, char siding2);
    c) remove local variables siding and siding2;
    d) change call to ground(side_left, side_right)

    These are only examples but from here you should be able to modify the program to work with all the functions.

  3. #3
    Registered User
    Join Date
    Feb 2004
    Posts
    26
    I've posted a few things here (during the new server update it lost record of my registration) and every time I've posted, I've been told about the fflush. Unfortunately, I'm always told why it's wrong, but never what to substitute for it. I was once given a link that was supposed to help, but I never found anything that was an understandable answer. Most posts and tutorials are never written in layman's terms so that the average person (me) can understand them. I'm usually more lost than I was when I started. Any suggestions that a newbie like me could use?

  4. #4
    Deleted Account
    Join Date
    Jan 2004
    Posts
    40
    Code:
    while ((ch = getchar()) != '\n' && ch != EOF);
    flushy flushy

    http://faq.cprogramming.com/cgi-bin/...&id=1043284392

  5. #5
    Registered User
    Join Date
    Feb 2004
    Posts
    26
    After trying the suggestions above, I am way more lost than I was before. Now instead of it compiling, I get 31 errors for my efforts. I didn't even understand what I was doing to begin with so that makes it harder for me to fix.
    I'm normally a patient person, but after 20 hours on this one project in 1 week's time, I feel like giving up and taking an F. I don't think I'd be as frustrated if it weren't for the fact that I had it working just fine, but my professor wants me to use pointers intead of initializing everything globally. So I get to start all over. So much for me being proud of myself.
    The one thing I never understood is why in tutorials, books, and replies on message boards that no one speaks in easy to understand terms that someone that is new would understand with something that resembles an explainantion to go with it. It always seems like all explainations and replies are done as if I should already know the answers. I understand the need to actually learn instead of having someone do it for you, but I come here as a last resort after reading the book, lecture notes, tutorials and trying every idea I can come up with because I don't understand the concepts. And when I finally ask for help, I don't ever get anyone to show me anything with an explaination to go with it so I can say, "Ahhh yes...I get it now! Thanks!". I get stuff that is over my head. Remember, I'm a newbie. I've only been doing this 6 weeks, and the code above is a lot for someone this new.
    I know I'm complaining for people trying to help me, but I'm just too frustrated with this, and I'm sure I'm not the only one that gets irritated by the throwing around of stuff that is obviously too much for someone in need of help to grasp. I don't care if people help me or not anymore. I'm sure they won't. It's too late anyway, because I'm sure to fail this project. Close to 20 hours of my time for absolutely nothing. Just please keep this post in mind when another ignorant person like me needs help.
    Don't try to impress them with your knowledge. Teach them with your skill at a level they will understand.

  6. #6
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    You do realize that what I gave you includes what needs to be changed and how to change it.
    Also the description of your experience in the orginal post is extremely vague. "Fairly new" could be someone hows done as an on-again-off-again hobby for years.
    We also are not code monkeys that will just give out the code. We try to explain it as best we can but if you don't understand what we are saying you also have to ask for clarification.

    So here is what I suggest: Copy the errors to a text file and put that file and the modified source file into a zip file and attached it so that we can see what the problems are.

    Your professor is making you not use global variables because they are generally a less desirable way of passing data between functions.

    Now to further explain what I was suggesting:
    Example A: Passing an integer from main() to a function (for the sake of length I'll skip the #include declarations)
    Code:
    void test(int); /* Function test returns nothing and it takes one argument of type int */
    int main(void)
    {
      int x=5;
      test (x); /* Call function test and pass the value of x to it */
      return 0;
    }
    void test (int a) /* Put the value of the first argument into a local variable a of type int.
    {
      printf("%d\n", a);
    }
    Example B: Passing a pointer to an integer so that the function can change the value
    Code:
    void test(int *); /* Function tests returns nothing and it takes one argument that is a pointer to an integer */
    int main(void)
    {
      int x=5;
      printf("Before %d\t", x);
      test(&x); /* The & means to pass the address of x and not the value */
      printf("After %d\n", x);
      return 0;
    }
    void test (int *a)
    {
      (*a) = 10; /* the (*) around the variable means to dereference the pointer.  Basically go to the address specified by the pointer and change the value there */
    }
    Example C: Have a function return the value of an int
    Code:
    int test(void); /*Test returns an int and accepts 0 arguments */
    int main(void)
    {
      int x=1;
      printf("Before %d\t", x);
      x = test();
      printf("After %d\n", x);
      return 0;
    }
    int test(void)
    {
      a = 5;
      return a;  /* Return the value of local variable a */
    }
    Ok any more questions or anything else that needs to be clarified?

  7. #7
    Registered User
    Join Date
    Feb 2004
    Posts
    26
    Oh yeah, the point of all of that was because I had only one problem with my code, and it wasn't adressed in any way, shape, or form. I wanted help with getting the number of floors to populate because it kept re-initializing the counter like I had it. The reply to my initial post didn't address it at all. Instead, it made me rework something that was already working just fine to start with and didn't help with my problem or question. Don't fix what ain't broke, especially if it is just a neato-impressive way for me to try to translate it into something that might be deemed useful. In fact, what was addressed was more difficult than what I asked for. And pointless. Didn't just waste my time, it wasted your own. Direct answers are always better. Ask anyone else in the world.

  8. #8
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    I had the program complete, but my professor didn't want me to initialize anything globally and instead wants me to do them all in the main. But now I run across the problem of having to initialize in each function the char or int was used in, and this re-initializes my counter, so I can no longer print the correct number of floors. I am guessing I have to use a pointer, but I am having trouble passing it between functions.
    Did I not give an EXAMPLE of how to pass a pointer between functions. In fact I stated
    These are only examples but from here you should be able to modify the program to work with all the functions.
    Also you should know the chance of anyone actually reading 150ish lines for one problem is about zilch. So instead of getting all ........y because I didn't answer the exact problem why don't you state the problem a little more clearly. This is what I got from skimming your program:
    1) main() basically does crap besides post a welcome screen
    2) process() is what calls all other functions
    3) intro() gets the number of floors but doesn't store them anywhere permeant thus it needs to be passed back to the caller
    4) sidingTypes() gets the sides and assigns a value to them, again it doesn't store them anywhere permeant and thus needs to be passed back to the caller. Since there were two variables doing two pass by pointers would be better
    5) the other floors don't get values from the user and need to have values passed to them

    Thus from that I made my posts.

    Note: Found this while doing this post:
    Code:
     for( floorCount>1; floorCount < numFloors; floorCount++)  //for loop
    the first part of a for loop is assignment and not evaulations. As such it should be
    Code:
    for ( floorCount =;floorCount < numFloors; floorCount++)

  9. #9
    Registered User
    Join Date
    Feb 2004
    Posts
    26
    Even from the part you copied and posted, it says my pointer problem only lies with my counter and how a pointer is probably needed for my counter so it doesn't keep reinitializing. I thought that was adequately clear. I did not discuss problems with my siding, so they should not have been adressed. Now that portion of my program doesn't even work. At the bottom of my original posted question, I specifically stated I removed anything having to do with my attempts at using a pointer so it would compile in case anyone trying to help wanted to compile it real quick and get an idea of what it is supposed to do instead of having to fixing it, then looking at it. Logical sequence in my inexperienced mind. I did it to help. Probably wrong of me, but my intentions were good.
    My complaint about the inability to understand the help came from any help I have received from this board from anyone in the last 6 weeks (about 5 people). The "further" explaination on pointers that was sent in reply to my complaint was ironically the exact same thing I was complaining about. A copy in paste from a page without an explaination to the parts. Everyone gives newbies too much credit and think we speak the same binary language as you, but unfortunately, we don't. We just learned what a compiler is, so therefore we are unable to look at 15 lines of code that is indirectly related to something and go, "Yes, this means this, that and the other'. I can't interpret code alone into English words. Sorry.
    I am not unappreciative of the fact that people scan these boards on their free time in order to help people in their time of need. I think it says a lot for your good nature of wanting to help. I just think the help could be better and put forth in an easy to understand way. Without that, it is all pointless. That's all. No need to post a reply again. I've said my piece. Peace.

  10. #10
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    My complaint about the inability to understand the help came from any help I have received from this board from anyone in the last 6 weeks (about 5 people).
    You do realize that in the last 6 weeks the boards have been pretty much been down 75% of that time.

    No need to post a reply again. I've said my piece. Peace.
    Is the program working? If not then we aren't done. Now the counter.. do you mean that after the first iteration of the entire program then user should not be asked how many floors again?

    Again I used the siding because it was a great case for showing how to pass pointers. If its not needed there then don't use it. sorry for not being clear enough.

    Also I try to address any problems I see with code. I expect the same in reverse when I ask problems.

  11. #11
    Registered User
    Join Date
    Feb 2004
    Posts
    26
    I'm aware of getting the new server caused problems. I got help the first 2 weeks of class with a stoplight project I did. Somehow with the migration it lost my registration...lost my posts, user name, everything. No biggie...I reregistered, and got my old name back.

    As for the program, I got it to compile with your info, but it messes up the siding and I have to change it back. The problem I had was this:
    The program asks the user for how many floors they would like their house to be, and this is incremented by the middle section as the ground and roof are constants that will not change. I can't get the floors to add up because since I have to redeclare the floors and counter in each function using these, I end up losing the information from the user input because it resets the counter every time.
    But as for the program, no it doesn't work, but I am through. It's almost 2am here, and I have to get up early to be at the college campus to see if I can find someone willing to help me that can point and say do this, and this is why you do this. Now watch what happens, now you do the next part to see if you got what I mean. I'm here when you get stuck.
    I'd rather not fail this class. It's my last one to graduate. It's due monday and I have a full time job on top of other classes, too. I've already spent literally a whole day on it. I can't keep wasting time like that. So I'm done with this board. Thanks anyway(I mean it sincerely).

  12. #12
    Registered User
    Join Date
    Feb 2004
    Posts
    72
    Seems to work. (It doesn't show the number of floors on the roof and doesn't handle 0 floors correctly)
    You can debug it yourself.
    Sidings have to be pointers because you have two of them but can only return 1 value;

    replace //comment with /*comment*/

    Code:
    #include <stdio.h>
    #include <stdlib.h>
    #include <ctype.h>
    
    void process();      
    int intro();        
    void roof();   
    void floors(char, char, int);       
    void ground(char, char);       // call for ground function
    void sidingType(char *, char *);   // call for siding type function
    
    int main()           //main function
    {                    //begin intro
    char play;           // initializing characer for play
    
         printf("\tWelcome to...\n");
         printf("\tBUILD YOUR DREAMHOUSE!\n\n");
         printf("\tBy: Rob's Construction Co.\n");
         printf("\tYou plan it, we build it!\n\n");
         printf("\tWant to start planning? y/n ");  //prompt for answer from user
         scanf("%c", &play);     //scanning answer from user
         fflush(stdin);          //flushing keyboard input
              if (play == 'y')     //begin if "yes"
              {
                  process();           //call for process
    			  return 0;
              } //end if
              else                // begin if "no"
              {
                   system("cls");   // clear screen
                   printf("\t   Thanks for using Rob's Construction.\n");    //ending
                   printf("\tDon't forget to tell your friends about us!\n\n");
    
                   system("PAUSE");
                   return 0;       //end program
              }  //end else
    }   
    
    void process()        // main process
    
    {     
    	  int numFloors;
    	  char siding, siding2;
          numFloors= intro();     
          sidingType(&siding, &siding2);
          roof();         
          floors(siding, siding2, numFloors);       
          ground(siding, siding2);       
    }                     
    
    int intro()          // intro & objective, and call for floor number
    {
    int numFloors ;   //number of floors
    
         system("cls");
         printf("\t\t BUILD YOUR OWN HOME!!\n\n");     //start objective
         printf("\tThe purpose of this program is to demonstrate the four ways to use\n");
         printf("\ta function(), Switch/Case and pointers. This project will finish the\n");
         printf("\tintroduction of Structure, Selection and Looping you learned in\n");
         printf("\tCOP1000 Data structures and Algorithms class and apply how it\n");
         printf("\tapplies to the C programming language.\n\n");
         printf("\tThis program asks you for the number of floors, and type of siding\n\n");
         printf("\tHow many floors would you like your house to be? "); //prompt for # of floors
         scanf("%d", &numFloors);   // scan # of floors and add to numFloors
         fflush(stdin);
         printf("\t\n\n");
    	 return numFloors;
    }  
    void sidingType(char *siding, char *siding2)  
    {                   //start sidingType
            
    int sidingChoice;    // storing siding preference
    
         system("cls");      //new screen
         printf("\t PLEASE CHOOSE YOUR SIDING TYPE:  \n\n");       //siding options
         printf("\t  \n");
         printf("\t 1. Straight (boring) siding | | \n");
         printf("\t 2. Brick (hurricane strength) siding [ ] \n");
         printf("\t 3. Log (Lincoln style) siding ( ) \n");
         printf("\t 4. Stucko (too cheap for brick) siding { } \n");
         printf("\t 5. X (whatever this is) siding X X \n");
         printf("\t 6. Shinge (poop on a) siding / \\ \n\n");
         printf("\t Please enter your siding preference:  ");
         scanf("%d", &sidingChoice);    //read user siding preference
         fflush(stdin);
         printf("\t\n\n");
              switch( sidingChoice ) {     //start switch for conversion
              case 1: *siding = '|'; *siding2 = '|'; break;     // conversion to straight
              case 2: *siding = '['; *siding2 = ']'; break;     // conversion to brick
              case 3: *siding = '('; *siding2 = ')'; break;     // conversion to log
              case 4: *siding = '{'; *siding2 = '}'; break;     // conversion to stucko
              case 5: *siding = 'X'; *siding2 = 'X'; break;     // conversion to x
              case 6: *siding = '/'; *siding2 = '\\\'; break;
              default: printf("Invalid option selected, straight assigned\n");
              *siding = '|'; *siding2 = '|';
              }      //end switch
    }            // end siding type
    
    void roof()  // function roof
    {            // start roof
    
         system("cls");
         printf("\t                                                        \n");
         printf("\t                                     ,~ ~~ ,~ ~~~       \n");
         printf("\t                                 ,~ ~~ ~ ~~  ,~ ~~~~~   \n");
         printf("\t                                 ~~~ ,~ ~ ~~  ~  ~~     \n");
         printf("\t                       ^       ,~ ~~ ,~ ~~~     \n");
         printf("\t                      /_\\    _______           \n");
         printf("\t                     /___\\   |__|__|           \n");
         printf("\t                    /__|__\\  |_|__||           \n");
         printf("\t                   /_|___|_\\ |__|__|           \n");
         printf("\t                  /|___|___|\\|_|__||           \n");
         printf("\t                 /|__|___|__|\\__|__|           \n");
         printf("\t                /__|___|___|__\\|__||           \n");
         printf("\t               /_|___|___|___|_\\|__|           \n");
         printf("\t              /|___|___|___|___|\\_||           \n");
         printf("\t             /__|TOTAL FLOORS|___\\_|           \n");
         printf("\t            /__|___|_     _|___|__\\|           \n" );
         printf("\t           /_|___|___|___|___|___|_\\           \n");
         printf("\t          /-------------------------\\          \n");
    }               //end roof
    
    void floors(char siding, char siding2, int numFloors)   //function floors with loop for # of floors
    {
      int floorCount;
    
         for( floorCount=1; floorCount < numFloors; floorCount++)  //for loop
            {
            printf("\t          %c                         %c\n", siding, siding2);
            printf("\t          %c                         %c\n", siding, siding2);
            printf("\t          %c     |---|     |---|     %c\n", siding, siding2);
            printf("\t          %c     |   |     |   |     %c\n", siding, siding2);
            printf("\t          %c     |---|     |---|     %c\n", siding, siding2);
            printf("\t          %c                         %c\n", siding, siding2);
            printf("\t          %c                         %c\n", siding, siding2);
            printf("\t          %c                         %c\n", siding, siding2);
            printf("\t          %c                         %c\n", siding, siding2);
            printf("\t          %c-------------------------%c\n", siding, siding2);
            }              //end floor
    }                 // end floors
    
    void ground(char siding, char siding2)     // function ground
    {                 // start ground
           // initializing characer for right side
    char play;           // initializing characer for play
    
         printf("\t          %c                         %c\n", siding, siding2);
         printf("\t          %c      GROUND FLOOR       %c\n", siding, siding2);
         printf("\t          %c            1            %c\n", siding, siding2);
         printf("\t          %c        /======\\         %c\n", siding, siding2);
         printf("\t          %c         |----|          %c\n", siding, siding2);
         printf("\t          %c         |    |          %c\n", siding, siding2);
         printf("\t          %c         |   .|          %c\n", siding, siding2);
         printf("\t          %c         |    |          %c     \n", siding, siding2);
         printf("\t   @  @   %c         |    |          %c   @  @ \n", siding, siding2);
         printf("\t___|__|___%c-------------------------%c___|__|___ \n", siding, siding2);
         printf("\t '    .    '     . /      \\    '      .   '       \n");
         printf("\t   '         '    /        \\                 .    \n");
         printf("\t .  ~   '   '    /          \\   '   '    '     .  \n");
         printf("\t     '  .      ./            \\    .     .  ~       \n");
         printf("\t  '        '   /              \\    '         '    \n");
         printf("\t  .|Rob|'  '  /                \\.  ~  '|Rob   | \n");
         printf(" \t================================================\n\n\n");
         printf(" Would you like to build another house? y/n  ");
         scanf("%c", &play);     // read  player's response to playing again
         fflush(stdin);
    
              if (play == 'y')       // if statement for play again
              {
                  process();           // call for prosess
              }                    //end if
              else                // statement for not playing again
             {
                 system("cls");
                 printf("\t   Thanks for using Rob's Construction.\n");
                 printf("\tDon't forget to tell your friends about us!\n\n");
    
                 system("PAUSE");
             }  //end else
    }      // end ground
    Last edited by major_blagger; 02-21-2004 at 03:11 PM.

  13. #13
    Registered User
    Join Date
    Feb 2004
    Posts
    26
    Thank you for your efforts. However, it doesn't compile. There is numerous errors.
    Please see last post by me above. 24 hours (literally) is too much to spend on any one thing, especially something as pointless as this project. My time is valuable, so I have given up on this project. No more assistance is needed. Please don't waste your time on this, unless you are practicing to keep your own chops up.

  14. #14
    Registered User
    Join Date
    Feb 2004
    Posts
    46
    24 hours (literally) is too much to spend on any one thing
    I have spent over 24 hours working on a single function before. Not back to back of course, but a programming task can indeed take a great deal of time.

    My time is valuable, so I have given up on this project.
    What will you do when you have problems with your next project? Will you continue to give up whenever difficulty arises?

  15. #15
    Registered User
    Join Date
    Feb 2004
    Posts
    72
    Originally posted by BungleSpice
    Thank you for your efforts. However, it doesn't compile. There is numerous errors.
    Please see last post by me above. 24 hours (literally) is too much to spend on any one thing, especially something as pointless as this project. My time is valuable, so I have given up on this project. No more assistance is needed. Please don't waste your time on this, unless you are practicing to keep your own chops up.
    Didn't realise the posting would change the code...
    Line 93 should be case 6: *siding = '/'; *siding2 = '\\\'; break;
    Join lines 163, 164 (where the line overruns)


    Edit:
    Having just seen that your question was clearly answered in the first reply it's obvious that you have put zero effort into working out the solution. Often this kind of minimum effort approach takes significantly more time in the end ... as you have discovered.
    Last edited by major_blagger; 02-21-2004 at 01:08 PM.

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 4
    Last Post: 05-13-2011, 09:28 AM
  2. Compiling sample DarkGDK Program
    By Phyxashun in forum Game Programming
    Replies: 6
    Last Post: 01-27-2009, 03:07 AM
  3. Passing a byte and its bits to a function
    By rtarbell in forum C Programming
    Replies: 9
    Last Post: 12-04-2008, 09:24 AM
  4. Please Help - Problem with Compilers
    By toonlover in forum C++ Programming
    Replies: 5
    Last Post: 07-23-2005, 11:03 AM
  5. Passing a function to a function
    By lend0g in forum C++ Programming
    Replies: 1
    Last Post: 03-18-2003, 10:16 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21