Thread: Modular design help

  1. #1
    Registered User
    Join Date
    Apr 2008
    Posts
    1

    Modular design help

    My question has been answered.


    Thankyou so much for the help, i now understand the error of my ways =)
    Last edited by Shadowflame; 04-01-2008 at 03:26 AM.

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Code:
    void GetOptions(char)	
    {
    	
            char letter;
    	scanf("%c%*c", &letter);
    	return(letter);
    	
    }
    A void return type means that you tell the compiler "this function returns nothing", yet you have a return(letter) at the end of the function.

    Code:
    getquestions()
    
    float l1, l2, l3;
    			
                                                                                                                                                Line 79 error 6
    {
    	printf("Enter the length of side A");
    	scanf("%f%*c", &l1);                                                                                                   line 82 error 7
    	printf("/nEnter the length of side B");
    	scanf("%f%*c", &l2);
    	printf("Enter the length of side C");
    	scanf("%f%*c", &l3);
    	return(char letter);
    								
    }
    You are using old-style declaration of arguments - but i think you meant to declare l1, l2 and l3 as local variables - which leads to the question of how you wish to get the answers out of the function. Perhaps you want to pass a set of pointers to float to the function, and fill those in...

    "return (char letter)" is definitely very wrong. If we assume that it was compilable, then it would mean "create a variable of type char called letter, then return it" - without giving it any value, so it would return rubbish.

    The function getquestions() hasn't been declared before DoOption, so it complains about that too.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    > My question has been answered.
    Please don't edit your post down to nothing after you've got an answer. It makes the thread useless to anyone who reads it in future.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. which design is better to wrap another class instance
    By George2 in forum C++ Programming
    Replies: 7
    Last Post: 04-13-2008, 12:27 AM
  2. Implementing Inheritence into your design
    By bobthebullet990 in forum C++ Programming
    Replies: 6
    Last Post: 08-05-2006, 04:40 PM
  3. Modular
    By loopshot in forum Game Programming
    Replies: 7
    Last Post: 01-20-2006, 07:24 PM
  4. Modular Division problem
    By Malek in forum C++ Programming
    Replies: 7
    Last Post: 05-24-2003, 06:08 PM