C examples for Function:Utility Function
reads a line of text into a char array q and returns its length:
int getline(char q[], int limit) { int ch, j; for(j=0; j<limit-1 && (ch=getchar())!=EOF && ch!='\n'; ++j) q[j] = ch; if(ch == '\n'){ q[j] = ch; ++j; } q[j] = '\0'; return j; }