?? addstr.3
字號:
.\" Copyright (c) 1986-1990 Entropic Speech, Inc..\" Copyright (c) 1991 Entropic Research Laboratory, Inc.; All rights reserved.\" @(#)addstr.3 1.5 09 May 1997 ESI/ERL.ds ]W (c) 1991 Entropic Research Laboratory, Inc..TH ADDSTR 3\-ESPSu 09 May 1997.SH NAME.nfaddstr \- append a string to a null-terminated array of stringsstrlistlen \- return number of strings in a null-terminated array of strings.fi.SH SYNOPSIS.ft B.nfevoidaddstr(str, arr)char *str;char ***arr;intstrlistlen(strlist)char **strlist;.SH DESCRIPTION.PPIf the location.RI * arrto which.I arrpoints (typically a variable in the calling program) is not NULL, itmust contain a pointer to the beginning of a block of storageallocated by.IR malloc (3C)or.IR calloc (3C)and containing a NULL-terminated string array \- that is, an array ofelements of type (char *), the last of which is (char *) NULL. Sucharrays are used, for instance, to hold lists of field names in FEAfile headers and to hold lists of values for CODED items in FEA fileheaders and generic header items..PPIf the location .RI * arrto which.I arrpoints is NULL, then \fIaddstr\fP allocates the necessary initial storage and assigns it to .RI * arr. .PPIn both cases, the function then reallocates the storage with.IR realloc (3C)to hold one more element,inserts.I stras a new last element (overwriting the terminating NULL),and follows it with a new terminating NULL.The pointer in.RI * arris updated to point to the beginning of the reallocated block..PPThe function \fIstrlistlen\fP returns the current number of strings in the string array \fIstrlist\fP, and is intended for use on string arrays maintained by \fIaddstr\fP. .SH EXAMPLE.PPA program may allow a command-line optionto be specified several times with different arguments.Here is one way to get a list of the arguments.(This is a quadratic algorithm and not recommended for building upextremely long arrays.).nfextern int optind;extern char *optarg;int ch;char **fields = NULL;while ((ch = getopt(argc, argv, "f:\fI<other option letters>\fP") != EOF) switch (ch) { case 'f': addstr(optarg, &fields); break; \fI<other cases>\fP }.fi.SH DIAGNOSTICSESPS assertion failed: can't reallocate memory for string array.SH BUGSNone known..SH SEE ALSO.nf\fIatoarrays\fP (3\-\s-1ESPSu\s+1), \fIlin_search\fP(3\-\s-1ESPSu\s+1), \fIlin_search2\fP (3\-\s-1ESPSu\s+1), FEA (5\-\s-1ESPS\s+1), \fIgenhd_codes\fP (3\-\s-1ESPSu\s+1), \fIgenhd_list\fP(3\-\s-1ESPSu\s+1).fi.SH AUTHORRodney Johnson, with mods by John Shore
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -