How do I, and is it even possible, get actual maximum size of character array passed to a function as a pointer?
int size=0;
while (char_array[size++])
this won't work, as it will return number of characters in the array, and I need its actual size.
Also I cannot use any libraries (specifically string) or my own classes or basically anything useful.
EDIT as it turns out, I will have to explain the assignment quickly. And I am told not to do it in the comments. So here it is:
I have to implement a function that has three character arrays passed as pointers. Cannot change that in any way. First one is a string with commands included in that string (important). The commands are simple: delete x letters, and so on, but some are tricky, like add x letters from second/third character array to the right. Why tricky? Because those arrays may contain more commands, which will then be added to the string I'm working on. So one way to do it is to work on the string passed to a function, but that would be very slow, and I would have to add/delete characters in the middle, which basically means moving the rest of the letters many times. So I would have to have m*n opertions, where n is size of string and m is ammount of commands. But only n operations if I could write to another string. However I don't know how much space would I need, because the commands could add more commands, which would add more letters to initial ammount of characters. Checking the ammount and type of commands beforehand would be slow and make the whole thing rather pointless. However I know that the string passed to the function will have enough space (it's in the assignment specifications). So if I just could access it's size, I could declare another string with same size, knowing it would fit the resulf for sure.
So what will I do? I will declare this local string that I'm writing into with initial size and then if the result is greater I will rewrite it to a bigger string. Which will give me n times z operations, where z is a number of rewrites, which is still better than n times m, but worse than just n.