- #include <stdio.h>
- #include <string.h>
-
- int main() {
- const char *str = "Hello, world! This is a test.";
- const char *substr = "world";
- const char *result = strstr(str, substr);
-
- if (result != NULL) {
- printf("Substring found at position: %ld\n", result - str);
- } else {
- printf("Substring not found.\n");
- }
-
- return 0;
- }
|