Thread: code for swapping name and surname

  1. #31
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by Animesh Gaitond View Post
    how will you reverse the whole array?we are not supposed to use string library functions
    What have you been told .... ANALYSE -> PLAN -> WRITE -> TEST

    You are in school to learn how to program... not to learn how to act like a simpering little brat begging everyone else for candy.

  2. #32
    Registered User
    Join Date
    Jun 2005
    Posts
    6,815
    Quote Originally Posted by CommonTater View Post
    Anybody mut me see the hypocrisy in this?
    Just a little, yeah, muttley

    The comment that "only a student can understand another students homework blues" is also laying it on with a trowel.

    Most people here were actually students at one time, so we do actually know what it's like. We also know that, while not all "homework blues" result directly from laziness of the student, that a significant proportion actually do.

    We also know that each crop of students believes their challenges are somehow new and unique, and each also thinks that they can somehow disguise homework problems in order to trick other people into spoon-feeding them the answers.
    Right 98% of the time, and don't care about the other 3%.

    If I seem grumpy or unhelpful in reply to you, or tell you you need to demonstrate more effort before you can expect help, it is likely you deserve it. Suck it up, Buttercup, and read this, this, and this before posting again.

  3. #33
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by grumpy View Post
    Just a little, yeah, muttley
    I see my typing skills are right on average...

    Most people here were actually students at one time, so we do actually know what it's like. We also know that, while not all "homework blues" result directly from laziness of the student, that a significant proportion actually do.
    Hey, always a student... Anyone who does not learn some new skill --no matter how small-- each day isn't really living.

    We also know that each crop of students believes their challenges are somehow new and unique, and each also thinks that they can somehow disguise homework problems in order to trick other people into spoon-feeding them the answers.
    Now ain't that the truth...

  4. #34
    Registered User
    Join Date
    Dec 2007
    Posts
    2,675
    Quote Originally Posted by Salem View Post
    > anyway if you get the code,don't forget to post it for me.
    I don't know why both of you are even bothering to study.
    With exhibits A and B right here in this thread.

  5. #35
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by quzah View Post
    Unless you are doing it just to see if you can, that's a terrible idea.
    Quzah.
    Actually, reading the requirements, that's about the only option left open to him.

    Stupid assignment really... but an interesting brain teaser...

  6. #36
    [](){}(); manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    *nullptr
    Posts
    2,657
    Quote Originally Posted by CommonTater View Post
    Actually, reading the requirements, that's about the only option left open to him.

    Stupid assignment really... but an interesting brain teaser...
    I tried it in another way, but it was more complicated.

  7. #37
    Registered User
    Join Date
    May 2011
    Location
    Around 8.3 light-minutes from the Sun
    Posts
    1,949
    Quote Originally Posted by quzah View Post
    Unless you are doing it just to see if you can, that's a terrible idea.


    Quzah.
    Quote Originally Posted by whiteflags View Post
    Because with big enough string space, excluding separate strings altogether, you really could move names around and not have to reverse anything. So the way that you suggested is only better because it fits the criteria.
    And that was the point wasn't it? The criteria of the homework.
    Quote Originally Posted by anduril462 View Post
    Now, please, for the love of all things good and holy, think about what you're doing! Don't just run around willy-nilly, coding like a drunk two-year-old....
    Quote Originally Posted by quzah View Post
    ..... Just don't be surprised when I say you aren't using standard C anymore, and as such,are off in your own little universe that I will completely disregard.
    Warning: Some or all of my posted code may be non-standard and as such should not be used and in no case looked at.

  8. #38
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    Quote Originally Posted by manasij7479 View Post
    There...was it to difficult to think it out ?
    Now... a better approach would be :
    1: Reverse the whole array.
    2: Reverse the individual words.
    I like your algorithm; the one I thought up was a variation of "Animesh Gaitond" method in post #22.

    Tim S.

  9. #39
    [](){}(); manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    *nullptr
    Posts
    2,657
    Quote Originally Posted by stahta01 View Post
    I like your algorithm; the one I thought up was a variation of "Animesh Gaitond" method in post #22.

    Tim S.
    What I came up with was too.
    This was suggested by 'whiteflags' and 'AndrewHunter' .

  10. #40
    Registered User
    Join Date
    Aug 2011
    Posts
    15
    what is the method used for reversing an array without using string library function?

  11. #41
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,667
    Well since there isn't a standard C library function for reversing strings, you're on your own anyway.

    But this thread is 40 posts old, with quite a few clues.
    Isn't it about time you read the thread carefully, and actually put in some effort of your own?
    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.

  12. #42
    Registered User
    Join Date
    Aug 2011
    Posts
    15
    i tried my best but couldnt get it correctly.

  13. #43
    Registered User
    Join Date
    May 2011
    Location
    Around 8.3 light-minutes from the Sun
    Posts
    1,949
    Then POST YOUR CODE. This isn't a homework service. Additionally, did you read through the thread at all. There are many suggestions on how to do this.
    Quote Originally Posted by anduril462 View Post
    Now, please, for the love of all things good and holy, think about what you're doing! Don't just run around willy-nilly, coding like a drunk two-year-old....
    Quote Originally Posted by quzah View Post
    ..... Just don't be surprised when I say you aren't using standard C anymore, and as such,are off in your own little universe that I will completely disregard.
    Warning: Some or all of my posted code may be non-standard and as such should not be used and in no case looked at.

  14. #44
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by AndrewHunter View Post
    Then POST YOUR CODE. This isn't a homework service. Additionally, did you read through the thread at all. There are many suggestions on how to do this.
    He stands before you, hands outstretched, brain on standby, ears fully covered, waiting for answers to fall from the heavens.

  15. #45
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by CommonTater View Post
    Actually, reading the requirements
    Yeah, like I did that!
    Quote Originally Posted by CommonTater View Post
    but an interesting brain teaser...
    It is harder than it seems like it should be.


    Quzah.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. swapping help
    By mouse666666 in forum C Programming
    Replies: 3
    Last Post: 03-24-2010, 10:38 AM
  2. sort linked list by surname
    By bazzano in forum C Programming
    Replies: 5
    Last Post: 10-02-2005, 04:06 AM
  3. Printing my initials and surname
    By Guti14 in forum C++ Programming
    Replies: 2
    Last Post: 08-20-2003, 02:46 AM
  4. swapping
    By metallicaau in forum C Programming
    Replies: 2
    Last Post: 10-08-2002, 08:17 AM
  5. swapping code
    By riley03 in forum C++ Programming
    Replies: 5
    Last Post: 02-21-2002, 08:06 AM