Join TSR now and chat about whatever you’re intoSign up now

need EMERGENCY C Programming help PLEASE Watch

    • Thread Starter
    Offline

    0
    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
    Offline

    0
    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.
    Offline

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

    0
    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
    Offline

    1
    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
    Offline

    0
    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 ...
    Offline

    0
    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.
 
 
 
Poll
How are you feeling about Results Day?
Useful resources

The Student Room, Get Revising and Marked by Teachers are trading names of The Student Room Group Ltd.

Register Number: 04666380 (England and Wales), VAT No. 806 8067 22 Registered Office: International House, Queens Road, Brighton, BN1 3XE

Quick reply
Reputation gems: You get these gems as you gain rep from other members for making good contributions and giving helpful advice.