Thread: sscanf help

  1. #1
    Unregistered
    Guest

    Question sscanf help

    I've been trying to find a way to parse a string in the following format:

    something:string1@string2:string3

    I've been using sscanf and I can't seem to get the format correct:
    I've tried:

    "something:%s@%s:%s"

    and

    "something:%[^@]s%[^:]s%s"

    both to no avail. Can anybody help me out with this? Thanks.

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    sscanf( buffer, "%*[^:]:%[^@]@%[^:]:%s", s1, s2, s3 );

    I'm opting to ignore the first 'something', you can optionally put it in a string.

    Quzah.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. sscanf and string handling question
    By ursula in forum C Programming
    Replies: 14
    Last Post: 05-30-2009, 02:21 AM
  2. Problem using sscanf fgets and overflow checking
    By jou00jou in forum C Programming
    Replies: 5
    Last Post: 02-18-2008, 06:42 AM
  3. Problems reading formatted input with sscanf
    By Nazgulled in forum C Programming
    Replies: 17
    Last Post: 05-10-2006, 12:46 AM
  4. sscanf question
    By Zarkhalar in forum C++ Programming
    Replies: 6
    Last Post: 08-03-2004, 07:52 PM
  5. sscanf (I think)
    By RyeDunn in forum C Programming
    Replies: 7
    Last Post: 07-31-2002, 08:46 AM