sscanf and gets

This is a discussion on sscanf and gets within the C++ Programming forums, part of the General Programming Boards category; How do I convert sscanf and gets into c++ code cout <<"Enter amount: "; gets(line); sscanf(line,"%ld",&amount);...

  1. #1
    Max
    Max is offline
    Registered User Max's Avatar
    Join Date
    Jul 2002
    Posts
    110

    sscanf and gets

    How do I convert sscanf and gets into c++ code

    cout <<"Enter amount: ";
    gets(line);
    sscanf(line,"%ld",&amount);

  2. #2
    Just because ygfperson's Avatar
    Join Date
    Jan 2002
    Posts
    2,493
    the gets() equivalent is cout.getline()

    i don't think there is an equivalent for sscanf... but sscanf doesn't interfere with c++ file i/o, anyway, so you should be fine using that.

  3. #3
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    dont u mean istream.getline and not ostream.getline.

    i.e. cout.getline is wrong and cin.getline is ok
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

Popular pages Recent additions subscribe to a feed

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