Thread: scanf properties in c

  1. #1
    Registered User
    Join Date
    Nov 2020
    Posts
    8

    scanf properties in c

    the example that i took from deitels book there is a code as seen below
    Code:
    while (scanf("%d%[^0-9-]%lf", &account, name, &balance) != EOF) {
    can you explain what does it mean %[^0-9-] why do we put - in the code.
    thanks in advance.

  2. #2
    Registered User
    Join Date
    Feb 2019
    Posts
    799
    %[^...] means the same as %s but excludes those characters (in your case from '0' to '9' and '-').

    Another thing: scanf() returns EOF only if any of the conversions can't be done and if you reach the END OF FILE in a file stream. stdin will not reach the end of file, so this is an infinite loop (except if you hit ^D on Unix terminal).

    scanf() also retuns the number of successful conversions...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. about properties
    By joaquim in forum C++ Programming
    Replies: 62
    Last Post: 02-06-2014, 10:51 AM
  2. DLL Properties @ Windows7 using g++
    By artur in forum C++ Programming
    Replies: 11
    Last Post: 05-30-2012, 06:41 AM
  3. No properties in c++?
    By MisterT in forum C++ Programming
    Replies: 19
    Last Post: 08-06-2006, 08:54 AM
  4. window properties
    By Warhawk in forum C++ Programming
    Replies: 9
    Last Post: 09-15-2005, 03:09 PM
  5. FPS properties.
    By DarkBrute in forum Game Programming
    Replies: 24
    Last Post: 02-03-2005, 07:41 PM

Tags for this Thread