help with c++ please

Discussion in 'Computing, Science, and Technology' started by Chrisschulz, Mar 6, 2009.

  1. Chrisschulz

    Chrisschulz New Member

    Joined:
    Jan 20, 2009
    Messages:
    892
    Likes Received:
    0
    Device:
    2G iPod touch
    okay so im just learning c++ and am running into a few bugs .
    ive succesfully made my first program, the official "hello world" one.

    Please Register or Log in to view images


    so i ran into a few bugs. im building one that computes the area. heres what i got
    // finding the area of a rectangle
    #include <iostream>

    typedef unsinged short int USHORT; //typedef defined

    int main()
    {

    using std::cout;
    using std::end1;

    USHORT Width = 5;
    USHORT Length;
    Length = 10;
    USHORT Area = Width * Length;
    cout << "Width:" << Width << end1;
    cout << "Length:" << length << end1;
    cout << "Area: " << Area <<end1;
    char response;
    std::cin >> response;
    return 0;
    }
    heres a couple of the errors im getting.
    4 C:\Documents and Settings\Dave and Tracy\Desktop\chris' c++\area of rectangle.cpp expected init-declarator before "short"
    4 C:\Documents and Settings\Dave and Tracy\Desktop\chris' c++\area of rectangle.cpp expected `,' or `;' before "short"
    12 C:\Documents and Settings\Dave and Tracy\Desktop\chris' c++\area of rectangle.cpp expected `;' before "Width"
    those are just a few.
    im looking for some friendly help

    Please Register or Log in to view images


    thanks
    ------------------double post merged------------------
    any help?
  2. jakecigar

    jakecigar New Member

    Joined:
    Mar 7, 2008
    Messages:
    83
    Likes Received:
    6
    Device:
    iPhone 4 (Black)
    you got burned! what is unsinged?
  3. Chrisschulz

    Chrisschulz New Member

    Joined:
    Jan 20, 2009
    Messages:
    892
    Likes Received:
    0
    Device:
    2G iPod touch
    Unsigned? You mean what needs to be labeled unsigned ?
  4. jakecigar

    jakecigar New Member

    Joined:
    Mar 7, 2008
    Messages:
    83
    Likes Received:
    6
    Device:
    iPhone 4 (Black)
    Spelling counts! "unsigned" isn't "unsinged"

    one means without a sign, the other means not burned.


    you got burned by the spelling police!
  5. veeloc

    veeloc New Member

    Joined:
    Sep 6, 2008
    Messages:
    815
    Likes Received:
    0
    Device:
    iPhone 3GS (Black)
    yeah spelling does count, that happened to me one time.

    heres is some much more similar code:
    #include <iostream.h>

    int main()
    {

    int Width = 5;
    int Length = 5;
    int Area = Width * Length;

    cout << "Width: " << Width << "\n";
    cout << "Length: " << Length << "\n";
    cout << "Area: " << Area << "\n";

    return (0);
    }

    this just simply sets your variables, then it says whatever they are, and then the variable itself, and then a line break with cout.
    then it does it again for length, and then it does it again for area. and then ends it.


    im not sure what your trying to accomplish... if anything else, so provide some more details and ill help you through it, but your code had a lot of unnecessary things in it.
    ------------------double post merged------------------
    oh and most of your errors would have been fixed by very few modifications...
    but i just wrote some much similar stuff instead.
  6. Chrisschulz

    Chrisschulz New Member

    Joined:
    Jan 20, 2009
    Messages:
    892
    Likes Received:
    0
    Device:
    2G iPod touch
    dude, thanks! i completely forgot to check the spelling. wow i feel stupid.
    thanks guys
  7. jakecigar

    jakecigar New Member

    Joined:
    Mar 7, 2008
    Messages:
    83
    Likes Received:
    6
    Device:
    iPhone 4 (Black)
    it's the compiler's way of teaching spelling... not very effective!
  8. wibble

    wibble New Member

    Joined:
    Mar 16, 2008
    Messages:
    176
    Likes Received:
    0
    wrong. signed and unsigned refer to ranges.

    and if your going to use a typedef for 3 words, just create a struct.
  9. jakecigar

    jakecigar New Member

    Joined:
    Mar 7, 2008
    Messages:
    83
    Likes Received:
    6
    Device:
    iPhone 4 (Black)
    learn to spell wibble! S I G N isn't S I N G!
    or at least learn to SING!

Share This Page