Path: utzoo!attcan!uunet!husc6!bloom-beacon!mit-eddie!uw-beaver!cornell!rochester!ritcv!ritcsh!gregory From: gregory@ritcsh.UUCP (Gregory Conway) Newsgroups: comp.lang.c Subject: printf vs fprintf Keywords: Style Message-ID: <2454@ritcsh.UUCP> Date: 17 May 88 00:57:12 GMT Organization: Computer Science House @ RIT, Rochester, NY Lines: 22 An interesting point came to mind as I was working today. I thought I might share it with those of you who are (or know someone who is) learning the C language. It seems to me that a great deal of confusion could be saved when learning printf, scanf, fprintf, fscanf, sprintf, and sscanf. The point is really simple, don't use printf and scanf. Use, instead, fprintf (stdout, "....") and fscanf (stdin, "....", &whatever). Why, you ask?? Well, if you think about it, scanf and printf are really special cases of fscanf and fprintf. The mental correlation is easier if you remember you always operate on an IO path, represented by some file. (stdin and stdout are just standard file, right? - hence Fscanf and Fprintf) Then, when the user wants to use sprintf and sscanf, he or she need only remember the the "IO path" is a stream, a buffer is you will. After a person has a complete understanding of how all this fits together, he or she could easily use the shorter, easier scanf and printf. Does anyone else think this seems like a good way to learn the rudiments of IO in C?? Flames are welcome. ;-) -- ================================================================================ Gregory Conway@Computer Science House UUCP: ...rochester!ritcv!ritcsh!gregory Rochester Institute of Technology, Rochester, NY "I got an allergy to Perrier, daylight, and responsibility", Marillion