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

A m a n y ~

macrumors newbie
Original poster
Jun 9, 2009
9
0
hi every one here
how r u all ? :D
I hope all one here is fine

I try to learn these code ,, it's not from my mind ,, I'm just try to learn it then I will write nearly and same like it ,, but Xcode give me to problems
unfortunately I did not know it where in these code and how I fix it

PHP:
#import <Foundation/Foundation.h>
typedef enum {
kCircle,
kRectangle,
kOblateSpheroid
} ShapeType;

typedef enum {
kRedColor,
kGreenColor,
kBlueColor
} ShapeColor;

typedef struct {
int x, y, width, height;
} ShapeRect;

typedef struct {
ShapeType type;
ShapeColor fillColor;
ShapeRect bounds;
} Shape;

int main (int argc, const char * argv[])
{
Shape shapes[3];
ShapeRect rect0 = { 0, 0, 10, 30 };
shapes[0].type = kCircle;
shapes[0].fillColor = kRedColor;
shapes[0].bounds = rect0;
ShapeRect rect1 = { 30, 40, 50, 60 };
shapes[1].type = kRectangle;
shapes[1].fillColor = kGreenColor;
shapes[1].bounds = rect1;
ShapeRect rect2 = { 15, 18, 37, 29 };
shapes[2].type = kOblateSpheroid;
shapes[2].fillColor = kBlueColor;
shapes[2].bounds = rect2;
drawShapes (shapes, 3);
return (0);
} // main


Dwo28968.jpg



thanx at all my lovers and dears
:rolleyes:



 
Looks like you're calling drawShapes() which doesn't exist anywhere, or if it is you aren't compiling it with the rest of your code.
 
You're calling a function named drawShapes. If you don't know why that is failing, I suggest you go pick up a book or tutorial on the C language.
 
thanx dear
I was learn some of c on windows ,, I was use C borland and netbeans
I know what does mean function ,,,
now I remember that ,,
:)


can I ask you small question
in c we was write {printf} for output
in objective C we write {NSLog} to include most thing

we was write {scanf} to give the input
what we can write in objective c ?

I'm sorry if my questions bother you ,,,
 
in c we was write {printf} for output
in objective C we write {NSLog} to include most thing

we was write {scanf} to give the input
what we can write in objective c ?

NSLog actually has quite a different use than printf. NSLog actually logs a line of text to the system logs, while printf just writes it to the console. That's why there's no such equivalent of scanf as you can't ask the log to type a line of text. I suggest just sticking with printf and scanf if that's what your book is working with. You can use them if you include their regular header.
 
PHP:
#import <Foundation/Foundation.h>
typedef enum {
kCircle,
kRectangle,
kOblateSpheroid
} ShapeType;

typedef enum {
kRedColor,
kGreenColor,
kBlueColor
} ShapeColor;

typedef struct {
int x, y, width, height;
} ShapeRect;

typedef struct {
ShapeType type;
ShapeColor fillColor;
ShapeRect bounds;
} Shape;

int main (int argc, const char * argv[])
{
Shape shapes[3];
ShapeRect rect0 = { 0, 0, 10, 30 };
shapes[0].type = kCircle;
shapes[0].fillColor = kRedColor;
shapes[0].bounds = rect0;
ShapeRect rect1 = { 30, 40, 50, 60 };
shapes[1].type = kRectangle;
shapes[1].fillColor = kGreenColor;
shapes[1].bounds = rect1;
ShapeRect rect2 = { 15, 18, 37, 29 };
shapes[2].type = kOblateSpheroid;
shapes[2].fillColor = kBlueColor;
shapes[2].bounds = rect2;

drawShapes (shapes, 3);
return (0);
} // main


int drawShapes (Shape shapes[], int count)
{
int i;
for (i = 0; i < count; i++) {
switch (shapes[i].type) {

case kCircle:
drawCircle (shapes[i].bounds,
shapes[i].fillColor);
break;
case kRectangle:
drawRectangle (shapes[i].bounds,
shapes[i].fillColor);
break;
case kOblateSpheroid:
drawEgg (shapes[i].bounds,
shapes[i].fillColor);
break;

return(0);
}
}
}
int drawCircle (ShapeRect bounds,ShapeColor fillColor)
{


NSLog (@"drawing a circle at (%d %d %d %d) in %@",
bounds.x, bounds.y,
bounds.width, bounds.height,colorname(fillColor));
return(0);
} // drawCircle

NSString *colorname (ShapeColor colorname)
{
switch (colorname)
 {
case kRedColor:
return @"red";
break;
case kGreenColor:
return @"green";
break;
case kBlueColor:
return @"blue";
break;
}
return @"dd";
} // colorName
#import <Foundation/Foundation.h>
typedef enum {
kCircle,
kRectangle,
kOblateSpheroid
} ShapeType;

typedef enum {
kRedColor,
kGreenColor,
kBlueColor
} ShapeColor;

typedef struct {
int x, y, width, height;
} ShapeRect;

typedef struct {
ShapeType type;
ShapeColor fillColor;
ShapeRect bounds;
} Shape;

int main (int argc, const char * argv[])
{
Shape shapes[3];
ShapeRect rect0 = { 0, 0, 10, 30 };
shapes[0].type = kCircle;
shapes[0].fillColor = kRedColor;
shapes[0].bounds = rect0;
ShapeRect rect1 = { 30, 40, 50, 60 };
shapes[1].type = kRectangle;
shapes[1].fillColor = kGreenColor;
shapes[1].bounds = rect1;
ShapeRect rect2 = { 15, 18, 37, 29 };
shapes[2].type = kOblateSpheroid;
shapes[2].fillColor = kBlueColor;
shapes[2].bounds = rect2;

drawShapes (shapes, 3);
return (0);
} // main


int drawShapes (Shape shapes[], int count)
{
int i;
for (i = 0; i < count; i++) {
switch (shapes[i].type) {

case kCircle:
drawCircle (shapes[i].bounds,
shapes[i].fillColor);
break;
case kRectangle:
drawRectangle (shapes[i].bounds,
shapes[i].fillColor);
break;
case kOblateSpheroid:
drawEgg (shapes[i].bounds,
shapes[i].fillColor);
break;

return(0);
}
}
}
int drawCircle (ShapeRect bounds,ShapeColor fillColor)
{


NSLog (@"drawing a circle at (%d %d %d %d) in %@",
bounds.x, bounds.y,
bounds.width, bounds.height,colorname(fillColor));
return(0);
} // drawCircle

NSString *colorname (ShapeColor colorname)
{
switch (colorname)
 {
case kRedColor:
return @"red";
break;
case kGreenColor:
return @"green";
break;
case kBlueColor:
return @"blue";
break;
}
return @"dd";
} // colorName

it's all program ,,
also it's doesn't work
:(
 
You seem to have pasted the code two times into the message.

Also the code is badly formatted.

I think it's quite hard for anyone to 1) see if the code is different or if you pasted it twice exactly and 2) see where the code blocks are because your indentation is so hard to read.
 
I will explain what these code do , and the function code
I tried to edit it , but I can not

I will try again :apple:
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.