Saturday, May 9, 2009

Why the error unable to open include file is coming ( C++)?

I have downloaded a C++ script from the net . it has 3 header files and 1 cpp file. I have put the header files in include directory of turbo C. but when I compile the cpp file ... it gives the error "unable to open include file" for all three header files...... Im new to programming in C++ . Kindly give suggestions ?

Why the error unable to open include file is coming ( C++)?
are you using #include %26lt;filename.h%26gt; ?





try this, copy the header files to your c:\


Now type your includes like this





#include "c:\filename.h"





this should work for you.


How can i include files(header) in c++?

i recently installed c++ in my computer and i wrote a program and compiled it and there were errors like unable to include file stdio.h,math.h,etc........ somebody tell me how to include the file ,the directory

How can i include files(header) in c++?
Use the code





#include %26lt;stdio.h%26gt; OR


#include "yourown.h"





But you must tell the compiler where these files are found


Will windows vista home basic support turbo c++??the header file # include<graphics.h>alone is not workng y??

i have got windows vista home basic op sys.a few days back i installed turbo C++. the header file # include%26lt;graphics.h%26gt; alone is nt working.but all other header files r working.y is this vista nt supporting this header file??and wat is the solution to this problem.

Will windows vista home basic support turbo c++??the header file # include%26lt;graphics.h%26gt;alone is not workng y??
Probably your compiler is unable to compile the code. Which version of turbo are you using? If it warns you that BGI graphics is not supported try using an earlier version of turbo c++compiler.
Reply:windows vista home basic op sys is a major head-ach these days.





It does not support most of the worlds softwares.


If u try to install a software an error uccers saying UNKNOWN OPERATING SYSTEM.





This is because the software cannot understand the operating system.





The latest softwares may support your op sys , engineers are making softwares which are compatable with vista these days.





Since Turbo C++ does not know what is vista it would not install successfully.





Its like teaching algebra to a 2 year old chield.


How do you end a c program starting with #include <stdio.h>?

Write a c program to evaluate a=(v-u)/t?


How do you end a c program starting with #include %26lt;stdio.h%26gt;?

How do you end a c program starting with #include %26lt;stdio.h%26gt;?
#include%26lt;stdio.h%26gt;


void main(){


float v,u,t;


float a=0;


printf("enter initial velocity: ");


scanf("%f",%26amp;u);


printf("enter final velocity: ");


scanf("%f",%26amp;v);


printf("enter the time: ");


scanf("%f",%26amp;t);


if(t!=0)


a = (v-u)/t;


printf("accelaration = %f",a);


}
Reply:#include%26lt;stdio.h%26gt;


void main()


{


int v,u,t,a;


printf("enter initial velocity,final velocity and time");


scanf("%d%d%d",%26amp;u,%26amp;v,%26amp;t);


a=(v-u)/t;


printf("accelaration = %d",a);


}

cvs

Help with c++ when I write "#include <iostream.h>" is has an error that say declaration syntax error

when I enter #include %26lt;iostream.h%26gt; it says, Error C:\TC\INCLUDE\IOSTREAM.H 38: Declaration syntax error





it has like more than 20 errors. but they are all thesame. it say declaration syntax error





But I have no probelm with #include %26lt;stdio.h%26gt;





How do I fix this? Please help me! By, the way I'm a beginner we were force to learned this subject because it is part of our computer class.

Help with c++ when I write "#include %26lt;iostream.h%26gt;" is has an error that say declaration syntax error
It's not complaining about your program, it is complaining about line 38 of iostream.h having a syntax error. Since that is a c++ system header perhaps your system is misconfigured or there is some compiler specific steps you need to take.
Reply:Unfortunately debugging programs is a pain. Often the actually error is not in the line reported but causes the break in that section. Double check all of you semi colons and see if you left some out. Often the simplest way to start.





Good luck.
Reply:did you save the file with a .c extension or a .cpp extension cause this can cause a violation
Reply:try:





#include%26lt;iostream%26gt;


using namespace std;








its because not all compilers are the same and there are different ways to write some syntax.





#include%26lt;iostream.h%26gt;





is for older compilers and older syntax


