I was reading about string functions in the book C Primer Plus 6th edition by Stephan Prata chapter 14. It says that
Some pre-ANSI systems use strings.h instead, and others might lack a string header file entirely.
So, I thought that It shouldn't work if I compile following program on any modern C compiler.
#include <stdio.h>
#include <strings.h> // note here strings.h not string.h
void fit(char *c,unsigned u);
int main(void)
{
char msg[]="Things should be as simple as possible," " but not simpler.";
puts(msg);
fit(msg,38);
puts(msg);
puts("Let's look at some more of the string.");
puts(msg + 39);
return 0;
}
void fit(char *c,unsigned u)
{
if(strlen(c)>u)
c[u]='\0';
}
I tried it on orwell Dev C++ IDE & Codeblocks 13.12 & it compiles and runs fine. Why I am not getting error?
What is the difference between string.h and strings.h?