Thread: sscanf and gets

  1. #1
    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,490
    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