I have a code including

#include <iostream>
#include <iomanip>
#include <fstream>

using namespace std;

And it works with MinGW under XP.
I want to compile the same code under Suse linux,
but compiler said that for example:
atof(), error() functions are not defined.

The problem solved if I include

#include <stdio.h>
#include <stdlib.h>

also, but I don't understand!
The packages are different under XP and linux?
I want a platform independent code.

The packages are different under XP and linux?

No. Your code under Windows was benefiting from internal includes. That is, standard headers themselves include other standard headers, which means somewhere in <iostream>, for example, <cstdlib> was included. atof is declared in <cstdlib>, so your calls magically worked.

It's best to include all of the headers you need, even if the code still compiles without them. Of course, this also means you should know which header to include for all of the standard names you use. ;)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.