header question

i have this code that im gettin this error "1>Build log was saved at "file://c:\Users\madjao\Documents\Visual Studio 2008\Projects\school\Debug\BuildLog.htm"
where am i wrong??????
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*
   Simple program to compute the two possible roots of a quadratic equation.
*/

#include <iostream>
#include <iomanip>
#include <cmath>
#include"helper.h"
#include <ostream>

using namespace std;

struct cmplxNumber{
   double dReal, dImaginary;
} ;

bool ComputeRoots( double dCoefA, double dCoefB, double dCoefC, 
          cmplxNumber & Root1, cmplxNumber & Root2);

ostream & PrintComplex( ostream & outDevice, cmplxNumber Root );

int main()
{
   // Need some variable storage for parameters
   double dCoefA = 0.0, dCoefB = 0.0, dCoefC = 0.0;

   cout << "Enter coefficient A: ";
   cin >> dCoefA;
   cout << "Enter coefficient B: ";
   cin >> dCoefB;
   cout << "Enter coefficient C: ";
   cin >> dCoefC;


   cmplxNumber Root1, Root2;
   ComputeRoots( dCoefA, dCoefB, dCoefC, Root2, Root1 );

   cout << "\n\nThe first root is " << Root1.dReal;
   if( Root1.dImaginary < 0.0 ) {
      cout << " - " << abs(Root1.dImaginary) << " j" << endl;
   }
   else if( Root1.dImaginary > 0.0 ) {
      cout << " + " << Root1.dImaginary << " j" << endl; 
   }
   else 
      cout << endl;
   
   cout << "\n\nThe second root is ";
   PrintComplex( cout, Root2 );
 
   system("pause");
   return 0;
}


bool ComputeRoots( double dCoefA, double dCoefB, double dCoefC, 
          cmplxNumber & Root1, cmplxNumber & Root2)
{
	double dInter1, dInter2;
	dInter1 = dCoefB * dCoefB;  // get the square of B
	dInter2 = 4.0 * dCoefA * dCoefC;
	if(dInter1 < dInter2 ) {
	 	Root1.dImaginary = pow(abs(dInter1 - dInter2), 0.5)/ (2.0 * dCoefA);
		Root2.dImaginary = -pow(abs(dInter1 - dInter2), 0.5)/ (2.0 * dCoefA);
		Root1.dReal = Root2.dReal = -dCoefB / (2.0 * dCoefA);
	} else {
		Root1.dReal = (-dCoefB + pow(dInter1 - dInter2, 0.5))/ (2.0 * dCoefA);
		Root2.dReal = (-dCoefB - pow(dInter1 - dInter2, 0.5))/ (2.0 * dCoefA);
	}
	return true;
}




and this is the header
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#ifndef _helper
#define _helper


ostream & PrintComplex( ostream & outDevice, cmplxNumber Root )
{
   outDevice << Root.dReal;
   if( Root.dImaginary < 0.0 ) {
      outDevice << " - " << abs(Root.dImaginary) << " j" << endl;
   }
   else if( Root.dImaginary > 0.0 ) {
      outDevice << " + " << Root.dImaginary << " j" << endl; 
   }
   else 
      cout << endl;
   return outDevice;
}
#endif 
Last edited on
1) Wrong section.
2) That is not an error.
i meant this error

"1 : fatal error C1083: Cannot open include file: 'helper.h': No such file or directory"
1. Click "Edit Topic" at the top of your post and change the forum to either Beginners or General C++ Programming. Thanks :)
2. Is the header named "helper.h" and is it in the same exact directory as the file you are trying to include it in?
Last edited on
what im trying to do is to create a multi project file that contains header files related complex data type that is defined and a helper code file containing the functions related specifically to the complex numbers. but i have to use this program in order to do this

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#include <iostream>
#include <iomanip>
#include <cmath>

#include <ostream>

using namespace std;

struct cmplxNumber{
   double dReal, dImaginary;
} ;

bool ComputeRoots( double dCoefA, double dCoefB, double dCoefC, 
          cmplxNumber & Root1, cmplxNumber & Root2);

ostream & PrintComplex( ostream & outDevice, cmplxNumber Root );

int main()
{
   // Need some variable storage for parameters
   double dCoefA = 0.0, dCoefB = 0.0, dCoefC = 0.0;

   cout << "Enter coefficient A: ";
   cin >> dCoefA;
   cout << "Enter coefficient B: ";
   cin >> dCoefB;
   cout << "Enter coefficient C: ";
   cin >> dCoefC;


   cmplxNumber Root1, Root2;
   ComputeRoots( dCoefA, dCoefB, dCoefC, Root2, Root1 );

   cout << "\n\nThe first root is " << Root1.dReal;
   if( Root1.dImaginary < 0.0 ) {
      cout << " - " << abs(Root1.dImaginary) << " j" << endl;
   }
   else if( Root1.dImaginary > 0.0 ) {
      cout << " + " << Root1.dImaginary << " j" << endl; 
   }
   else 
      cout << endl;
   
   cout << "\n\nThe second root is ";
   PrintComplex( cout, Root2 );
 
   system("pause");
   return 0;
}


bool ComputeRoots( double dCoefA, double dCoefB, double dCoefC, 
          cmplxNumber & Root1, cmplxNumber & Root2)
{
	double dInter1, dInter2;
	dInter1 = dCoefB * dCoefB;  // get the square of B
	dInter2 = 4.0 * dCoefA * dCoefC;
	if(dInter1 < dInter2 ) {
	 	Root1.dImaginary = pow(abs(dInter1 - dInter2), 0.5)/ (2.0 * dCoefA);
		Root2.dImaginary = -pow(abs(dInter1 - dInter2), 0.5)/ (2.0 * dCoefA);
		Root1.dReal = Root2.dReal = -dCoefB / (2.0 * dCoefA);
	} else {
		Root1.dReal = (-dCoefB + pow(dInter1 - dInter2, 0.5))/ (2.0 * dCoefA);
		Root2.dReal = (-dCoefB - pow(dInter1 - dInter2, 0.5))/ (2.0 * dCoefA);
	}
	return true;
}

// declaration of function using 'things' from the stream devices is 
//  fairly exacting.  MUST use references to the device variables.
ostream & PrintComplex( ostream & outDevice, cmplxNumber Root )
{
   outDevice << Root.dReal;
   if( Root.dImaginary < 0.0 ) {
      outDevice << " - " << abs(Root.dImaginary) << " j" << endl;
   }
   else if( Root.dImaginary > 0.0 ) {
      outDevice << " + " << Root.dImaginary << " j" << endl; 
   }
   else 
      cout << endl;
   return outDevice;
You didn't answer my question; is the helper.h file actually in the same folder as that file that has the code you're trying to compile?
no the helper.h file was created. the code that im trying to compile is in the source folder and the helper.h file is in the header file. all i did was add a .h file to header folder then i copy the code and i paste on that helper.h
Topic archived. No new replies allowed.