In GCC the deprecated header files have been moved to the "backwards" include
folder (for backward compatibility). Unless you have explicitly specified this
include folder the files there will not be found. However the clue is in the
name; you should not be using these header files in new code, they are
provided to allow legacy code compilation. That said I believe that Dev-C++
adds this header in the default configuration, so I do not know why it does
not work in your case, but you failed to post the build log so it is not
possible to tell.
In ISO C++ standard headers do not have a .h extension, and those libraries
inherited from C loose the .h extension and are prepended with 'c'. Moreover
all standard library symbols are moved to the std:: namespace in C++, so
ideally the header files you should be using in this case are <cstdio> and
<iostream>. The ISO standard was ratified in 1998 and many compilers supported
the extentionless headers and std:: namespace long before that; where have you
been?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Compiler: Default compiler
Executing gcc.exe...
gcc.exe "C:\Users\owner\Documents\Prog\tcw.c" -o
"C:\Users\owner\Documents\Prog\tcw.exe" -I"C:\Dev-Cpp\include" -L"C:\Dev-
Cpp\lib"
C:\Users\owner\Documents\Prog\tcw.c:1:20: iostream: No such file or directory
C:\Users\owner\Documents\Prog\tcw.c: In function main':
C:\Users\owner\Documents\Prog\tcw.c:5: error:cout' undeclared (first use in
this function)
C:\Users\owner\Documents\Prog\tcw.c:5: error: (Each undeclared identifier is
reported only once
C:\Users\owner\Documents\Prog\tcw.c:5: error: for each function it appears
in.)
Execution terminated
I tried it without the .h but it still didn't work. I don't really understand
some of what you're saying. I'm just trying to see how some of the basic stuff
works because I will need to know a little programming for computations in
class.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
That is the build log; aAnd immediately the problem becomes clear (which is
why you should always post the log).
By naming your sourcefile with the .c extension you force the compiler to
perform C compilation and Dev-C++ ti use C compilation settings. Dev-C++'s C
compilation settings do not include the C++ backward compatibility directory
(for obvious reasons), and, and even if it did the iostream.h header file
would not compile as C code.
If you are writing C++ code, name your file with the .cpp extension.
Also I recommend that you use a project to manage your build rather than just
loading a sourcefile and building it. A project file keeps the build settings
with the project rather than simply using whatever you may have configured
Dev-C++ to use at that time. Moreover the New Project dialog provides a number
of project templates to get you started with the correct settings and example
code, and also allows you to set the default language for the project, which
would have solved your problem in this case. The other use of a project is
that it allows your program to be divided amongst a number of separately
compiled sourcefiles which is essential for any significantly large project,
and a useful way of reusing existing code from other projects or libraries.
The build log show exactly how the compiler was invoked, when you switch to
C++ look at how it differs from the one above; then some of what I said above
may make more sense.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm just starting out using Dev-C++ 4.9.9.2
When I put
include <iostream.h>
it says no such file or directory, but it works with codes with
include <stdio.h>
What does that mean?
In GCC the deprecated header files have been moved to the "backwards" include
folder (for backward compatibility). Unless you have explicitly specified this
include folder the files there will not be found. However the clue is in the
name; you should not be using these header files in new code, they are
provided to allow legacy code compilation. That said I believe that Dev-C++
adds this header in the default configuration, so I do not know why it does
not work in your case, but you failed to post the build log so it is not
possible to tell.
In ISO C++ standard headers do not have a .h extension, and those libraries
inherited from C loose the .h extension and are prepended with 'c'. Moreover
all standard library symbols are moved to the std:: namespace in C++, so
ideally the header files you should be using in this case are <cstdio> and
<iostream>. The ISO standard was ratified in 1998 and many compilers supported
the extentionless headers and std:: namespace long before that; where have you
been?
Is this the build log?
Compiler: Default compiler
Executing gcc.exe...
gcc.exe "C:\Users\owner\Documents\Prog\tcw.c" -o
"C:\Users\owner\Documents\Prog\tcw.exe" -I"C:\Dev-Cpp\include" -L"C:\Dev-
Cpp\lib"
C:\Users\owner\Documents\Prog\tcw.c:1:20: iostream: No such file or directory
C:\Users\owner\Documents\Prog\tcw.c: In function
main': C:\Users\owner\Documents\Prog\tcw.c:5: error:
cout' undeclared (first use inthis function)
C:\Users\owner\Documents\Prog\tcw.c:5: error: (Each undeclared identifier is
reported only once
C:\Users\owner\Documents\Prog\tcw.c:5: error: for each function it appears
in.)
Execution terminated
I tried it without the .h but it still didn't work. I don't really understand
some of what you're saying. I'm just trying to see how some of the basic stuff
works because I will need to know a little programming for computations in
class.
That is the build log; aAnd immediately the problem becomes clear (which is
why you should always post the log).
By naming your sourcefile with the .c extension you force the compiler to
perform C compilation and Dev-C++ ti use C compilation settings. Dev-C++'s C
compilation settings do not include the C++ backward compatibility directory
(for obvious reasons), and, and even if it did the iostream.h header file
would not compile as C code.
If you are writing C++ code, name your file with the .cpp extension.
Also I recommend that you use a project to manage your build rather than just
loading a sourcefile and building it. A project file keeps the build settings
with the project rather than simply using whatever you may have configured
Dev-C++ to use at that time. Moreover the New Project dialog provides a number
of project templates to get you started with the correct settings and example
code, and also allows you to set the default language for the project, which
would have solved your problem in this case. The other use of a project is
that it allows your program to be divided amongst a number of separately
compiled sourcefiles which is essential for any significantly large project,
and a useful way of reusing existing code from other projects or libraries.
The build log show exactly how the compiler was invoked, when you switch to
C++ look at how it differs from the one above; then some of what I said above
may make more sense.