Bioplib
Protein Structure C Library
|
Like fgets(), but allocates memory and returns pointer to memory block. More...
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
Go to the source code of this file.
Macros | |
#define | MAXBUFF 80 /* Memory allocated in chunks of this size */ |
Functions | |
char * | blFgetsany (FILE *fp) |
Variables | |
int | errno |
Like fgets(), but allocates memory and returns pointer to memory block.
This code is NOT IN THE PUBLIC DOMAIN, but it may be copied according to the conditions laid out in the accompanying file COPYING.DOC.
The code may be modified as required, but any modifications must be documented so that the person responsible can be identified.
The code may not be sold commercially or included as part of a commercial product except as described in the file COPYING.DOC.
blFgetsany() provides a routine like fgets() for reading strings from a file, but does not require you to impose a limit on the length of string which may be read. fgetsany() allocates memory to store a string of any length and returns a pointer to that allocated memory. After use, this memory must be freed by the calling routine.
blFgetsany() returns NULL on end-of-file and if memory allocation failed. It uses the global `errno' variable to indicate a memory allocation failure (errno==ENOMEM).
Typical usage is as follows:
Definition in file fgetsany.c.
#define MAXBUFF 80 /* Memory allocated in chunks of this size */ |
Definition at line 109 of file fgetsany.c.
char* blFgetsany | ( | FILE * | fp | ) |
[in] | *fp | File pointer open for reading |
blFgetsany() provides a routine like fgets() for reading strings from a file, but does not require you to impose a limit on the length of string which may be read. blFgetsany() allocates memory to store a string of any length and returns a pointer to that allocated memory. After use, this memory must be freed by the calling routine.
blFgetsany() returns NULL on end-of-file and if memory allocation failed. It uses the global `errno' variable to indicate a memory allocation failure (errno==ENOMEM).
Definition at line 143 of file fgetsany.c.
int errno |