I get this code from a book but i could not get it work. What is my problem here? As the title says
“No previous prototype for function BOOL areIntsDifferent (int thing1, int thing2 ) and NSString * boolString (BOOL yesNo)”
#import <Foundation/Foundation.h>
BOOL areIntsDifferent (int thing1, int thing2 ) {
if ( thing1 == thing2) {
return (NO);
}
else {
return (YES);
}
}
NSString * boolString (BOOL yesNo) {
if (yesNo== NO) {
return (@"NO");
}
else {
return (@"YES");
}
}
int main (int argc, const char * argv[]) {
BOOL aretheydiffrent;
aretheydiffrent = areIntsDifferent (5,5);
NSLog(@"are %d and %d diffrent? %@", 5, 5, boolString(aretheydiffrent));
aretheydiffrent = areIntsDifferent(23,42);
NSLog(@"are %d and %d diffrent? %@", 23, 42, boolString(aretheydiffrent));
return 0;
}
The error message translates to:
Making the functions
staticshould sort this out: