please help me to solve the error

This is a discussion on please help me to solve the error within the C++ Programming forums, part of the General Programming Boards category; i have a project called myprogram.(win32 console application) in myprogram, i have included function.h in function.h i have defined a ...

  1. #1
    Registered User
    Join Date
    Nov 2002
    Posts
    117

    please help me to solve the error

    i have a project called myprogram.(win32 console application)
    in myprogram, i have included function.h

    in function.h i have defined a function(e.g char* funcA), and in the function.cpp, i have type the definition of funcA, but when i compile it, error saids that

    "unexpected end of file while looking for precompiled header directive"

    how to solve this?

    thank you for helping.

  2. #2
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    Can we see the code please?
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  3. #3
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    in MSVC++ 6

    project / settings / C/C++ / Precompiled Headers / Not using precompiled headers


    or include the thing

    #include "stdafx.h"
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

  4. #4
    Registered User
    Join Date
    Nov 2002
    Posts
    117

    the code...

    thank you for helping ...here is the code(for example):
    myprogram.cpp:
    Code:
    #include <iostream.h>
    #include <function.h>
    
    int main()
    {
        cout << funcA() <<"\n";
        return 0;
    }
    function.h:
    Code:
    #include <iostream.h>
    #include <string.h>
    
    char* funcA();
    function.cpp:
    Code:
    #include <function.h>
    #include <iostream.h>
    #include <string.h>
    
    char*funcA()
    {
    char *st = new char[5];
    st = "halo";
    return st;
    }
    i cant copy the exact program cos it is too long....but if you think you need it...i can do so...

    by the way, my program is support MFC.
    and...i have tried to inclue the code in function.cpp in to function.h....it works....but....is that the only way out??

    TO fill your brain,

    thank you for helping, i have tried your suggestion, but i have ome code like getline(), ifstream in the program.....it treat all of them as errors.
    Last edited by Jasonymk; 05-01-2003 at 03:58 PM.

  5. #5
    Registered User
    Join Date
    Apr 2003
    Posts
    2,662
    I get an error if I try to use this statement in the file containing main()

    #include <function.h>

    Generally, the < > are for standard library header files. For you own header files you do this:

    #include "function.h"

    Also, these lines are unnecessary in function.h:

    #include <iostream.h>
    #include <string.h>

    since you don't reference anything from those header files in function.h.

  6. #6
    Registered User
    Join Date
    Nov 2002
    Posts
    117

    i have...

    i have done all these.....but still ...the same error...
    thank you for helping.

  7. #7
    Registered User
    Join Date
    Nov 2002
    Posts
    1,109
    maybe zip up the code and attach it.

  8. #8
    Registered User
    Join Date
    Nov 2002
    Posts
    117

    problem solved

    the method provided by fill your brain is right...

    thank you fillyourbrain!

  9. #9
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    no prob
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling sample DarkGDK Program
    By Phyxashun in forum Game Programming
    Replies: 6
    Last Post: 01-27-2009, 03:07 AM
  2. Testing some code, lots of errors...
    By Sparrowhawk in forum C Programming
    Replies: 48
    Last Post: 12-15-2008, 04:09 AM
  3. Another syntax error
    By caldeira in forum C Programming
    Replies: 31
    Last Post: 09-05-2008, 02:01 AM
  4. Quantum Random Bit Generator
    By shawnt in forum C++ Programming
    Replies: 62
    Last Post: 06-18-2008, 11:17 AM
  5. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 07:39 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21