When i include iostream.h in my c++ program i get errors. what should i do?

error is C:\TC\INCLUDE\IOSTREAM.H 38:declaration syntax error


i include the file like #include%26lt;iostream.h%26gt;


my turbo c++ version is 1.01

When i include iostream.h in my c++ program i get errors. what should i do?
maybe... u didn't put any space between include and %26lt;iostream%26gt;...





example:





#include %26lt;iostream.h%26gt;








hope this will help you...


Why unable to open include file in c++?

in c++ any header file not include


project menu directories some information given my self not clear so ask question

Why unable to open include file in c++?
Any included files must be in your include path. If not the system will not be able to find them at compile time.





You might try to write your question with some punctuation so it is easier to understand. It is not really clear what you are trying to ask.


What do I need to include in a C program source code distribution?

I'm working on a C programming project, using Dev-C++. What files do I need to include if I want to distribute the source code? Besides the .c, .h, .rc files I wrote, there're .manifest, makefile... Which of those are needed in order to let others compile successfully, using any compiler they like?





And what is the use of those Dev-C++-generated files like .manifest, makefile?

What do I need to include in a C program source code distribution?
The makefile describes the build instructions and dependencies. You always want to include this.





Throw in the any other tool-generated files as well - it can't hurt, and if someone is using dev-c++, it would be welcome.





If you use a special library (like sdl), you may want to include it. This is up to you, and may depent on your target audience.





Document anything like that - include urls for where get libraries and and other stuff even if you do include them.

gardenia

How to open an include file in c program?

This C program starts with #include %26lt;stdio.h%26gt;. This line includes the "standard I/O library" into your program. The standard I/O library lets you read input from the keyboard (called "standard in"), write output to the screen (called "standard out"), process text files stored on the disk, and so on. It is an extremely useful library. C has a large number of standard libraries like stdio, including string, time and math libraries.

How to open an include file in c program?
Did you want to just look at the header file itself? If so, their location is dependent on the the operating system and the compiling system that you are working with.





Like with GCC on a *nix system, you can usually find them here.





/usr/local/include


/usr/lib/gcc-lib/target/version/includ...


/usr/target/include


/usr/include
Reply:go to the com.
Reply:Ummm... did you notice that you answered your own question? Have you perhaps got other things about this whole "C" programming gig you would like to know more about?


How to include *.c file in a C program?

note that the compiler used is TURBO C++

How to include *.c file in a C program?
All the files are included in the same way.


For example you can write it as





#include "file1.h"


#include "file2.c"


#include "file3.c"


.


You can't write " *.c ".....you have to mention all the file names separately in the program !!
Reply:I don't think there is a direct way to do this.





U can create a intermediate header file called allfiles.h which inturn


includes all the necassary C files. Your program can just use the %26lt;allfiles.h%26gt;





The allfiles.h can be generated thru another program(may be a batch file) to avoid manual effort


Can you include C++ source files in other ones?

C++ is really confusing me. I'm working on a project with a lot of files: source codes, header files, libraries. It is a jungle with tons of files, classes and structures that must be defined somewhere. I'm new to C++





What type of comunication can exist between C++ files? Can you declare classes or objects in one file and use it in another one? Or is it best to use functions? And can you call a function in one file from another?

Can you include C++ source files in other ones?
You define your function prototypes and/or class definitions in the header files and then implement them in the source files. The compiler is run against each source file and the included headers for each source file are copied into the source file. Then the compiler creates object/compiled code for the source file and spits out an object file. If another source file also includes the header file with functions implemented in another object file, the linker is provided with this information so that the external symbols can be resolved during linking. When you use an IDE such as Visual C++ this tedious stuff normally seen in a make file is all handled for you.





Basically just remember to put the definitions in the headers and implementation in source.





Example:





---------------------Stack.h----------...


#ifndef __STACK__


#define __STACK__





struct StackData


{


char Data;


StackData *Node;


};





class Stack


{


private:


StackData* m_Head;





public:


Stack();


virtual ~Stack();


void Push(char Data);


char Pop( void );


bool IsEmpty( void );


};





#endif





---------------------Stack.cpp--------...





#include "Stack.h"





