• 0

[C++] Deprecated or antiquated header?


Question

At college we're using a Borland C++ 5.01 compiler.. We're only a few lessons in and at the start of each source file I've been told to use:

#include <iostream.h>
#include <conio.h>

I've just downloaded Dev-C++ 4.9.9.0 and I get the following error:

2 C:\Dev-Cpp\include\c++\3.3.1\backward\backward_warning.h:32 #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <sstream> instead of the deprecated header <strstream.h>. To disable this warning use -Wno-deprecated.

So as I understand it, the headers have been replaced with something new? Can anyone tell me what they've been replaced with? Will I have to change the code I use?

Thanks!

Link to comment
Share on other sites

22 answers to this question

Recommended Posts

  • 0

Hmmm, from what I've read conio.h was a microsoft header and it is no longer used..

The only two things that I've been taught to use at the moment which come from conio.h are getch(); and clrscr();..

We were using getch(); to pause the program at the end so I can use system("PAUSE"); instead but what can I use instead of clrscr();?

Link to comment
Share on other sites

  • 0

to use the standard iostream without errors (at least in stuff I made before iostream.h was deprecated) you also need using namespace std;

i.e.

#include<iostream>

using namespace std;

Link to comment
Share on other sites

  • 0

Ok thanks guys..

Just before I download that microsoft thing, my tutor said that the microsoft C++ compiler doesn't comply with the C++ standard as they do their own things or something.. Is this true?

Link to comment
Share on other sites

  • 0
Ok thanks guys..

Just before I download that microsoft thing, my tutor said that the microsoft C++ compiler doesn't comply with the C++ standard as they do their own things or something.. Is this true?

Yeah. Although you'd have a hard time finding one that is truely compliant, however GCC is almost there (it's trying).

Edited by kjordan2001
Link to comment
Share on other sites

  • 0
Ok thanks guys..

Just before I download that microsoft thing, my tutor said that the microsoft C++ compiler doesn't comply with the C++ standard as they do their own things or something.. Is this true?

Uh, not quite true. The newest incarnation is pretty damn close to the standard. I doubt that in your class you will run into anything that wouldn't be supported.

Link to comment
Share on other sites

  • 0

I wasn't concerned with C++ stuff not being supported but rather microsoft adding stuff that I could end up thinking was standard C++ when its microsofts own extras.. Like that conio thing, from what I read it was a microsoft specific thing and so would prefer not to use it at this time..

Hope that makes sense

Link to comment
Share on other sites

  • 0
to use the standard iostream without errors (at least in stuff I made before iostream.h was deprecated) you also need using namespace std;

i.e.

#include<iostream>

using namespace std;

oooh i never knew that

well, what does use namespace std do anyhow? i dont think ive ever done that for any of my dealies

Link to comment
Share on other sites

  • 0
oooh i never knew that

well, what does use namespace std do anyhow? i dont think ive ever done that for any of my dealies

Good question..

Another question aswell, at college we're only just starting C++ and I was told to put void main(void) but Dev-C++ doesn't seem to like that so what can I put instead? In this book I've got it says int main(int nNumberofArgs, char* pszArgs[]) but I don't understand what that means when I did understand void main(void)..

Anyone?

Link to comment
Share on other sites

  • 0

"using namespace std;": this allows u to use variable types and functions that are part of the 'std' namespace, without having to explicitely put the namespace.

if u don't put it, and you want to use string, u'll have to do this:

std::string someString = "something";

but u can simplify your code by telling the compiler to try the std namespace when it doesn't find the var type or method.

using namespace std;
string someString = "something";

As for the main() thing: for console application, when the main function is called, it's passed 2 arguments: the number of parameters and the actual parameters.

this mean if u call your programme by using this command line:

myApp.exe something else here

your main() function will be called with argc (argument count) = 3 and with argv (the actual arguments) = {"something","else","here"}

you'll then be able to check the parameters like so:

int main (int argc, char *argv[]) {
  if (argc&gt;1) {
    if (strcmp(argv[1],"something")==0) {
      ...
    }
  }
}

Link to comment
Share on other sites

  • 0

So if that's what you use for main what do you use for functions? I've been told that it's:

whatever_is_coming_out function_name(anything_being_passed_in)

So for example:

int someFunction(float x, float y)

Is that still correct?

Edit: I know that if you declare a variable in a function then only that function has scope of that variable.. But if I declare a variable in main can the functions also use that variable or should I declare the variable before main after the includes? If that makes sense..

Edited by mark52230
Link to comment
Share on other sites

  • 0

Is that still correct?

Yes.

Variables defined in main() are valid in the main() function only.

If you want other functions to have access to them, you need to pass those using functions arguments (anything_being_passed_in) and possibly return them when that function is done modifying it.

int main(...) {
  int i = 1;
  int j = someFunc(i);
  printf("The result is %i",j);
  ...
}

int someFunc(int i) {
  return i + 5;
}

This will display: "The result is 6"

Link to comment
Share on other sites

  • 0

Me again with another question lol..

I've noticed that different books or materials use different includes for the same thing.. In one book I have something like:

#include &lt;iostream&gt;
#include &lt;stdlib.h&gt;
#include &lt;string&gt;

But in another I have:

#include &lt;cstdio&gt;
#include &lt;cstdlib&gt;
#include &lt;iostream&gt;

One has the include string, but I've used the variable type string without the include string if that makes sense.. So why would I need the include string? Also, I thought the .h part of includes was no longer used?

How do I know which includes I need and which I do not? Is there some online listing of official includes anywhere?

Link to comment
Share on other sites

  • 0

I would guess #include <cstdlib> includes string, so u don't need it.

to know if u need them, u can simply try to remove them and see if the compiler complains about unknown types of functions.

In the manual for the function u want to use, the needed include is mentionned. (manual can be msdn, man pages, cppreference.com, etc.)

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.