HELP!!! Unable to use iostream.h using C, instead of C++

Hi everyone, I tried to used iostream.h into my file so that I can open a file for OpenGL but it seems like it’s not going work.

Can anyone help?

#include <gl/glut.h>
#include <gl/glu.h>
#include <iostream.h>
#include <fstream.h>

void InputImage(void)
printf("Enter the name of the input file : ");
/* try to open file for reading ® in binary (b) mode /
if ((inf_handle = fopen(inf_name, “rb”)) == NULL) /
open failed /
** Can’t open input file - please check file name typed!
charin = getchar();
exit(1); /* terminate execution */

You’re trying to use iostream in C? In a .c file? Because that won’t work. Iostream uses classes. C++ only.

Ya, now I know. I NEED HELP!!!

For example, I startt the .exe file, the question prompt

"Enter the file name: - "

And I want to type the filename, how do I read or type in the file name?

No offense but this:

a.) has not ANYTHING to do with OpenGL.
b.) Is VERY basic C/C++ knowledge.

I suggest you grab a beginners book to C/C++, its all in there.

I know it got nothing to do with OpenGL,but I’m currently doing OpenGL and I need to know this “basic C and C++” code to continue with it! :frowning:

They are lots of websites with basic C/C++ information.

You can compile C code under C++, but not the other way around. You need to ether change to C++ (.cpp) or do all the file I/O in C format.

But as you do some of the example openGL tutors like from, you will pick up how to do more C/C++ programming as you do along.

If you have a non-openGL question about C/C++, just drop me an e-mail and will see if I can help you.

Remember, you can’t use STL, <iostream.h>, etc. in C. But, you may consider coding your OGL Apps in C++ unless you have some specific reason not to. OOP is pretty useful in games, but some people still swear by C. Ultimately it’s up to you, but C++ is my preference.

#include <stdio.h> instead, of iostream.h and fstream. You’re trying to include the C++ headers for i/o, but using the C functions for i/o.

As has already been said, you should really get a better grasp of C/C++ before starting down the path of using OpenGL.