but the field paramMethod can have an undefined number of positions...
so, i have to change its size, if there are more things to put on it...
here is a part of my code:
1 2 3 4 5 6 7 8 9 10
int contParam = 0;
temp->paramMethod[0] = NULL;
temp->classe = indiceLexClass;
while(v){
c_Name_Decl* n = v->nameDeclaration;
if(n)
temp->paramMethod[contParam] = getType(n->type);
v = v->next;
contParam++;
}
v is a linked list containing the chars to put on the paramMethod positions...
but i need to resize it if the number is greater than the value i put on the declaration...
You can't resize arrays, if you are using char* as strings, you should try std::string
If you really want a resizable array without STL, you can:
- create the array dynamically
- create a new array with the new size
- copy the elements from the first to the second array
- delete the first array
- redirect the pointer to the first array to the second
edit:
well I solved this error by creating another auxiliar vector...
and doing the push_back on it and them swaping it with de paramMethod...
but i think this is a very stupid solution...
=T
By the way, it'd be nice to stop suggesting C++ alternatives when OP is obviously using C.
Well it obviously wasn't obvious to the OP since he decided to start using vectors. Why do you keep writing these annoying and condescending statements helios? This website is cplusplus.com. If the OP wants help with C then they should either use another website or specifically state that they are only allowed to write C code in their assignment.
condescending
1. Assuming a tone of superiority, or a patronizing attitude.
That sentence was hardly condescending. Can you provide any concrete examples?
While you're doing that, consider why none of the people who actually replied to this thread took offense of what I said, or if they did they kept quiet, and you apparently did.