You can simply use array of n
number of pointers to char. Then use a loop to allocate space for those.
int n, size;
scanf("%d %d", &n, &size);
char *arr[n];
for( int i = 0; i < n; ++i ){
arr[i] = malloc( size * sizeof(char) );
}
More Related Contents:
- isnt everything where it should be, why the segmentation fault?
- c search for target string in string [closed]
- Fast way to tokenize a string in c
- How do I create an array of strings in C?
- Difference between char *str=”STRING” and char str[] = “STRING”?
- “error: assignment to expression with array type error” when I assign a struct field (C)
- C – Difference between “char var[]” and “char *var”?
- Return char[]/string from a function [duplicate]
- In C, why can’t I assign a string to a char array after it’s declared?
- Literal string initializer for a character array
- Array type char[] is not assignable [duplicate]
- Strange character after an array of characters
- Varying string variable in an if condition
- C split a char array into different variables
- Assigning char array a value in C
- How can I check if an element in an array is equal to something in C? [closed]
- How can I get a text file into a string but whith the “\n” in C?
- String compare function in C [closed]
- How to find the ‘sizeof’ (a pointer pointing to an array)?
- Check substring exists in a string in C
- How do you convert a byte array to a hexadecimal string in C?
- How to read string from keyboard using C?
- Can C arrays contain padding in between elements?
- How do I print a non-null-terminated string using printf?
- Returning Arrays/Pointers from a function
- why is array name a pointer to the first element of the array?
- How can I find the number of elements in an array?
- Passing two-dimensional array via pointer
- string array with garbage character at end
- How to find the size of an array (from a pointer pointing to the first element array)?