#ifndef NULL


#define NULL 0


#endif








Stack::Stack(): m_Head(NULL) { /* Constructor */ }





// Destructor


Stack::~Stack()


{


while(m_Head != NULL)


{


StackData *OldNode = m_Head;


m_Head = m_Head-%26gt;Node;





delete OldNode;


}


}





void Stack::Push(char Data)


{


StackData *NewData = new StackData();





NewData-%26gt;Data = Data;


NewData-%26gt;Node = NULL;





if (m_Head == NULL)


{


m_Head = NewData;


}


else


{


NewData-%26gt;Node = m_Head;


m_Head = NewData;


}


}





char Stack::Pop( void )


{


char Result = '\0';





if(m_Head != NULL)


{


Result = m_Head-%26gt;Data;





StackData *OldData = m_Head;


m_Head = m_Head-%26gt;Node;


delete OldData;


}





return Result;





}





bool Stack::IsEmpty( void )


{


return (m_Head == NULL);


}





---------------------main.cpp---------...





#include %26lt;iostream%26gt;


#include %26lt;string%26gt;


#include %26lt;string.h%26gt;


#include "Stack.h"





using namespace std;





void main( void )


{


string sInput;


string sOutput;


Stack oStack;





cout %26lt;%26lt; "Enter a string: " %26lt;%26lt; endl;


cin %26gt;%26gt; sInput;





for( size_t i = 0; i %26lt; sInput.length(); i++)


oStack.Push(sInput[i]);





while(!oStack.IsEmpty())


sOutput += oStack.Pop();





if (sInput.compare(sOutput) == 0)


cout %26lt;%26lt; "It is a palindrome." %26lt;%26lt; endl;


else


cout %26lt;%26lt; "It is NOT a palindrome." %26lt;%26lt; endl;


}
Reply:You can #include "filename.cpp" to obtain a class(es)/functions, but I consider it poor programming. Typically you want to include only the header and link additional source file.
Reply:#include %26lt;file path%26gt;


JNI question: What is the need to include the header file generated by javah command in the C program?

The function definition itself specifies the JNIEXPORT keyword so that it is known as a dll export and it is not using anything really from the header file . What is the need to include it?


I experimented creating a C++ file without including it, created a dll out of it and calling it from java. But I get this exception below. Why?


