question about strings

This is a discussion on question about strings within the C++ Programming forums, part of the General Programming Boards category; One problem is your misuse of the name variable. In your code posted, it is an array of 33 string ...

  1. #16
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,799
    One problem is your misuse of the name variable. In your code posted, it is an array of 33 string objects but when you read it in from the user you say getline(cin,name); which is wrong. Look closely at Hammer's 2nd post, the name variable has been made a single string and not an array of them. With the use of the name variable as an array, the call to your search function shouldn't work because your function definition takes a single string as the third argument but you are passing it an array.

    You can also double check your sorting routine by outputing the entire array after it has been sorted to make sure the sort has happened correctly. If this isn't working properly, then it should be quite obvious that the search function may or may not work.
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

  2. #17
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    Originally posted by volk
    Anyway, no one told me what was wrong with the code I posted.
    Maybe you should read more closely what people post for you.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  3. #18
    Un Artiste Extraordinaire volk's Avatar
    Join Date
    Dec 2002
    Posts
    357
    This thread is old. You were a little late with that reply, Hammer.

  4. #19
    Registered User
    Join Date
    Nov 2002
    Posts
    1,109
    Originally posted by volk
    This thread is old. You were a little late with that reply, Hammer.
    only two days old..

  5. #20
    Un Artiste Extraordinaire volk's Avatar
    Join Date
    Dec 2002
    Posts
    357
    Two days is like two years on these boards.

  6. #21
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    Why, on other boards people sometimes reply to threads two real years old.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  7. #22
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    From where I see it, it's one day old. Anyway, maybe the extra time gave you to the opportunity to read my sample code

    As you're moaning about this threads age, I'll consider it done.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Question about strings in c
    By gp364481 in forum C Programming
    Replies: 9
    Last Post: 11-13-2008, 05:32 PM
  2. Question About Strings
    By spanker in forum C++ Programming
    Replies: 1
    Last Post: 07-13-2008, 05:09 AM
  3. strings question
    By cstudent in forum C Programming
    Replies: 4
    Last Post: 04-18-2008, 07:28 AM
  4. Functions and Strings Question
    By StrikeMech in forum C Programming
    Replies: 4
    Last Post: 07-18-2007, 06:07 AM
  5. Strings question
    By kimimaro in forum C Programming
    Replies: 10
    Last Post: 03-14-2005, 11:14 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21