Thread: Problem

  1. #1
    OLLand
    Guest

    Problem

    I am quite new to programing and need help!!!!!!!!!
    Upon compiling a program the following error arises.Compiling...

    cscript.cpp
    c:\program files\microsoft visual studio\myprojects\probing jet function\cscript.cpp(4) : fatal error C1083: Cannot open include file: 'stdafx.h': No such file or directory
    Error executing cl.exe.

    cscript.obj - 1 error(s), 0 warning(s)


    The begining of the program begins like this:
    I have a file called stdafx.h stored on one of my hard drives, but how to I get the program to regonise it?

    #include "stdafx.h"
    // AplCompare.cpp : Defines the entry point for the console aplication.



    // stdafx.h : include file for standard system include files,
    // or project specific include files that are used frequently, but
    // are changed infrequently
    //

    #if !defined(AFX_STDAFX_H__1FC0D17B_3DE6_4757_A80D_DF3 D8ECC34F5__INCLUDED_)
    #define AFX_STDAFX_H__1FC0D17B_3DE6_4757_A80D_DF3D8ECC34F5 __INCLUDED_

    #if _MSC_VER > 1000
    #pragma once
    //#endif // _MSC_VER > 1000

    #include <stdafx.h>
    #include <stdio.h>
    #include <string.h>
    #include <math.h>

    // TODO: reference additional headers your program requires here

    //{{AFX_INSERT_LOCATION}}
    // Microsoft Visual C++ will insert additional declarations immediately before the previous line.

    endif !defined(AFX_STDAFX_H__1FC0D17B_3DE6_4757_A80D_DF3 D8ECC34F5__INCLUDED_)

  2. #2
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,130
    I have a file called stdafx.h stored on one of my hard drives, but how to I get the program to regonise it?
    #include <file.h>

    This line will look for file.h in your compilers include folders

    #include "file.h"

    This line will look for file.h in your workspace directory where the rest of your files are

    #include "C:\somewhere\obscure\so\noone\will\ever\find\it\f ile.h"

    Looks for file.h in the given path. This is frowned upon, as it is higly unlikely other people store their include files in the same path you set up, so any time you share code someone has to change it first to make it work.


    Solution: copy it to your project. StdAfx.h should be created by your MSVC compiler and saved to your workspace directory anyway.
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

  3. #3
    ....
    Join Date
    Aug 2001
    Location
    Groningen (NL)
    Posts
    2,380
    When you create a MFC project in VC++, stdafx.h is automatically created in your project directory. A solution is to create a new project and add you're own sourcefiles to that project.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help understanding a problem
    By dnguyen1022 in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2009, 04:21 PM
  2. Memory problem with Borland C 3.1
    By AZ1699 in forum C Programming
    Replies: 16
    Last Post: 11-16-2007, 11:22 AM
  3. Someone having same problem with Code Block?
    By ofayto in forum C++ Programming
    Replies: 1
    Last Post: 07-12-2007, 08:38 AM
  4. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 02:51 PM
  5. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 06:54 PM