+ 1

What is/are the difference(s) between the header file "string.h" and "strings.h"?

When shall I include which header file?

1st Nov 2020, 7:34 AM
Himanshu Yadav
Himanshu Yadav - avatar
4 Respuestas
+ 3
Typically <strings.h> just adds some useful but non-standard additional string functions to the standard header <string.h>. For maximum portability you should only use <string.h> but if you need the functions in <strings.h> more than you need portability then you can use <strings.h> instead of <string.h>. https://stackoverflow.com/questions/4291149/difference-between-string-h-and-strings-h#:~:text=Typically%20%3Cstrings.,to%20the%20standard%20header%20%3Cstring.&text=For%20maximum%20portability%20you%20should,need%20the%20functions%20in%20%3Cstrings. If you read the best answer on the stack overflow question you'll find the function prototypes for the additional functions in strings.h with suggestions on replacing them with other string.h functions
1st Nov 2020, 1:43 PM
Davide
Davide - avatar
+ 2
You are welcome
1st Nov 2020, 4:23 PM
Davide
Davide - avatar
+ 1
Thank you, Davide. 🙌 🙌 😀
1st Nov 2020, 1:51 PM
Himanshu Yadav
Himanshu Yadav - avatar
0
Header inclusion in C++ doesn't need file extension, except for non-standard header files. #include <string> File extension is needed in header inclusion for C language. #include <string.h> Inclusion of <string> In C++ is recommended when the program needs to use string. The same purpose is there for inclusion of <string.h> in C language. Note that C++ string is not the same to that of C string. P.S. I'm not sure there is strings.h header.
1st Nov 2020, 8:39 AM
Ipang