Thread: cut problem

  1. #1
    Registered User
    Join Date
    Feb 2006
    Posts
    71

    cut problem

    Hi

    OK I have the following problem:

    Code:
    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
    Posts
    5,005
    Use a scanset. And supply a width for the strings.
    Code:
       temp = sscanf(Servaddress,"ftp://%255[^:]:%255[^@]@%255[^:]:%d",
                     user,password,ip,&port);
    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
    Posts
    71
    Great
    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