a_river_in_canada
a_river_in_canada

Reputation: 299

How does c++ handle ">>" operation for ifstream and char arrays?

if I do something like this

ifstream stat_stream("filepath",ios_base::in);
char pid[128];
stat_stream >> pid;

is c++ going to do any implicit conversions of my char[] (to a std::string say) or will it leave it as is?

Edit: For clarity, I want to ensure that this is as asynchronous signal safe as it is possible to be when file io is necessary. I really only meant the implicit conversions as an example of an operation that would be unacceptable.

Upvotes: 0

Views: 51

Answers (1)

Jake Freeman
Jake Freeman

Reputation: 1698

C++ does not implicitly change your char[] to a std::string. You can tell the type by doing: cout<<typeid(pid).name()<<endl;

Hope this help.

Upvotes: 1

Related Questions