/* ------------------------------------------------------------------------- ** ** str.c - implementacao das funcoes para manipulacao de strings. ** ** CURSO DE PROGRAMACAO - II ** ** Prof. Márcio Santi. ** ------------------------------------------------------------------------- ** */ #include #include #include #include /* ------------------------------------------------------------------------- ** Funcoes locais: */ /* ------------------------------------------------------------------------- ** Funcoes publicas: */ /* =============================== StrPut =============================== */ void StrPut(char *s) { int i; for (i = 0; s[i] != '\0'; i++) putchar(s[i]); } /* =============================== StrGet =============================== */ int StrGet(int lim, char *s) { int i,c; int l = lim - 1; for (i = 0; i < l; i++) { c = getchar( ); if (c == EOF || c == '\n') break; s[i] = c; } s[i] = '\0'; return(i); } /* =============================== StrLen =============================== */ int StrLen(char *s) { int i; for (i = 0; s[i] != '\0'; i++); return(i); } /* =============================== StrCpy =============================== */ void StrCpy(char *s, char *t) { int i; for (i = 0; t[i] != '\0'; i++) s[i] = t[i]; s[i] = '\0'; } /* =============================== StrCat =============================== */ void StrCat(char *s, char *t) { int i,j; for (i = StrLen(s), j = 0; t[j] != '\0'; i++, j++) s[i] = t[j]; s[i] = '\0'; } /* ============================== StrPCat =============================== */ #if 0 void StrPCat(char *c, char *s, char *t) { int i, j; int size; char *r; size = StrLen(s) + StrLen(t); r = StrAlc(size+1); for(i=0;i