/************************************************************* * File: lib/getword.c * Purpose: Part of C runtime library * Author: Phil Bunce (pjb@carmel.com) * Revision History: * 970304 Start of revision history */ #include "string.h" /************************************************************* * char *getword(dst,p) * copies next word from p into dst, else rtns 0 */ char *getword(char *dst,char *p) { char *a; if (!dst || !p) return(0); dst[0] = 0; while (isspace(*p)) p++; if (*p == 0) return(0); a = p; while (!isspace(*p) && *p != 0) p++; strncpy(dst,a,p-a); dst[p-a] = 0; return(p); } /* int wordsz(p) return size of first word in p */ int wordsz(p) char *p; { int n; if (!p) return(0); while (isspace(*p)) p++; for (n=0;! *p && ! isspace(*p);n++) p++; return(n); }