Unsure about Include errors

Go4Expert Member
19Oct2010,07:27   #1
Shihonoryu's Avatar
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
Go4Expert Founder
19Oct2010,07:57   #2
shabbir's Avatar
What you are trying to do BTW
Ambitious contributor
19Oct2010,10:40   #3
jimblumberg's Avatar
You need to either turn off pre-compiled headers or add
Code:
#include <stdafx.h>
and add the headers to stdafx.h

Jim
Shihonoryu like this
Go4Expert Member
19Oct2010,20:34   #4
Shihonoryu's Avatar
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
Go4Expert Member
19Oct2010,21:43   #5
Shihonoryu's Avatar
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.
Ambitious contributor
19Oct2010,22:34   #6
jimblumberg's Avatar
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
shabbir, Shihonoryu likes this
Go4Expert Member
20Oct2010,20:25   #7
Shihonoryu's Avatar
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?
Ambitious contributor
20Oct2010,21:22   #8
jimblumberg's Avatar
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 like this
Go4Expert Member
22Oct2010,02:33   #9
Shihonoryu's Avatar
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
Go4Expert Member
22Oct2010,02:36   #10
Shihonoryu's Avatar
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;