missing file header

Mar 27, 2012 at 6:55pm
Anybody,.. i was coding a program based a tutorial and than, i didn't find a file header in include dir, for example <stdafx.h>, because error message told me about that. Can i find it by download and put that h file in include dir? Thanks.
Mar 27, 2012 at 6:56pm
closed account (S6k9GNh0)
stdafx.h is generally a precompiled header used in VC++. You can probably just removed that include directive.
Mar 27, 2012 at 7:11pm
It's a pre-compiled header. If you've created your project, then you probably don't need this if you don't know what it is. To get rid of this error:

1. Remove references to <stdafx.h> in your source files.
2. Right click on your project in the Solution Explorer.
3. Choose 'Properties'
4. In the property window, select Configuration Properties > C/C++ > Precompiled headers.
5. In the "Precompiled Header" field, select "Not using precompiled headers"
Mar 27, 2012 at 7:15pm
computerquip..
I did, but i got 1 error message. This my code before removed stdafx.h, I'm using wxDev-C++
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
#include "stdafx.h"
#include <stdio.h>
#include <tchar.h>
#include <iostream>
#include <math.h>
#include <conio.h>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <dos.h>
// We need to output stuff, and we need the sine function

using namespace std;

 int sinewave()
{
    srand((unsigned)time(0));
    // declarations
    FILE *fptr;
    char fileName[50] = "";
    double freq;
    double gain;
    double phase;
    double bias;
    double noise;
    char save;
    const long double PI = acos((long double) -1);

    // user inputs for sine wave values

    cout<<"Enter Frequency: [1-10Mhz] ";
        cin>>freq;
    cout<<"Enter Gain of Sine Wave: [1-10] ";
        cin>>gain;
    cout<<"Enter Phase Angle: [0-180] ";
        cin>>phase;
    cout<<"Enter Bias (offset) [+/- 10] ";
        cin>>bias;
    cout<<"Enter % Noise level introduced to sine (percent) [0 - 100%] ";
        cin>>noise;
    cout<<"Do you want to save the data [y/n]: ";
        cin>>save;

    if (save == 'y')
       {
        cout<<"Enter a file name you wish to use: ";
            cin>> fileName;
       }

    double timeint = (double)1/freq/360;
    long double interval = (2*PI)/360;
    long double sinevalue;
    if (save = 'y')
       {
        sprintf(fileName, "%s.csv", fileName);
        fptr = fopen(fileName, "w");
        fprintf(fptr, "%s,", "Time(1/f)");
        fprintf(fptr, "%s\n", "Sine Pattern");
       }
    for(int i=0; i<=360; i++)
      {
        sinevalue = (gain*sin((interval*i)+phase)+(rand()*(noise/100)*gain))+bias;
        if (save = 'y')
         {
            fprintf(fptr, "%f,", timeint*i);
            fprintf(fptr, "%f\n", sinevalue);
         }
      }

    system("PAUSE");
    return EXIT_SUCCESS;
}

Mar 27, 2012 at 7:31pm
Mind about posting your error message at least?
We could solve your problem 10 times faster, if you tell us what's the error message. Anyways, if it's about "Missing precompiled header" or similar, you have to turn off the precompiled header option in your project settings.
EDIT: Just noticed, there is no entry point. Declare your "int main()" function.
RE-EDIT: You just needed three includes: <cstdio>, <cmath> and <iostream>.
RE-RE-EDIT: Change your "system("pause")" into "cin.get()".
Last edited on Mar 27, 2012 at 7:33pm
Mar 27, 2012 at 7:37pm
Stewbond..
i didn't find like what you mean. I didn't find Solution Explorer. But, i got properties, in properties i didn't find Precompiled Header.
Mar 27, 2012 at 7:41pm
Did you try to remove the ' #include "stdafx.h" ' line at least?
You cannot find "Precompiled header" in project options because you are using wxDev-C++ (So also ignore that part on my post)
Mar 27, 2012 at 8:04pm
EssGeEich..
i was removed #include "stdafx.h" and the error message that is,
[Linker error] undefined reference to 'WinMain@16'
ld returned 1 exit status.
[Build error][Output/MingW/grap.exe] Error 1
Mar 27, 2012 at 8:49pm
It's nothing related to stdafx. You have to declare your main function. Where is your program supposed to start? It has no start. Did you notice? It simply asks you to create a starting point.
Mar 28, 2012 at 3:19am
EssGeEich..
So, what must i do?
Mar 28, 2012 at 11:17am
You didn't answer my question. Where is your program supposed to start at?
Mar 28, 2012 at 7:34pm
line 15th
Last edited on Mar 28, 2012 at 7:35pm
Mar 28, 2012 at 8:30pm
Replace line 15 with int main()
Mar 28, 2012 at 10:26pm
Thanks Stewbond..
But, they working only until line 42nd
Mar 29, 2012 at 5:18am
if you type anything other than lower-case y, filename will be uninitialized for the printing. I bet that is your problem.
Mar 29, 2012 at 11:05am
Thanks again Stewbond..
Topic archived. No new replies allowed.