Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

srinivas.be88

macrumors newbie
Original poster
Aug 10, 2010
24
0
hi ,
i am beginner to objective c .i am trying to compile the following program in GNUStep on windows i got the following error mentioned at the end . please tell how to clear the error and say why it came.


#import <Foundation/Foundation.h>

@interface Fraction: NSObject
{
int numerator;
int denominator;
}

-(void) print;
-(void) setNumerator: (int) n;
-(void) setDenominator: (int) d;
@end


@implementation Fraction
-(void) print
{
NSLog (@”%d/%d”,numerator,denominator);
}
-(void) setNumerator: (int) n
{
numerator = n;
}
-(void) setDenominator: (int) d
{
denominator = d;
}
@end



int main (void)
{

Fraction *frac1 = [[Fraction alloc] init];

Fraction *frac2 = [[Fraction alloc] init];

[frac1 setNumerator: 2];

[frac1 setDenominator: 3];

[frac2 setNumerator: 3];
[frac2 setDenominator: 7];

NSLog (@”First fraction is:”);

[frac1 print];

NSLog (@”Second fraction is:”);

[frac2 print];

[frac1 release];

[frac2 release];
}




user@hnode-55 /c/GNUStep/home/user/fraction
$ gcc -o Fra Fra.m -I /GNUstep/System/Library/Headers -L /GNUstep/System/Librar
y/Libraries -lobjc -lgnustep-base -fconstant-string-class=NSConstantString
Fra.m: In function '-[Fraction print]':
Fra.m:19: error: stray '\224' in program
Fra.m:19: error: expected expression before '%' token
Fra.m:19: error: stray '\224' in program
Fra.m: In function 'main':
Fra.m:47: error: stray '\224' in program
Fra.m:47: error: 'First' undeclared (first use in this function)
Fra.m:47: error: (Each undeclared identifier is reported only once
Fra.m:47: error: for each function it appears in.)
Fra.m:47: error: expected ')' before 'fraction'
Fra.m:47: error: stray '\224' in program
Fra.m:51: error: stray '\224' in program
Fra.m:51: error: 'Second' undeclared (first use in this function)
Fra.m:51: error: expected ')' before 'fraction'
Fra.m:51: error: stray '\224' in program
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.