Thread: I need help with this please (IMPORTANT)

  1. #1
    Registered User
    Join Date
    Mar 2011
    Posts
    4

    I need help with this please (IMPORTANT)

    I have this question that I don't understand how to start writing it:



    Question 6.
    "supervocalic" is a word made up by Eric Chaikin. It describes words or phrases that contain all the 5 vowels a, e, i, o and u at least once. Write a program that reads in a word or phrase and then outputs whether the word or phrase is supervocalic. The word(s) only contain lower case letters. The output required is illustrated in the following examples.
    (Take care with the last word of the output): [10]

    E. g.

    Type in a word or phrase: supervocalic
    "supervocalic" is a supervocalic word.

    or

    Type in a word or phrase: massey university
    "massey university" is not a supervocalic phrase.


    This is one of the test last year, the thing is I just wanna understand it and know how to do it so I can do any kind of these questions, thanks

  2. #2
    Registered User
    Join Date
    Sep 2008
    Posts
    200
    Well, you could start with (i) making a main() function that takes a line of input. Then have a look at the index() function - it'll tell you whether a letter is in your line. Apply for each vowel and see if all of them are true.

    If you didn't know about index(), you could always write it yourself.

  3. #3
    Registered User
    Join Date
    Mar 2011
    Posts
    21
    The question is asking you to basically do the following:

    Read in a line of input.
    --- check out the man page for 'gets'
    Check to see whether it contains all of the vowels.
    Print a statement either confirming or denying the vowel-nature.
    --- check out the man page for 'printf(3)'

    The "trick" is that they also want you to identify whether it is a word or phrase.
    --- I would do this with a conditional operator and printf.

  4. #4
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by damha View Post
    I have this question that I don't understand how to start writing it:

    This is one of the test last year, the thing is I just wanna understand it and know how to do it so I can do any kind of these questions, thanks
    Look in your C Library documentation...
    Is there a function to tell you if a string contains a certain character?

    Ok... now how might you apply that function to this task?

    Hint: You should be able to do this in less than 20 lines of code.

  5. #5
    Registered User
    Join Date
    Dec 2007
    Posts
    2,675
    check out the man page for 'gets'
    No, never!!!! gets() is unsafe and should never be used. Instead, use fgets().

  6. #6
    Registered User
    Join Date
    Mar 2011
    Posts
    21
    Quote Originally Posted by rags_to_riches View Post
    No, never!!!! gets() is unsafe and should never be used. Instead, use fgets().
    Yo, simmer. If you read the man page for gets it will point that out, and point you to fgets. This is clearly a class/learning type situation here. A little headache now will lead to a better programmer in the future.

  7. #7
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by FrankTheKneeMan View Post
    Yo, simmer. If you read the man page for gets it will point that out, and point you to fgets. This is clearly a class/learning type situation here. A little headache now will lead to a better programmer in the future.
    Translation: "I made a mistake and don't want to admit it."

    Frank... we all make errors and 'round here you get tagged for them... and guess what, it makes us better programmers so long as we don't dig in our heels and start tripping over our pride.

  8. #8
    Registered User
    Join Date
    Nov 2010
    Location
    Long Beach, CA
    Posts
    5,909
    Quote Originally Posted by JohnGraham View Post
    Well, you could start with (i) making a main() function that takes a line of input. Then have a look at the index() function - it'll tell you whether a letter is in your line. Apply for each vowel and see if all of them are true.

    If you didn't know about index(), you could always write it yourself.
    I believe index() is a bit outdated and non-standard. strchr() would be a better bet, since it behaves identically to index() and is part of the standard library.

  9. #9
    Registered User
    Join Date
    Mar 2011
    Posts
    21
    Quote Originally Posted by CommonTater View Post
    Translation: "I made a mistake and don't want to admit it."

    Frank... we all make errors and 'round here you get tagged for them... and guess what, it makes us better programmers so long as we don't dig in our heels and start tripping over our pride.
    I appreciate errors, and lord knows I make my fair share of them, but I was serious. Judging from the language, damha is in a class - likely an "Intro to C" how "C programming skills" class. There's a huge note in the "Bugs" section of the manual about how you should never use gets(). It's the same reason I point all my friends to the atoi man page instead of strtol. If someone hands you the exact method you need every time you need it, you'll never learn to use the tools in front of you. I live off of man and apropos, and I think people should be made aware of how to use them properly. I come to this board specifically because people don't spoon-feed their help, and I was trying to step in time to that. Sorry it came off wrong.

  10. #10
    Registered User
    Join Date
    Dec 2007
    Posts
    2,675
    We try to break these newcomers of their bad habits (which in many cases are being actively taught to them) ASAP, so any suggestion of something like this will certainly get called out as being a bad one.

    In any event, welcome

  11. #11
    Registered User
    Join Date
    Mar 2011
    Posts
    21
    Been searching these threads on and off for a year or two. Only started posting a week or so ago. Thanks for the welcome.

    Sorry to hijack your thread there, damha - did you figure it out or do you need more?

  12. #12
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by FrankTheKneeMan View Post
    I appreciate errors, and lord knows I make my fair share of them, but I was serious. Judging from the language, damha is in a class - likely an "Intro to C" how "C programming skills" class. There's a huge note in the "Bugs" section of the manual about how you should never use gets(). It's the same reason I point all my friends to the atoi man page instead of strtol. If someone hands you the exact method you need every time you need it, you'll never learn to use the tools in front of you. I live off of man and apropos, and I think people should be made aware of how to use them properly. I come to this board specifically because people don't spoon-feed their help, and I was trying to step in time to that. Sorry it came off wrong.
    Hey, no worries...

    Your strategy is ok, but don't forget a lot of the people who come here can barely operate computers, never mind knowing how to dig out man pages and write decent code.

    As R2R points out, often these bad habits are being actively taught in schools by professors running off decades old course outlines... At least one school is still using 16 bit TurboC and teaching about 8085 processors...

    The general strategy here is to point out why these things are bad and offer them a better alternative... because we KNOW they're not going to click the links or read the help files.

    And don't even get me started on "Scoop and Poop" coding...
    Last edited by CommonTater; 04-06-2011 at 10:34 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. For me is very important Please...
    By pitkini in forum C++ Programming
    Replies: 3
    Last Post: 07-26-2005, 02:49 AM
  2. What Is Important In Making Games?
    By Krak in forum C++ Programming
    Replies: 6
    Last Post: 05-07-2004, 08:12 PM
  3. &...how important?
    By CAP in forum C Programming
    Replies: 1
    Last Post: 07-16-2002, 02:02 AM
  4. Most important element of a game?
    By Eber Kain in forum Game Programming
    Replies: 24
    Last Post: 01-11-2002, 03:04 PM
  5. Replies: 2
    Last Post: 12-08-2001, 11:10 PM