Hello,
How can we create an array which size would grow as the user enter an input ? (Maybe linked lists ?)
Here is a piece of code that I have written where I have a fixed input, 128 characters long :
Code:
#include <stdio.h>
#include <string.h>
#define MAX_SIZE 128
int main(int argc, char **argv)
{
printf("Input : ");
char user_input[MAX_SIZE];
fgets(user_input,MAX_SIZE,stdin);
printf("You Wrote : \n");
printf(" %s \n", user_input);
const int ARRAY_SIZE = strlen(user_input);
printf("%d characters found \n", ARRAY_SIZE);
return 0;
}
By the way is this piece of code "safe" ?
Regards