I want to know whether is there a direct way of addressing a 2D char array and store strings on it.
And I know that by using malloc, I could dynamically allocate memory to strings for example for char * names[number]
I can malloc (char *)malloc(50*sizeof(char))
and get it done.
And also I know that by using a for loop and assigning each and every element you can achieve the same. I found it through this similar question here .
but my case is ,Is there a way to use array name and indexes to store strings directly.It should look something like this. down here is not a popper code and I just wanted to show how it should look like (from the link I mentioned above)
char arrayOfWords[NUMBER_OF_WORDS][MAX_SIZE_OF_WORD];
int i;`
for (i=0; i<NUMBER_OF_WORDS; i++) {
arrayOfWords[i] = "laksith"; //here I need to use a way like arrayOfWords+1 etc.
}
I think you may have got the idea of what I'm saying.