Thread: very very simple question....

  1. #1
    Registered User
    Join Date
    Oct 2007
    Posts
    51

    very very simple question....

    Hi there im in my very first semester of c-programing at uni doing some study at the moment on past exam and im stuck on this question.. well i sorta know it but im wondering what your take on it is.. any help would be much appreciated.

    ......
    Q1, Write a function prototype of a function that dose not return a value and has a single string as an argument.
    ......

    so im thinking of like a void prototype for a function im obviously going to make.. however im not sure how to translate the bit where it dose not return a value and has a string for an argument.??
    Last edited by webznz; 10-22-2007 at 10:23 PM. Reason: spelling error

  2. #2
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by webznz View Post
    so im thinking of like a void prototype for a function im obviously going to make.. however im not sure how to translate the bit where it dose not return a value and has a string for an argument.??
    You're not being asked to make a function, just to make a prototype. You already have half of it right, since you say you should make a "void prototype." The only other part is the single parameter which is a string. So... Figure out what type a "string" should be and you have your answer.

  3. #3
    Registered User
    Join Date
    Oct 2007
    Posts
    51
    okay then so this would be.

    void my_name (char name, "jack");

    void is the prototype, my_name is the function name and char name is the argument with jack as the string.. is that right?.... :S i been reading though my book and notes thats what i have come up with.
    Last edited by webznz; 10-22-2007 at 10:56 PM. Reason: corrected code.

  4. #4
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,005
    Quote Originally Posted by webznz View Post
    Q1, Write a function prototype of a function that dose not return a value and has a single string as an argument.
    Code:
    void foo(char *);
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  5. #5
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by webznz View Post
    okay then so this would be.

    void my_name (char name, "jack");

    void is the prototype, my_name is the function name and char name is the argument with jack as the string.. is that right?.... :S i been reading though my book and notes thats what i have come up with.
    "char name" means a single char, not a string of chars. If you look in your book for the section on Strings you should see the correct type to use (it's based on char, but not just "char").

    And because this is a prototype, you don't actually pass a parameter, so the "jack" part is not needed.

  6. #6
    Registered User
    Join Date
    Oct 2007
    Posts
    51
    okay! thanks guys! lol youll probably see abit of me round here soon! this place is real helpful.. especilly listening to other problems are seeing how they are solved! thanks agaIN! time to go eat a banana! food for the braiN! lol

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Simple question regarding variables
    By Flakster in forum C++ Programming
    Replies: 10
    Last Post: 05-18-2005, 08:10 PM
  2. Simple class question
    By 99atlantic in forum C++ Programming
    Replies: 6
    Last Post: 04-20-2005, 11:41 PM
  3. Simple question about pausing program
    By Noid in forum C Programming
    Replies: 14
    Last Post: 04-02-2005, 09:46 AM
  4. simple question.
    By InvariantLoop in forum Windows Programming
    Replies: 4
    Last Post: 01-31-2005, 12:15 PM
  5. simple fgets question
    By theweirdo in forum C Programming
    Replies: 7
    Last Post: 01-27-2002, 06:58 PM