It is really best handled using passed parameters.
[edit]Bad example. Better one to follow.
Code:
#include <stdio.h>
int inputPhrase(char *s, int size)
{
int ch, i = 0;
while ( i < size - 1 )
{
int ch = getchar();
if ( ch == '\n' || ch == EOF )
{
break;
}
s[i++] = ch;
}
s[i] = '\0';
return i;
}
int main(void)
{
char text[30];
int size = sizeof text / sizeof *text;
int count = inputPhrase(text, size);
printf("text[%d] = \"%s\" : %d characters.\n", size, text, count);
return 0;
}
/* my output
Hello world
text[30] = "Hello world" : 11 characters.
The quick brown fox jumps over the lazy dog.
text[30] = "The quick brown fox jumps ove" : 29 characters.
*/