So I am writing a program that stores a user defined number of arrays, into a user defined sized array, currently I am trying to print out each string entered but do not know how to store away the previous strings to somewhere else. For example if the user wants 4 strings, I can only print out the last one. My first thought is to create another array for strings that grows as i put the user entered strings into it, but am lost on how to achieve this and seperate the strings in the bigger string. How do I repeat the printf statement at the end so that it prints out all of the strings entered and not just the last one? How do I create the space for the strings as they are given, and not overwrite them? How do I send the string somewhere else in memory before having the next string entered, and how would I access it? here is the code so far (work in progress)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc,char *argv[]){
    int i, length, amt;
    char *ptr, *thetotalstring;
    i=0;
    printf("enter string amount: ");
    scanf("%d",&amt);
    for(;i<amt;i++){
        printf("Enter the length of the string: ");
        scanf("%d", &length);  //length is defined
        ptr = malloc(length/2*sizeof(char));  //allocate the space
        printf("Please enter string %d: ", (i+1));  
        scanf("%s", ptr);   //get the string
        thetotalstring = realloc(ptr, amt*length*sizeof(char));
    }  
    //allocate more 
    //space in a bigger string to hold other strings?? 
    for(i=0;i<amt;i++){
        printf("%s", thetotalstring);
    }
    return 0;
}
 
     
     
    