C++ header file to be included for lexical cast

701 Views Asked by At

My compiler(GCC for C++) throws error when I include the #include header file for converting integer type to string type for some program. Can anyone help me with this?

This is for a small code in C++, I've tried it for the first time.

#include<iostream>
#include <boost/lexical_cast.hpp>// for lexical_cast()
#include <string> // for string

using namespace std;

int main()
{

long long n,i,k;
cin>>n;
ostringstream str1;

str1<<n;

string s = str1.str();
cout<<s<<endl;
return 0;
}

No such file or directory.

1

There are 1 best solutions below

0
On

Boost is not part of the standard library, so its implementation does not come with your compiler.

If you wish to use Boost functionality, by including its headers in your source code, you have to actually install Boost so that those headers are available on your development system.

On a system like CentOS, that would come from a package like boost-devel (or similar).

However, you're not using Boost functionality here, so just remove the include.

Even if you wanted to replace that stringstream usage, we have std::to_string nowadays.