I'm porting the program from C to C++ including this code:
char* get_file_extension(const char* file_name)
{
char* e = strrchr((char*) file_name, '.');
if (e == NULL)
{
char* buf = strdup(file_name);
return buf;
}
return e + 1;
}
Assuming that I'm only changing compiler to c++11, is it enough to just change NULL to nullptr in this case? Currently strrchr is from included header string.h, so I'm afraid if strrchr return NULL instead of nullptr and if(e == nullptr) check fail.
Or should I change string.h to cstring?