Why my program not work

Discussion in 'Mac Programming' started by A m a n y ~, Sep 1, 2009.

  1. A m a n y ~ macrumors newbie

    Joined:
    Jun 9, 2009
    #1
    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 xywidthheight;
    ShapeRect;

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

    int main (int argc, const char argv[])
    {
    Shape shapes[3];
    ShapeRect rect0 = { 001030 };
    shapes[0].type kCircle;
    shapes[0].fillColor kRedColor;
    shapes[0].bounds rect0;
    ShapeRect rect1 = { 30405060 };
    shapes[1].type kRectangle;
    shapes[1].fillColor kGreenColor;
    shapes[1].bounds rect1;
    ShapeRect rect2 = { 15183729 };
    shapes[2].type kOblateSpheroid;
    shapes[2].fillColor kBlueColor;
    shapes[2].bounds rect2;
    drawShapes (shapes3);
    return (
    0);
    // main

    [​IMG]


    thanx at all my lovers and dears
    :rolleyes:



     
  2. kainjow Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #2
    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.
     
  3. A m a n y ~ thread starter macrumors newbie

    Joined:
    Jun 9, 2009
  4. kainjow Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #4
    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.
     
  5. A m a n y ~ thread starter macrumors newbie

    Joined:
    Jun 9, 2009
    #5
    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 ,,,
     
  6. Sijmen macrumors 6502a

    Joined:
    Sep 7, 2005
    #6
    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.
     
  7. A m a n y ~ thread starter macrumors newbie

    Joined:
    Jun 9, 2009
    #7
    PHP:
    #import <Foundation/Foundation.h>
    typedef enum {
    kCircle,
    kRectangle,
    kOblateSpheroid
    ShapeType;

    typedef enum {
    kRedColor,
    kGreenColor,
    kBlueColor
    ShapeColor;

    typedef struct {
    int xywidthheight;
    ShapeRect;

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

    int main (int argc, const char argv[])
    {
    Shape shapes[3];
    ShapeRect rect0 = { 001030 };
    shapes[0].type kCircle;
    shapes[0].fillColor kRedColor;
    shapes[0].bounds rect0;
    ShapeRect rect1 = { 30405060 };
    shapes[1].type kRectangle;
    shapes[1].fillColor kGreenColor;
    shapes[1].bounds rect1;
    ShapeRect rect2 = { 15183729 };
    shapes[2].type kOblateSpheroid;
    shapes[2].fillColor kBlueColor;
    shapes[2].bounds rect2;

    drawShapes (shapes3);
    return (
    0);
    // main


    int drawShapes (Shape shapes[], int count)
    {
    int i;
    for (
    0counti++) {
    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.xbounds.y,
    bounds.widthbounds.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 xywidthheight;
    ShapeRect;

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

    int main (int argc, const char argv[])
    {
    Shape shapes[3];
    ShapeRect rect0 = { 001030 };
    shapes[0].type kCircle;
    shapes[0].fillColor kRedColor;
    shapes[0].bounds rect0;
    ShapeRect rect1 = { 30405060 };
    shapes[1].type kRectangle;
    shapes[1].fillColor kGreenColor;
    shapes[1].bounds rect1;
    ShapeRect rect2 = { 15183729 };
    shapes[2].type kOblateSpheroid;
    shapes[2].fillColor kBlueColor;
    shapes[2].bounds rect2;

    drawShapes (shapes3);
    return (
    0);
    // main


    int drawShapes (Shape shapes[], int count)
    {
    int i;
    for (
    0counti++) {
    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.xbounds.y,
    bounds.widthbounds.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
    :(
     
  8. A m a n y ~ thread starter macrumors newbie

    Joined:
    Jun 9, 2009
  9. zippyfly macrumors regular

    Joined:
    Mar 22, 2008
    #9
    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.
     
  10. A m a n y ~ thread starter macrumors newbie

    Joined:
    Jun 9, 2009
    #10
    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:
     

Share This Page