ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
I've been revising my dusty old C knowledge and have found things have changed a bit since 1992!
The problem I'm finding is that I'm reading up on various functions like scanf, gets, fgets, fscanf, fprintf and loads more like them, only to find out later the info in question was written many years ago and the function discussed is no longer used, or else its use is now deprecated and/or it's been superseded by something better.
So the question is: in 2009, what are the best ANSI C functions for manipulating and processing data in and between files?#
I've been revising my dusty old C knowledge and have found things have changed a bit since 1992!
The problem I'm finding is that I'm reading up on various functions like scanf, gets, fgets, fscanf, fprintf and loads more like them, only to find out later the info in question was written many years ago and the function discussed is no longer used, or else its use is now deprecated and/or it's been superseded by something better.
So the question is: in 2009, what are the best ANSI C functions for manipulating and processing data in and between files?#
I'm not aware that anything in string handling has changed particularly in C. String handling has always been rudimentary in C and that has not changed. scanf, fscanf, and their ilk were deprecated from the moment they first appeared and no one in their right mind uses them. printf, sprintf, fprintf, getc, putc, strcpy, strncpy, strcmp, strncmp...all are unchanged. Beyond that, just use buffers and pointers to build what you need, or use a higher level language if you don't care about the overhead.
I'm not aware that anything in string handling has changed particularly in C. String handling has always been rudimentary in C and that has not changed. scanf, fscanf, and their ilk were deprecated from the moment they first appeared and no one in their right mind uses them. printf, sprintf, fprintf, getc, putc, strcpy, strncpy, strcmp, strncmp...all are unchanged. Beyond that, just use buffers and pointers to build what you need, or use a higher level language if you don't care about the overhead.
There is a bunch of pretty advanced string handling libraries for "C", but the OP does not say what he exactly wants.
I've been revising my dusty old C knowledge and have found things have changed a bit since 1992!
it's true that things have really changed, though not to a far extent.
C itself has two versions. c89 was the one that you used when you were in the nineties(1992).
now almost all the compilers follow the c99 mode, though some compilers have support for the c89 mode.
Quote:
The problem I'm finding is that I'm reading up on various functions like scanf, gets, fgets, fscanf, fprintf and loads more like them, only to find out later the info in question was written many years ago and the function discussed is no longer used, or else its use is now deprecated and/or it's been superseded by something better.
So the question is: in 2009, what are the best ANSI C functions for manipulating and processing data in and between files?#
THanks!
CC.
various things has been added, while various features been abandoned or deprecated(as you said).
you must have noticed that gets function does not provide a boundary checking for the string you enter. most modern compilers flashes a warning message on the screen mentioning it to be a dangerous functions.
get hold of the newest edition "C: The Complete Reference" by Herbert Schildt.
a few wikying might help you...
as for file operations i would prefer binary files over text files and finally use fread() and fwrite().
Sorry I was thinking about the new builtin functions that are provided by gcc. If I'm going to create an advance program, I would love basing it from those. Those builtins are described or enumerated somewhere in the info. Maybe in C Extensions.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.