sscanf help

This is a discussion on sscanf help within the C Programming forums, part of the General Programming Boards category; 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 ...

  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, 03: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, 01:46 AM
  4. sscanf question
    By Zarkhalar in forum C++ Programming
    Replies: 6
    Last Post: 08-03-2004, 08:52 PM
  5. sscanf (I think)
    By RyeDunn in forum C Programming
    Replies: 7
    Last Post: 07-31-2002, 09:46 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21