Thread: cutting a string

  1. #1
    Registered User
    Join Date
    Feb 2006

    cutting a string

    I have two questions:

    So I have a char

    I want to cut this char into 3 parts, into the ip, the port 80 and the path with the file name path1/path2/pathn/test.exe.

    I have a char with a path c:\test\temp\test.txt and I want only the path c:\test\temp

    Thanks for help.
    Last edited by Salem; 05-25-2006 at 12:46 AM. Reason: de-url the text string with http in it

  2. #2
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    If it were C, I'd say (1) sscanf, (2) strrchr. They'll both be available in C++, of course, but someone will now come along and mention something else.
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  3. #3
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    United States
    1. If you used strings, like you should, you would have an easier time since you have a bunch of find functions and a substr function.

    2. Again, use strings, and for this particular problem, use find_last_of()

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 8
    Last Post: 04-25-2008, 02:45 PM
  2. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 05:45 PM
  3. Something is wrong with this menu...
    By DarkViper in forum Windows Programming
    Replies: 2
    Last Post: 12-14-2002, 11:06 PM
  4. Classes inheretance problem...
    By NANO in forum C++ Programming
    Replies: 12
    Last Post: 12-09-2002, 03:23 PM
  5. Warnings, warnings, warnings?
    By spentdome in forum C Programming
    Replies: 25
    Last Post: 05-27-2002, 06:49 PM