Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

The GNU C Programming Tutorial - getdelim

Node:getdelim, Previous:getline, Up:String input



getdelim

The getdelim function is a more general form of the getline function; whereas getline stops reading input at the first newline character it encounters, the getdelim function enables you to specify other delimiter characters than newline. In fact, getline simply calls getdelim and specifies that the delimiter character is a newline.

The syntax for getdelim is nearly the same as that of getline, except that the third parameter specifies the delimiter character, and the fourth parameter is the stream from which to read. You can exactly duplicate the getline example in the last section with getdelim, by replacing the line

bytes_read = getline (&my_string, &nbytes, stdin);

with the line

bytes_read = getdelim (&my_string, &nbytes, '\n', stdin);

 
 
  Published under free license. Design by Interspire