Thread: Simple thing

  1. #1
    Divine
    Join Date
    Oct 2007
    Location
    Earth(duh!)
    Posts
    20

    Simple thing

    I found this inside a scanf...

    %[^/n]

    I've been searching what it's mean. Would you help me out?

  2. #2
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    Read a string until a newline is found, I don't think it's part of the standard - more of a compiler extension.

    [] is a list of characters to accept, ^ means the characters in the brackets won't be accepted.

    Basically,
    Code:
    %s = %[]
    Code:
    %1024s = %1024[]
    So if you only wanted to stop reading at a comma, fullstop or space it'd look like:
    Code:
    %[^,. ]
    Or if you only wanted to read commas, fullstops or spaces,
    Code:
    %[,. ]
    Last edited by zacs7; 11-11-2007 at 03:44 AM.

  3. #3
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Read a string until a newline is found, I don't think it's part of the standard - more of a compiler extension.
    It is part of C99, at least.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help with simple DAQ program
    By canada-paul in forum C++ Programming
    Replies: 12
    Last Post: 03-15-2002, 08:52 AM
  2. Simple Compile Time Problem - HELP!
    By kamikazeecows in forum Windows Programming
    Replies: 2
    Last Post: 12-02-2001, 01:30 PM
  3. Help me with these simple programs
    By Help me in forum C Programming
    Replies: 4
    Last Post: 11-08-2001, 10:38 AM
  4. Need help with simple data types
    By partnole in forum C++ Programming
    Replies: 1
    Last Post: 10-03-2001, 08:36 AM
  5. Linker errors with simple static library
    By Dang in forum Windows Programming
    Replies: 5
    Last Post: 09-08-2001, 09:38 AM