I want to input:
abc def ghi jkl
and the output should be:
abc
def
ghi
jkl
I want to store each string in an array and then use a for cycle to print each position.
I have this code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
char vector[100];
int i = 0;
int aux = 0;
while (i < 5)
{
scanf("%s", &vector[i]);
i++;
aux+= 1;
}
for (i=0;i<aux;i++)
{
printf("%s\n", &vector[i]);
}
return 0;
}
What am I doing wrong?
Second question:
How can I change the code to stop reading my inputs when I press ctrlD and print the output?