LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
LinkBack Search this Thread
Old 08-20-2009, 05:04 AM   #1
Completely Clueless
Member
 
Registered: Mar 2008
Location: Marbella, Spain
Distribution: Many and various...
Posts: 676

Rep: Reputation: 63
Question C: recommended string handling commands?


Hi all,

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?#

THanks!

CC.
 
Old 08-20-2009, 05:58 AM   #2
konsolebox
Senior Member
 
Registered: Oct 2005
Location: Philippines
Distribution: Gentoo, Slackware, LFS
Posts: 1,526
Blog Entries: 5

Rep: Reputation: 98
If you're using gcc, 'info gcc' tells it all .
 
Old 08-20-2009, 06:13 AM   #3
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,123

Rep: Reputation: 407Reputation: 407Reputation: 407Reputation: 407Reputation: 407
Quote:
Originally Posted by Completely Clueless View Post
Hi all,

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?#

THanks!

CC.
Your question lacks specifics.
 
Old 08-20-2009, 06:19 AM   #4
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Slackware 10.1/10.2/12, Ubuntu 10.04, Crunchbang Statler
Posts: 3,325

Rep: Reputation: 168Reputation: 168
@konsolebox: where?
 
Old 08-20-2009, 06:54 AM   #5
Completely Clueless
Member
 
Registered: Mar 2008
Location: Marbella, Spain
Distribution: Many and various...
Posts: 676

Original Poster
Rep: Reputation: 63
Quote:
Originally Posted by Sergei Steshenko View Post
Your question lacks specifics.
Okay, well specifically, which string handling functions are currently in popular use?
 
Old 08-20-2009, 07:37 AM   #6
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,123

Rep: Reputation: 407Reputation: 407Reputation: 407Reputation: 407Reputation: 407
Quote:
Originally Posted by Completely Clueless View Post
Okay, well specifically, which string handling functions are currently in popular use?
It depends on what you want. There are such functions in standard "C" library, and there are other libraries offering extended functionality.

For example, if you want to find patterns in strings, think of PCRE (use your favorite web search engine to find more).

The main in my opinion thing is to understand deficiencies (if any) of standard "C" library string handling functions and to find alternatives.
 
Old 08-20-2009, 01:16 PM   #7
jiml8
Senior Member
 
Registered: Sep 2003
Posts: 3,171

Rep: Reputation: 112Reputation: 112
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.
 
Old 08-20-2009, 02:49 PM   #8
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,123

Rep: Reputation: 407Reputation: 407Reputation: 407Reputation: 407Reputation: 407
Quote:
Originally Posted by jiml8 View Post
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.
 
Old 08-20-2009, 03:05 PM   #9
lemon09
Member
 
Registered: Jun 2009
Location: kolkata,India
Distribution: Mandriva,Fedora
Posts: 186
Blog Entries: 1

Rep: Reputation: 32
Quote:
Originally Posted by Completely Clueless View Post
Hi all,

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().

Good Day.

Last edited by lemon09; 08-22-2009 at 06:51 AM.
 
Old 08-21-2009, 03:48 AM   #10
konsolebox
Senior Member
 
Registered: Oct 2005
Location: Philippines
Distribution: Gentoo, Slackware, LFS
Posts: 1,526
Blog Entries: 5

Rep: Reputation: 98
Quote:
Originally Posted by Wim Sturkenboom View Post
@konsolebox: where?
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Pasting a block of commands, handling delayed programs (ffmpeg) anonguy9 Linux - Newbie 3 03-27-2009 01:31 PM
Handling Errors and exceptions of commands pdklinux79 Linux - Newbie 1 06-20-2008 02:28 PM
handling perl string containing '@' and '$' with system function powah Programming 7 11-30-2007 12:54 AM
Php String Handling joelhop Programming 1 09-11-2006 11:21 PM
Need help w/ shell handling 3 commands/2 pipes sptchamp Programming 3 07-15-2004 09:37 PM


All times are GMT -5. The time now is 03:09 PM.

Main Menu
 
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration