Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C++ (http://www.go4expert.com/forums/cpp/)
-   -   Unsure about Include errors (http://www.go4expert.com/forums/unsure-include-errors-t23612/)

Shihonoryu 19Oct2010 07:27

Unsure about Include errors
 
I have these errors:

Code:

\Calculator.cpp(33) : warning C4627: '#include <cstdlib>': skipped when looking for precompiled header use
1>        Add directive to 'stdafx.h' or rebuild precompiled header
1>.\Calculator.cpp(34) : warning C4627: '#include <iostream>': skipped when looking for precompiled header use
1>        Add directive to 'stdafx.h' or rebuild precompiled header
1>.\Calculator.cpp(35) : warning C4627: '#include <string>': skipped when looking for precompiled header use
1>        Add directive to 'stdafx.h' or rebuild precompiled header
1>.\Calculator.cpp(36) : warning C4627: '#include "AllMath_H.h"': skipped when looking for precompiled header use
1>        Add directive to 'stdafx.h' or rebuild precompiled header
1>.\Calculator.cpp(172) : fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "stdafx.h"' to your source?
1>AllMath.cpp
1>.\AllMath.cpp(3) : warning C4627: '#include "allmath_h.h"': skipped when looking for precompiled header use
1>        Add directive to 'stdafx.h' or rebuild precompiled header
1>.\AllMath.cpp(4) : warning C4627: '#include <iostream>': skipped when looking for precompiled header use
1>        Add directive to 'stdafx.h' or rebuild precompiled header




from this code....

Code:

#include <cstdlib>
#include <iostream>
#include <string>
#include "AllMath_H.h"


yeah i dont understand it at all

shabbir 19Oct2010 07:57

Re: Unsure about Include errors
 
What you are trying to do BTW

jimblumberg 19Oct2010 10:40

Re: Unsure about Include errors
 
You need to either turn off pre-compiled headers or add
Code:

#include <stdafx.h>
and add the headers to stdafx.h

Jim

Shihonoryu 19Oct2010 20:34

Re: Unsure about Include errors
 
Alright, i foxed all that. now i have another error.

i have this code:

Code:

                system("cls");

and get this error:

[COD1>c:\users\dad\documents\visual studio 2008\projects\calculator1\calculator1\calculator1. cpp(176) : error C3861: 'clrscr': identifier not foundE][/CODE]




and what im making a is a calculator, that calculates The area of a any 3 shapes, and also does basic operations

Shihonoryu 19Oct2010 21:43

Re: Unsure about Include errors
 
Now i have One more error and my code "should be" completely debugged.(Till i add something else :P)



Code:

HTML Code:

//Includes:
#include <cstdlib>
#include <iostream>
#include <string>
#include "AllMath_H.h"


int main()
{
        int looping = 0;
        using namespace std;
    string choice1;
    while (looping == 0)
{
    system("cls");
    cout << "====================================================" << endl;
    cout << "====                Main Menu                  ====" << endl;
    cout << "====================================================" << endl;
    cout << "====================================================" << endl;
    cout << "====  Please enter what calculation you want.  ====" << endl;
    cout << "==== A. Find the area of a shape.              ====" << endl;
    cout << "==== B. basic calculation.(not implemented yet) ====" << endl;
    cout << "====================================================" << endl;
    cout << "====================================================" << endl;
    cout << "Please Choose: ";
    cin >
> choice1;
    cout << " ";
    if (choice1 == "A")
   
{
    system("cls");
    cout << "Please enter what shape you want to find the area of(circle, triangle, or square. CAP SENSITIVE)" << endl;
    string choice;
    cin >
> choice;

if ( choice == "circle" )//CIRCLE CHOICE

{
        system("cls");
        cout << "Please enter the radius of your circle" << endl;
        int x;
        cin >
> x;
        findAreaOfCircle(x);
        cout << "Do you want to use the calculator again?" << endl;
        string awnser;
        cin >
> awnser;

        if (awnser == "no")
{
        cout << "goodbye!" << endl;
        looping = 1;
}

       
         
}

else if ( choice == "square")//square choice

{
    system("cls");
    int L;
    int H;
    cout << "Please enter the length of your square" << endl;
    cin >
> L;
    cout << "Please enter the heigth of your square" << endl;
    cin >
> H;
    findAreaOfSquare(L,H);
              cout << "Do you want to use the calculator again?" << endl;
        string awnser;
        cin >
> awnser;

        if (awnser == "no")
{
        cout << "goodbye!" << endl;
        looping = 1;
}

}

else if ( choice == "triangle" )//Triangle choice

{
    system("cls");
    int H;
    int B;
    cout << "Please enter the base of your triangle" << endl;
    cin >
> B;
    cout << "Please enter the heigth of your triange" << endl;
    cin >
> H;
    FindAreaOfTriangle(H,B);
   
        cout << "Do you want to use the calculator again?" << endl;
        string awnser;
        cin >
> awnser;

        if (awnser == "no")
{
        cout << "goodbye!" << endl;
        looping = 1;
}
}
   
}





else if (choice1 == "B")
{

    cout << "Please choose what operation you wish to do." << endl;
    string choice;
    cin >
> choice;
    if (choice == "add")
    {
        int a;
        int b;
        system("cls");
        cout << "Please enter a number" << endl;
        cin >
> a;
        cout << "Please enter another number" << endl;
        cin >
> b;
        add(a,b);
        cout << "Do you want to use the calculator again?" << endl;
        string awnser;
        cin >
> awnser;

        if (awnser == "no")
{
        cout << "goodbye!" << endl;
        looping = 1;
}


    }


        else if(choice == "subtract")
        {
                int a;
                int b;
                system("cls");
                cout << "Whats the minuend?" << endl;
                cin >
> a;
                cout << "whats the subtrahend?" << endl;
                cin >
> b;
                subtract(a,b);
        cout << "Do you want to use the calculator again?" << endl;
        string awnser;
        cin >
> awnser;

        if (awnser == "no")
                        {
                                cout << "goodbye!" << endl;
                                looping = 1;
                        }


       







return 0;
}





Now thats the Entire Main() function the error is as follows:

1>c:\users\dad\documents\visual studio 2008\projects\calculator1\calculator1\calculator1. cpp(201) : fatal error C1075: end of file found before the left brace '{' at 'c:\users\dad\documents\visual studio 2008\projects\calculator1\calculator1\calculator1. cpp(141)' was matched



Now i have no idea how to fix this.

jimblumberg 19Oct2010 22:34

Re: Unsure about Include errors
 
system("cls") is operating system dependent. If you are on Windows it may need to be system("clear");

For your second question your braces do not match. You are missing at least 2. Using consistent indentation will help find these errors.

Jim

Shihonoryu 20Oct2010 20:25

Re: Unsure about Include errors
 
Hah! your right, i was missing Braces, 3 of them :(

So one question, im using Visual C++ 2008. how do i run a program? i cant find a "run" or anything anywhere, it runs the program when i debug, is that the only way?

jimblumberg 20Oct2010 21:22

Re: Unsure about Include errors
 
I am not sure how to run a program from Visual C++. But you can run a program from the command line. Sorry but I haven't used Windows in many years so I can't supply too many answers for that operating system.


Jim

Shihonoryu 22Oct2010 02:33

Re: Unsure about Include errors
 
This isnt a error but my Else statement to stop the user from entering incorrect input isnt working:


HTML Code:

if (choice1 == "A")
   
{
    system("cls");
    cout << "Please enter what shape you want to find the area of(circle, triangle, or square. CAP SENSITIVE)" << endl;
    string choice;
    cin >
> choice;

if ( choice == "circle" )//CIRCLE CHOICE

        {
        system("cls");
        cout << "Please enter the radius of your circle" << endl;
        int x;
        cin >
> x;
        findAreaOfCircle(x);
        cout << "Do you want to use the calculator again?" << endl;
        string awnser;
        cin >
> awnser;

        if (awnser == "no")
                {
        cout << "goodbye!" << endl;
        looping = 1;
                }

       
         
        }

else if ( choice == "square")//square choice

        {
    system("cls");
    int L;
    int H;
    cout << "Please enter the length of your square" << endl;
    cin >
> L;
    cout << "Please enter the heigth of your square" << endl;
    cin >
> H;
    findAreaOfSquare(L,H);
              cout << "Do you want to use the calculator again?" << endl;
        string awnser;
        cin >
> awnser;

        if (awnser == "no")
                {
        cout << "goodbye!" << endl;
        looping = 1;
                }

        }

        else if ( choice == "triangle" )//Triangle choice

        {
    system("cls");
    int H;
    int B;
    cout << "Please enter the base of your triangle" << endl;
    cin >
> B;
    cout << "Please enter the heigth of your triange" << endl;
    cin >
> H;
    FindAreaOfTriangle(H,B);
   
        cout << "Do you want to use the calculator again?" << endl;
        string awnser;
        cin >
> awnser;

        if (awnser == "no")
                {
        cout << "goodbye!" << endl;
        looping = 1;
                }


        else
        {
                cout << "Invalid choice\n";
        }

        }


When you enter something wrong, the loop just restarts at the beginning

Shihonoryu 22Oct2010 02:36

Re: Unsure about Include errors
 
What i want to happen is for it to go back to

cout << "Please enter what shape you want to find the area of(circle, triangle, or square. CAP SENSITIVE)" << endl;


All times are GMT +5.5. The time now is 03:23.