Allocating fails
Simple but it doesn't work for me
int i=0,j=0;
int count=1;
char**str=0;
char strtemp[strlen(s)%4+1];
for(;i<strlen(s)-4,count=i+3;i++){
for(;j<=count;j++){
char**str=new char*[strlen(s)%4];
strtemp[i]=s[j];
}
str[i]=strtemp;
}
it's to partition string s into strings of length 4, segmentation fault
[411 byte] By [
passward] at [2007-11-11 8:49:53]

# 1 Re: Allocating fails
This code won't compile at all. For example,
char strtemp[strlen(s)%4+1]
can't compile because the array's dimension must be a constant expression.
Also, this line
char**str=new char*[strlen(s)%4];
Was probably meant to be
char*str[0]=new char[strlen(s)%4];
And do on. In short, you need to redesign the whole code.
IF each partition must contain 4 characters, then you need an array of char arrays of 5 chars. To determine how many elements this array should have use strlen(s)%4.
Danny at 2007-11-11 21:00:54 >
