int main(int argc, char** argv) {
char *test[5][20];
char *input[20];
int i;
for(i=0;i<5;i++){
printf("enter> ");
fflush ( stdout );
fgets(input,20,stdin);
*test[i] = *input;
}
for(i=0;i<5;i++)
printf("%d | %s\n",i,test[i]);
return 0;
}
Output:
enter> pwd
enter> pathd
enter> ls
enter> echo $path
enter> pwd 0 | pwd
1 | path▒] a▒▒a▒▒#a▒▒ 2 | ls
3 | echo▒▒( 4 | pwd
Press [Enter] to close the terminal ...
I also need to be able to read in input that has spaces. Thanks!