Thread: Cannot open include file: 'stack.h'

  1. #1
    Registered User
    Join Date
    Nov 2006
    Posts
    40

    Cannot open include file: 'stack.h'

    hi all, my problem is that I cannot include stack.h , but it seems exists
    the error message : fatal error C1083: Cannot open include file: 'stack.h': No such file or directory

    I'm using VC++ 6.0 please , can you help me.

    Code:
    #include <iostream.h>
    #include <fstream.h>
    #include <string.h>
    #include <stack.h> <== error
    
    using namespace std;

  2. #2
    Sanity is for the weak! beene's Avatar
    Join Date
    Jul 2006
    Posts
    321
    Where is this file, is it in your include directory, or did you make it?

  3. #3
    Its hard... But im here swgh's Avatar
    Join Date
    Apr 2005
    Location
    England
    Posts
    1,688
    Uusally means stack.h is not listed in the include folder for the compiler. All your header filess are rather dated too. You should drop the .h on them all apart from stack as I am not sure if it requires it.
    The only thing I can sugguest is going onto Microsofts website and enquiring about stack.h. It may give you the answer you need.
    Double Helix STL

  4. #4
    Its hard... But im here swgh's Avatar
    Join Date
    Apr 2005
    Location
    England
    Posts
    1,688
    Oh, and beene, I love your avatar
    Double Helix STL

  5. #5
    Sanity is for the weak! beene's Avatar
    Join Date
    Jul 2006
    Posts
    321
    Thank you

  6. #6
    Registered User
    Join Date
    Nov 2006
    Posts
    40
    beene , no its not in my include, its in another include dirc - borland, I will get it

    thank you all

  7. #7
    The larch
    Join Date
    May 2006
    Posts
    3,573
    According to this C++ reference there is a standard <stack> library.

    When you are using C++ standard headers, don't put the ".h" at the end of them. If the library is inherited from C, drop ".h" and prefix "c" (e.g <cmath>, <cstdlib>, <cstdio>, <ctime> etc).

    If by #include <string.h> you mean the C++ string class, you are including a wrong library altogether (the C string library), and you have probably got away with this because <iostream> may include <string> for you.

    (With Dev-Cpp #include <stack.h> gives an "deprecated header" warning. Only #include <stack> compiles well. May-be VC++ doesn't have the deprecated versions of some headers at all?)
    Last edited by anon; 01-02-2007 at 12:16 PM.

  8. #8
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    It should be <iostream>, <fstream>, <string>, and <stack> or <iostream>, <fstream>, <cstring>, and <stack>, depending on whether you are using the C++ string class or C style string functions.

    <stack.h> is not deprecated and is not standard at all. Chances are that <stack> is different from the <stack.h> in Borland, so the code might have to change. Just copying over Borland's stack.h is probably a bad idea, switching to the standard <stack> header is a better idea, even if you have to adjust the current code.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Formatting a text file...
    By dagorsul in forum C Programming
    Replies: 12
    Last Post: 05-02-2008, 03:53 AM
  2. Replies: 3
    Last Post: 03-04-2005, 02:46 PM
  3. System
    By drdroid in forum C++ Programming
    Replies: 3
    Last Post: 06-28-2002, 10:12 PM
  4. Need a suggestion on a school project..
    By Screwz Luse in forum C Programming
    Replies: 5
    Last Post: 11-27-2001, 02:58 AM