Is This right?

This is a discussion on Is This right? within the C++ Programming forums, part of the General Programming Boards category; Will this work? If not how can i fix it? /* A program to input a word and draw and ...

  1. #1
    Registered User
    Join Date
    Sep 2001
    Posts
    10

    Is This right?

    Will this work? If not how can i fix it?

    /* A program to input a word and draw and Chinese character
    for the given word.*/

    #include “GUIObj.h”
    #include “Turtles.h”
    #include <string.h>

    void main()
    {
    char outString[MAX+1] = “ “,
    word[10];
    StringTypeIn strInputBox;
    OKBox msgBox;
    YesNoBox Prompt;
    const int Yes = 1;
    Turtle t;

    t.init(260,180);

    while(answer == yes) {
    strcpy(word,
    strInputBox.GetString(“String Input”, “Type In a Word”));

    strcat(outString, word);

    if (strcmp(word, “sun”) = 0) {
    t.move(50); t.turn(90);
    t.move(70); t.turn(90);
    t.move(50); t.turn(90);
    t.move(70); t.turn(180);
    t.move(35); t.turn(90);
    t.move(50); t.done ();
    }
    else if (strcmp(word, “moon”) = 0) {
    t.move(50); t.turn(90);
    t.move(60); t.turn(90);
    t.move(50); t.turn(90);
    t.move(70; t.GoToPos(260,180);
    t.GoToPos(310,180);
    t.GoToPos(310,150);
    t.GoToPos(260,150);
    penup (); t.GoToPos(310,180);
    pendown (); t.GoToPos(310, 195);
    t.done();
    }
    else if(strcmp(word, “river”) = 0) {
    t.GoToPos(260,240);
    penup (); t.GoToPos(275,230);
    pendown (); t.GoToPos(275,190);
    penup (); t.GoToPos(290,180);
    pendown (); t.GoToPos(290,245);
    t.done ();
    }
    else if(strcmp(word, “mountain”) = 0) {
    t.GoToPos(260,210); t.GoToPos(300,210);
    t.GoToPos(300,180); penup ();
    t.GoToPos(280,165); pendown ();
    t.GoToPos(280,210); t.done ();
    }
    }
    Jimmy

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,344
    > while(answer == yes) {
    1. answer is undeclared
    2. yes should be perhaps Yes

    > strcat(outString, word);
    What does this do?

    > if (strcmp(word, “sun”) = 0) {
    Should be
    if (strcmp(word, “sun”) == 0) {

    > void main()
    The old favourite - main returns an int
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21