I got this weird behavior of my programm, that i cant figure out. My professor showed me a flaw in my programm, where i just copy a char pointer when i construct an object instead of making a new copy of the whole array, so you can fool around with it. He demonstrated this with similar code like this.
For the code:
char sweat[] ="Sweater";
warenkorb = new WareImKorb(new Textil (205366,4.2,sweat,40),2,warenkorb);
sweat[0] = '\0';
now if i instead make it:
char* sweat ="Sweater";
the program runs fine till i try sweat[0] = '\0'; It simply crahes then.
However this works: char cc[] ="Sweater"; char* sweat = cc;
It is really bugging me, that i dont understand, why version 1 does not work. Hope you guys can help me out, or else i will go crazy wondering about this.