Re: Array of numbers
Re: Array of numbers
- Subject: Re: Array of numbers
- From: Fritz Anderson <email@hidden>
- Date: Tue, 10 May 2005 14:38:22 -0500
Your difficulties stem from an unfamiliarity with the basics of C
programming that is beyond the scope of email. Find a good book about
C and study for a while.
On 10 May 2005, at 1:44 PM, R T wrote:
Trying to set up many large arrays of (double)numbers
taht will not change. And I built a class. Then in the
Main I try to initialize them.
#import <Cocoa/Cocoa.h>
@interface pArray : NSObject {
double tArray[10];
}
- (double) tArray;
- (void) settArray:(double) atArray;
@end
-------------------------------
#import <Cocoa/Cocoa.h>
#import "pArray.h"
@implementation pArray
-(double) tArray { return tArray[10]; }
- (void) settArray:(double) atArray { tArray[10] =
atArray; }
@end
In the above lines, tArray[10] refers to only a single element of
tArray: One double. It refers to the eleventh double in the array
tArray. As tArray has only 10 elements, this will be an error. Study
until you understand why this is so.
____________________________________
#import <Cocoa/Cocoa.h>
#import "pArray.h"
int main(int argc, char *argv[])
{
pArray *yr11r, *yr11g, *yr11b;
yr11r = [[pArray alloc] init];
double spare[10] = {251.1806006092005756,
15.73649816571729964, -38.55250579961138844,
18.6646726496034207, -4.296551930829748601,
0.4739075909473704491, -0.02077806058734893401,
-0.0003113397371798453354, 0.00005585334479602430891,
-.000001311698905778314492};
[yr11r settArray:spare];
In the above line, spare is a pointer to the first double in a ten-
element array. The method settArray: takes as an argument one double,
not a pointer to a double. The compiler sees the difference and
signals the error. Again, study until you understand why this is so.
return NSApplicationMain(argc, argv);
[yr11r free];
}
________________________________________
...And I get error: incompatible type for argument 3
of indirect function call.
In looking at all of this it seems there is probably
an easier way.
I need these arrays of numbers to be created once and
then called into use from other parts of the program.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden