Oh, something along this line:
Code:#include <stdio.h>
#include <stdlib.h>
#include <string.h>
size_t array_get(char (*array)[20], size_t size);
void array_print(char (*array)[20], size_t size);
int main(void)
{
char array[10][20];
size_t count = array_get(array, sizeof array / sizeof *array);
array_print(array, count);
return 0;
}
size_t array_get(char (*array)[20], size_t size)
{
char text[20];
size_t i = 0;
while ( i < size )
{
printf("enter some text: ");
fflush(stdout);
if ( fgets(text, sizeof text, stdin) &&
sscanf(text, "%19s", array[i]) == 1 )
{
++i;
}
else
{
break;
}
}
return i;
}
void array_print(char (*array)[20], size_t size)
{
while ( size-- )
{
puts(*array++);
}
}
/* my output
enter some text: one
enter some text: two
enter some text: three
enter some text:
one
two
three
*/