Thread: help with an array problem of sortrs

  1. #1
    Registered User
    Join Date
    Jul 2005
    Posts
    8

    help with an array problem of sortrs

    With the function that I have. I get different types of data passed to this function. The ones that I am getting now are for the state of California, for the MAX TOWING and MAX RENTAL section. The data that is passed is usually passed as '100/250' and the function is already set up to handle that with strtok and all of that. What's happening is that there is one piece of data being passed that doesn't have a "/" in it. The data is '1001200' and I need it displayed as $100 MAX TOWING / $1200 MAX RENTAL without messing up the other data that comes in with the "/". Any ideas?

  2. #2
    Registered User
    Join Date
    Jul 2005
    Posts
    8
    Basically, how can I insert a "/" into '1001200'. I need the string to be "100/1200"

    Any help at all would be helpful.

  3. #3
    Sr. Software Engineer filker0's Avatar
    Join Date
    Sep 2005
    Location
    West Virginia
    Posts
    235
    When you have a value that has no slash, is there a good way to determine where the slash belongs? Will the first value always be 3 digits, and the second 4? If you know this, you can write a special case that, when strtok() returns NULL (or whatever it is that it returns when it doesn't find a token delimiter) that either copies the first part of the string into a new string, appends a "/", then appends the following bit of the string, then calls the function recursively with the new string. This is just one option, though -- you don't really give enough information to give a definitive answer, and some of the information that you do give (MAX TOWING/MAX RENTAL for example) is not really relevant to the problem.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Array problem
    By TomBoyRacer in forum C++ Programming
    Replies: 3
    Last Post: 04-08-2007, 11:35 AM
  2. Replies: 6
    Last Post: 02-15-2005, 11:20 PM
  3. Merge sort please
    By vasanth in forum C Programming
    Replies: 2
    Last Post: 11-09-2003, 12:09 PM
  4. Need desperate help with two dimensional array problem
    By webvigator2k in forum C++ Programming
    Replies: 4
    Last Post: 05-10-2003, 02:28 PM
  5. From stream/file to a string array problem
    By dradsws in forum C Programming
    Replies: 2
    Last Post: 10-01-2001, 06:24 PM