I am new in C and I have the following simple code. I know that with the strncpy I can copy characters from string.
#include <stdio.h>
#include <string.h>
int main ()
{
char str1[]= "To be or not to be";
char str2[40];
strncpy ( str2, str1, 5 );
str2[5] = '\0'; /* null character manually added */
puts (str2);
return 0;
}
The output of this code is
To be
If I want the result to be ´or not to´ how can I read these characters? From 7-15 in this case?
find_first_oforat()which can help youc++tag.