Exception in thread "main" java.lang.UnsatisfiedLinkError: ObjectArrayTest.initInt2DArray(I)[[I





This line in my program seems to cause the problem:


jclass intArrCls = env-%26gt;FindClass("[I");

JNI question: What is the need to include the header file generated by javah command in the C program?
Based on the question, I'm assuming that you're not a C/C++ developer.





When constructing a DLL, you need a header file to interface to it.


Since you're developing in Java, think of a header file as an IDL file. An IDL file contains the complete interface definitions (like a header file in C). The corresponding Java class contains *both* the interface definitions and the implementations (like a C file).





C/C++ compilers use these header files to get "advance notification" of what to expect in the code. See this page http://en.wikipedia.org/wiki/Header_file for a complete explanation of the need to include header files.

aster

What is different between c++ include and java import?

The major difference would be that in C++ the actual file is included. The only advantage is that you could modularize and compile the code seperately. The executable code size will be as much as if you put all the files together and compiled it together.





But in Java, the technology itself is different. The Java files are compiled individually and the class files are not big at all, even if you import so many classes. The actual classes are loaded when you run the code.





So its a bit interpretation in Java. So, you might end up getting smart code in Java. For example if you have an empty loop for a million times, the Java will not even execute it even once, as the interpreter (unlike the compiled executable. Of course there are smart compilers for c that can take care of some things like this, but not as many things as java can do) will generate on the fly code.





Hope it answers.

What is different between c++ include and java import?
A C/C++ include statement lists a file which replaces the include statement in the source file. The contents of this included file can be anything, but are usually constants and function "declarations".





Java imports are used to help resolve symbol names that are not fully qualified in the source itself. As an example:





import java.util.*; allows one to abbreviate the class java.util.Map as "Map". Without the import statement, the fully qualified name would have to be written.





Java does not require explicit declarations before a symbol can be used. Therefore C++ includes and java imports are completely different.


How to add one program into the other using #include in c pgm?

say we have a pgm p1.c which has some function and definitions and the same functions are to be accessed in the other program p2.c. i want this to be done using the preprocessor directicve


#include "filename"

How to add one program into the other using #include in c pgm?
you can include another program by eg p1.c


#include "p1.c" - place p1.c in current directory


#include "d:\pro\p1.c" - place p1 in D:\pro\p1.c


What is the terminology 'include', 'library' in C programming?

What is the meaning of library, include in C programming?


any example show?

What is the terminology 'include', 'library' in C programming?
Includes are used by the compiler's pre-processor to "include" a header file. This file will typically have constants and function definitions.





Example


------------------------





#include %26lt;stdio.h%26gt;


int main (){


FILE *myfile;


myfile = fopen ( "somefile", "w+" );


fprintf ( myfile, "Hello File!\n" );


fclose ( myfile );


return 0;


}





--------------------------------





fprintf is a function that's defined in stdio.h. If you don't include the header file, the compiler will have no idea how to properly handle the function call.





The actual code for fprintf is in a library. Specifically the Standard C library. This library is fairly large and contains the code for common functions.





You don't tell the compiler about the library. You tell it about the include file. It will generate code with a "stub" for fprintf. Then when you use the linker, you tell the linker about the library. The linker will the replace the stub with the actual code for fprintf. Most modern compilers appear to perform the compile and link in one command, but it's really two separate steps.














( Note: this is an over simplification and doesn't cover dynamic linking , and the example code is a horrible example of proper error handling .)
Reply:An include statement allows a c program to use another chunk of code from another file.





For example, in C, you usually have to include the header file stdio.h which contains many of the common primative functions that are used in the normal course of C programming.





A simple example would be an include file which would contain an add function that would return the sum of two integers.





add.h





int add2ints(int,int);


int add2ints(int x, inty){


return (x+y);


}





mainprogram.c





#include %26lt;stdio.h%26gt;


#include %26lt;add.h%26gt;





int main(void){


int x=3;


int y=2;


int result=add(2,3);


printf(result);


}


If I were to translate this program from c: #include <stdio.h>#include <stdlib.h>int main ( ) { int a;

Disassembly of section .text:





0000000000000000 %26lt;main%26gt;:


0: 3c1c0000 lui $gp,0x0


4: 279c0000 addiu $gp,$gp,0


8: 0399e021 addu $gp,$gp,$t9


c: 27bdffc0 addiu $sp,$sp,-64


10: afbc0010 sw $gp,16($sp)


14: afbf003c sw $ra,60($sp)


18: afbc0038 sw $gp,56($sp)


1c: afb10034 sw $s1,52($sp)


20: afb00030 sw $s0,48($sp)


24: 27a40020 addiu $a0,$sp,32


28: 2405000a li $a1,10


2c: 8f860000 lw $a2,0($gp)


30: 8cc60000 lw $a2,0($a2)


34: 8f990000 lw $t9,0($gp)


38: 0320f809 jalr $t9 #fgets1


3c: 00000000 nop


40: 8fbc0010 lw $gp,16($sp)


44: 27b00020 addiu $s0,$sp,32


48: 02002021 move $a0,$s0


4c: 00002821 move $a1,$zero


50: 2406000a li $a2,10


54: 00003821 move $a3,$zero


58: 8f990000 lw $t9,0($gp)


5c: 0320f809 jalr $t9 #atoi1


60: 00000000 nop


64: 8fbc0010 lw $gp,16($sp)


68: 00408821 move $s1,$v0 #s1=a


6c: 02002021 move $a0,$s0


70: 2405000a li $a1,10


74: 8f860000 lw $a2,0($gp)


78: 8cc60000 lw $a2,0($a2)


7c: 8f990000 lw $t9,0($gp)


80: 0320f809 jalr $t9 #fgets2


84: 00000000 nop


88: 8fbc0010 lw $gp,16($sp)


8c: 02002021 move $a0,$s0


90: 00002821 move $a1,$zero


94: 2406000a li $a2,10


98: 00003821 move $a3,$zero


9c: 8f990000 lw $t9,0($gp)


a0: 0320f809 jalr $t9 #atoi2


a4: 00000000 nop


a8: 8fbc0010 lw $gp,16($sp)


ac: 00402021 move $a0,$v0 #a0 is b


b0: 00003021 move $a2,$zero


b4: 1a20000d blez $s1,ec %26lt;main+0xec%26gt;


b8: 00002821 move $a1,$zero


bc: 00000000 nop


c0: 18800006 blez $a0,dc %26lt;main+0xdc%26gt;


c4: 00001821 move $v1,$zero


c8: 24a50001 addiu $a1,$a1,1


cc: 24630001 addiu $v1,$v1,1


d0: 0064102a slt $v0,$v1,$a0


d4: 1440fffc bnez $v0,c8 %26lt;main+0xc8%26gt;


d8: 00000000 nop


dc: 24c60001 addiu $a2,$a2,1


e0: 00d1102a slt $v0,$a2,$s1


e4: 1440fff6 bnez $v0,c0 %26lt;main+0xc0%26gt;


e8: 00000000 nop


ec: 8f840000 lw $a0,0($gp)


f0: 24840000 addiu $a0,$a0,0


f4: 8f990000 lw $t9,0($gp)


f8: 0320f809 jalr $t9 #


fc: 00000000 nop


100: 8fbc0010 lw $gp,16($sp)


104: 00001021 move $v0,$zero


108: 8fbf003c lw $ra,60($sp)


10c: 8fb10034 lw $s1,52($sp)


110: 8fb00030 lw $s0,48($sp)


114: 03e00008 jr $ra


118: 27bd0040 addiu $sp,$sp,64


11c: 00000000 nop

If I were to translate this program from c: #include %26lt;stdio.h%26gt;#include %26lt;stdlib.h%26gt;int main ( ) { int a;
THE ANSWER IS ( WHAT !!!!!!!!!) JOKING I HAVE NO CLUE

marigold

How to include c or c++ file in borland c++ builder 6.0?

I want to include user defined header file in my c program. How to include the c or c++ header file in my c or c++ program in borland c++ builder 6.0.

How to include c or c++ file in borland c++ builder 6.0?
u will have header folder from there u can
Reply:i'm guessing you already have your header files and your main cpp.





create a new project.


save


add both files to the project.


compile%26amp;run
Reply:in the INCLUDE FOLDER where other headers are put your user defined header





# include "userdefined.h"


Where can I download all the C++ include files?

I was trying to compile a C++ program and got an error message saying I was missing a few .h files. Is there a reliable source of all the include files available for easy download?

Where can I download all the C++ include files?
You can try download.net and look for borland. But you shouldn't have to do that at all.





If you are missing some .h files then they should be included with the compiler you are using. What compiler or what are your errors???





**ADDED


This many help


http://www.cee.hw.ac.uk/~ceehsa1/teachin...
Reply:try to reinstall it
Reply:It may be that you installed the compiler and didn't add the path to the header files into your path environment variable. Your compiler doesn't know where to find the files. Check any README files that came with the compiler.


Visual C++ Express 2008 progamming to include hid.h and hidsdi.h?

here is part of my code





extern "C" {





#include "hid.h"





#include "hidsdi.h"





#include "process.h"





#include %26lt;setupapi.h%26gt;





#include %26lt;initguid.h%26gt;





}





this is the error i get during compile:


|| Cannot open include file: 'hid.h': No such file or directory ||


i already have windows DDK installed.. how do i solve this problem?? do i add the directory of the headers file?? or add the library of the hid files to the linker??

Visual C++ Express 2008 progamming to include hid.h and hidsdi.h?
have you setup include directories and lib files in vc++?? if not here is a link that teaches you how to setup vc++ express edition 2005.. i hope setting up 2008 is also similar. Also Remove the inverted commas and use angular brackets because inverted comma limits the searching of files within one particular path...you have to add the path of the hid.h file to the include path list in tools-%26gt;options-%26gt;(on the left pane) projects and solutions-%26gt;vc++directories-%26gt;(on the right pane show directories for include files)-%26gt; and add the folder in which hid.h is present...