getline.c

来自「cygwin, 著名的在win32下模拟unix操作系统的东东」· C语言 代码 · 共 55 行

C
55
字号
/*FUNCTION<<getline>>---read a line from a fileINDEX        getlineANSI_SYNOPSIS        #include <stdio.h>        ssize_t getline(char **<[bufptr]>, size_t *<[n]>, FILE *<[fp]>);TRAD_SYNOPSIS        #include <stdio.h>        ssize_t getline(<[bufptr]>, <[n]>, <[fp]>)        char **<[bufptr]>;        size_t *<[n]>;        FILE *<[fp]>;DESCRIPTION<<getline>> reads a file <[fp]> up to and possibly including thenewline character.  The line is read into a buffer pointed toby <[bufptr]> and designated with size *<[n]>.  If the buffer isnot large enough, it will be dynamically grown by <<getdelim>>.As the buffer is grown, the pointer to the size <[n]> will beupdated.<<getline>> is equivalent to getdelim(bufptr, n, '\n', fp);RETURNS<<getline>> returns <<-1>> if no characters were successfully read,otherwise, it returns the number of bytes successfully read.at end of file, the result is nonzero.PORTABILITY<<getline>> is a glibc extension.No supporting OS subroutines are directly required.*//* Copyright 2002, Red Hat Inc. - all rights reserved */#include <stdio.h>extern ssize_t __getdelim (char **, size_t *, int, FILE *);ssize_t__getline (lptr, n, fp)     char **lptr;     size_t *n;     FILE *fp;{  return __getdelim (lptr, n, '\n', fp);}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?