#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2011
    Posts
    4
    Rep Power
    0

    What am i doing wrong?


    // variables1.cpp - Script 2.1

    // We need the iostream file in order
    // to use cout and cin.
    #include <iostream>

    // Start the main function.
    int main() {
    // Declare the variables to be used.
    unsigned short quantity;
    float price;
    float taxRate;

    // Print some introductory text.
    std::cout << "- Widget Cost Calculator-\n";

    // Wait for the user to press Enter or Return.
    std::cin.get();

    //Return the value 0 to indicate no problems.
    return 0;

    } // End of the main() function.

    this is the code i used im using a C++ programming book to teach myself C++ and when i try to compile it gives me these errors:
    multiple definition of 'main'
    first defined here
    id returned 1 exit status
    [Build Error] [hello.exe] Error 1

    the last error may be associated with the other file in my project which is:
    #include <iostream>

    using namespace std;

    int main (int argc, char *argv[])
    {
    cout << "Hello World!" << endl;
    cout << "Press ENTER to continue..." << endl;
    cin.get();
    return 0;
    }

    I have no clue what these errors mean and have no clue how to fix them can someone please tell me how?
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2011
    Posts
    4
    Rep Power
    0
    Well i feel kinda stupid. I had a project open with both those source files and i tried to compile it all together. so i just opened the source files by themselves outside the project and compiled them separate and it worked perfect! so i solved my own problem before anyone could even respond to my forum... must be a record lol. Well i hope this helps anyone else who runs across this problem.

IMN logo majestic logo threadwatch logo seochat tools logo