Originally Posted by
Jakob
When I delete one strcpy-command (no matter which one) it works without problems.
Does it really works? I don't thinks so. Anyway maybe you need this:
Code:
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
char stra[10];
char strb[10];
strcpy(stra, "hallo");
strcpy(strb, "hallo");
return(0);
}
With this line
you defined array of 10 pointers to type char.
If your intetnion was to do this then you must first allocate memory otherwise you'll get a seg. fault
So correct version would be:
Code:
char *stra[10];
stra[0] = new char[10]; //allocate enough memory to store 10 character
strcpy(*stra, "hallo");
//or strcpy(stra[0], "hallo");
when using *stra that means you use stra[0] in this case.
I repeat I don't know if your intetion was to define array of pointers to type char in the first place. Did you want to define array of C strings?