Thread: cut problem

  1. #1
    Registered User
    Join Date
    Feb 2006

    cut problem


    OK I have the following problem:

    char *Servaddress;
    char	ip[256];
    char	user[256];
    char	password[256];
    int	port;
    int	temp = 0;
    temp = sscanf(Servaddress,"ftp://%s:%s@%s:%d",&user,&password,&ip,&port);
    But the result is not what I have expected. I read that %s will read subsequent characters until a whitespace is found. But I need sth which read until the character I want is find, e.g. : or @.

    Any ideas?

  2. #2
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Use a scanset. And supply a width for the strings.
       temp = sscanf(Servaddress,"ftp://%255[^:]:%255[^@]@%255[^:]:%d",
    Last edited by Dave_Sinkula; 05-19-2006 at 07:50 AM.
    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
    Registered User
    Join Date
    Feb 2006
    Works perfect. Thank you.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 02:51 PM
  2. Awkward problem in learning c++
    By TheUnknownFacto in forum C++ Programming
    Replies: 6
    Last Post: 05-17-2007, 01:43 PM
  3. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 06:54 PM
  4. Laptop Problem
    By Boomba in forum Tech Board
    Replies: 1
    Last Post: 03-07-2006, 06:24 PM
  5. beginner problem
    By The_Nymph in forum C Programming
    Replies: 4
    Last Post: 03-05-2002, 05:46 PM