Thread: cout vs. printf

  1. #16
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >Definately not the same as gets.
    It was the way Stoned wrote it

    -Prelude
    My best code is written with the delete key.

  2. #17
    Banned Troll_King's Avatar
    Join Date
    Oct 2001
    Posts
    1,784

    Smile

    That's because Stoned Coder doesn't know how to program J/K!

  3. #18
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    Of course, no one in their right mind would use scanf that way anyway so I guess the point is moot. The only times I've seen that scanf construct has been in response to a question either here or Usenet. Never in production code.

    -Prelude
    My best code is written with the delete key.

  4. #19
    Banned Troll_King's Avatar
    Join Date
    Oct 2001
    Posts
    1,784
    Those formatters are not used in scanf but they are used in sscanf, after a string is retrieved with fgets. Take this senario

    39408234030482na me83048019384039842309
    42340982349823na me23904823908402384239
    43493842030948na me8432d039849023893944

    I want 2 floats a string and 2 ints. This datafile is used by 2 different programs. The data unrelated to the program that I'm currently using must be skipped. I will grab the line with fgets and use those formatters to retrieve my desired fields with sscanf right into my structure. That's production code. You will find this if you look into Cobol. Most large scale systems in the world are Cobol. C can accomplish the same thing. Try looking into business applications, not games. In production code, infact they do not even use decimals for floating point numbers on the datafile. It is all just numbers and the programmer has to format the data, all decimal places are virtual or implied. The datafiles just look like a mess of numbers packed together. And like I mentioned, more than one program will use the same datafile, therefore characters must be skipped in order for the structure to accept the correct fields that it needs in contrast to another program with a different structure with different fields using the same file.
    Last edited by Troll_King; 02-10-2002 at 04:32 PM.

  5. #20
    Registered User Invincible's Avatar
    Join Date
    Feb 2002
    Posts
    210

    Thumbs up

    10,000 ways to do the same thing *sigh*

    Now I think I'll look into the console function. It sounds exactly like what I'm looking for. Especially since it can even format numbers. Just think, I was trying to understand the locale.h, confusing stuff.

    Thanks for all the information, it's been extremely helpful.
    Last edited by Invincible; 02-10-2002 at 04:47 PM.
    "The mind, like a parachute, only functions when open."

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Data Structure Eror
    By prominababy in forum C Programming
    Replies: 3
    Last Post: 01-06-2009, 09:35 AM
  2. making it portable.....?
    By ShadeS_07 in forum C Programming
    Replies: 11
    Last Post: 12-24-2008, 09:38 AM
  3. Need Help with a Bowling Score Program
    By oobootsy1 in forum C++ Programming
    Replies: 6
    Last Post: 11-01-2005, 10:04 AM
  4. Whats Wrong Whith This!?
    By SmokingMonkey in forum C++ Programming
    Replies: 8
    Last Post: 06-01-2003, 09:42 PM
  5. (printf VS cout) and (including libraries)
    By \cFallen in forum C++ Programming
    Replies: 3
    Last Post: 01-20-2003, 09:47 PM