[futurebasic] C array garbage value

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : February 2017 : Group Archive : Group : All Groups

From: Bernie <bernie.fblist@...>
Date: Fri, 10 Feb 2017 12:05:41 +0000
Clang (analysis) complains of a garbage value in MyFunction1. To remove the warning, I created an NSArray instead (MyFuntion2).

Anyone got a better idea?

// ---------------
BeginCFunction
void MyFunction1( int count ) {
    int dim[count];
    for ( int d = 0; d < count; d++ ) {
        dim[d] = 15;
    }
    int d = dim[1];// garbage value
    NSLog(@"%d",d);
}

// workaround
void MyFunction2( int count ) {
    NSMutableArray *dim = [NSMutableArray arrayWithCapacity:count];
    for ( int d = 0; d < count; d++ ) {
        [dim addObject:@15];
    }
    int d = [dim[1] intValue];
    NSLog(@"%d",d);
}
EndC
// ---------------