over and over again, for as much pointers are in element.str[].
But trying to work this code into a loop [neither for() nor while()] did not work. It even makes my program crash instantly when test() is called;
I can't see whats wrong with this code or where the difference between these two code is (except that repeating the same instruction programaticly instead by hand before compiling).
Can anybody give me at least a clue on why the loop version did not work.
When i start a loop (even if it's doing absolutly nothing like an empty for(i = 0; i < 1; i++){}) after calling InitializeElement() the program goes boom.
Is something dangerous or false that I'm doing here?
I copy the chararray because i wasn't quite sure if strtok creates new char* and copy the created contend to this new memory or if it just replaces the delimiter with '\0' in memory and produces pointer with adress of memory just beyound that '\0' for next token.
But the original problem seems to be a mixture of the dumbass before th screen (that's me) and the compiler.
I wonder why it let me slip this code
1 2 3 4 5 6
elementtype test(char* str_contend){
char *token, *tmp;
int i = 0;
elementtype element = InitializeElement(element);
strcpy(tmp, str_contend);
in version without a loop and didn't when a loop is present.
Had to change it the way I normaly handle chararrays. Did thought could be lazy this time, big error. Its like helios said, no memory allocation by its own.