Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR C

search and then change string -- strstr and strcpy

// CPP program to illustrate strstr()
#include <string.h>
#include <stdio.h>
  
int main()
{
    // Take any two strings
    char s1[] = "Fun with STL";
    char s2[] = "STL";
    char* p;
  
    // Find first occurrence of s2 in s1
    p = strstr(s1, s2);
  
    // Prints the result
    if (p) {
        strcpy(p, "Strings");
        printf("%s", s1);
    } else
        printf("String not found
");
  
    return 0;
}
Source by www.geeksforgeeks.org #
 
PREVIOUS NEXT
Tagged: #search #change #string #strstr #strcpy
ADD COMMENT
Topic
Name
4+2 =