struct ArrayList {
char* string;
int index;
int capacity;
};
array initialize(int cap) {
array list;
list.index = 0;
list.capacity = cap;
list.string = malloc(sizeof(char));
return list;
}
void addElement(arrayPtr list, char c) {
list->string[list->index] = c;
list->index += 1;
}
I initialized string for 1 char only but I was able added more than what the array should have been I added 11 char elements and it was possible and it printed in the terminal as well.
I tried adding more but it didnt error. As far as I know for char I can only access one letter, but it was able to input me a word.