Friday, September 05, 2008

Code Lab Notes

Standard C Library Function
strstr (finds the first occurrence of a substring of characters)

#include <cstring>
char *strstr (const char *str1, const char *str2);
☆ Check if the second string is a substring in the first string.
☆ The second string must be completely contained in the first string.
☆ None NULL return is a pointer to the first matched char. So if the second string in above code is "sad", the printed-out will also be "sad cat".
☆ Case sensitive
☆ Do not cout the NULL return directly in above code. (RunTime Error)
☆ If the second string contains no character, it will print out the first string completely.