Results are out! Find what you need...fast. Get quick advice or join the chat
Hey there! Sign in to join this conversationNew here? Join for free

need EMERGENCY C Programming help PLEASE

Announcements Posted on
Applying to Uni? Let Universities come to you. Click here to get your perfect place 20-10-2014
    • Thread Starter
    • 0 followers
    Offline

    ReputationRep:
    hi,

    i really need some help with this task which is due tomorrow at 5pm:
    the task asks us to Write a program to take in the names of 10 people, and find the longest name. Use the gets() function to take in the peoples names so that full names (including spaces) can be stored. You should be able to enter a name of 25 characters in length.

    many thanks in advance
    • 0 followers
    Offline

    ReputationRep:
    Erm, you won't learn anything if you get other people to do your homework for you.

    Post your code and a note of which bit of it isn't working.
    • 0 followers
    Offline

    ReputationRep:
    One tip I'll give you is never use the gets() function. Use fgets() instead.
    • Thread Starter
    • 0 followers
    Offline

    ReputationRep:
    (Original post by JGR)
    Erm, you won't learn anything if you get other people to do your homework for you.

    Post your code and a note of which bit of it isn't working.
    i dont think i could write my code due to plagiarism ,i have done the 1st part but the only part im struggling with is finding the longest word ...i can't get the logic behind it and i don't know how to use strcpy.
    any help is appreciated
    thanx
    • 1 follower
    Offline

    ReputationRep:
    (Original post by arjun3)
    i dont think i could write my code due to plagiarism ,i have done the 1st part but the only part im struggling with is finding the longest word ...i can't get the logic behind it and i don't know how to use strcpy.
    any help is appreciated
    thanx
    Break it into smaller problems:
    1) Find the length of each name
    2) Find the highest length (a 'for' loop possibly)
    • Thread Starter
    • 0 followers
    Offline

    ReputationRep:
    (Original post by JoMo1)
    Break it into smaller problems:
    1) Find the length of each name
    2) Find the highest length (a 'for' loop possibly)
    i've done that but my program still doesnt work ...
    • 0 followers
    Offline

    ReputationRep:
    (Original post by arjun3)
    i dont think i could write my code due to plagiarism ,i have done the 1st part but the only part im struggling with is finding the longest word ...i can't get the logic behind it and i don't know how to use strcpy.
    any help is appreciated
    thanx
    So you're using the string library, take a look at: this

    You will need to store the names into an array to start with, then go through that array checking each length using strlen and storing the length if it is bigger than the previously known largest. As previously suggested, use a for loop.

Reply

Submit reply

Register

Thanks for posting! You just need to create an account in order to submit the post
  1. this can't be left blank
    that username has been taken, please choose another Forgotten your password?
  2. this can't be left blank
    this email is already registered. Forgotten your password?
  3. this can't be left blank

    6 characters or longer with both numbers and letters is safer

  4. this can't be left empty
    your full birthday is required
  1. By joining you agree to our Ts and Cs, privacy policy and site rules

  2. Slide to join now Processing…

Updated: February 22, 2012
New on TSR

Submitting your UCAS application

How long did it take for yours to be processed?

Article updates
Useful resources
Reputation gems:
You get these gems as you gain rep from other members for making good contributions and giving helpful advice.