Thread: 2 function prototypes

  1. #1
    Registered User
    Join Date
    May 2006
    Posts
    17

    2 function prototypes

    i am trying to come up with function prototypes for 2 functions. here is what i have:

    1. a function Symbol() that takes a character value x and returns a
    Boolean value.

    2. a function that displays 3 spaces to the standard output stream
    cout.

    answers

    Code:
    1. bool Symbol(char c);
    
    2. void three_spaces(   );
    are these correct?

  2. #2
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,079
    Well... yes, but I have a few questions. First off, #1 says a character value x, which even though x is just a generic symbol for a value of the variable, I would take as saying the char identifier should be x. You made it c. There is nothing wrong with that, but for the sake of being explicit, the identifier x might be better. That's just me, though.

    For #2, I couldn't help but notice you have 3 spaces in between your parenthesis. Did you think that had anything to do with how it would output the three spaces? It's correct because it doesn't take arguments as it shouldn't, but when you don't have any arguments it's best that you just write
    Code:
    void func();
    // ...or better yet
    void func(void);
    Sent from my iPadŽ

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    > a function that displays 3 spaces to the standard output stream
    As in being able to write
    cout << "hello" << three_spaces() << "world" << endl;
    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.

  4. #4
    Registered User
    Join Date
    May 2006
    Posts
    17
    thank you the c was just a typo it should have been x

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  2. Question about function prototypes
    By Mikecore in forum C Programming
    Replies: 2
    Last Post: 11-20-2005, 05:39 PM
  3. Problem with Visual C++ Object-Oriented Programming Book.
    By GameGenie in forum C++ Programming
    Replies: 9
    Last Post: 08-29-2005, 11:21 PM
  4. Question..
    By pode in forum Windows Programming
    Replies: 12
    Last Post: 12-19-2004, 07:05 PM
  5. c++ linking problem for x11
    By kron in forum Linux Programming
    Replies: 1
    Last Post: 11-19-2004, 10:18 AM