You are here:

C/C String handling

Advertisement


Question
I wanna ask u is there any built in function for
removing a pateern of string for eg. Internationalschool and i want to remove school from it.
                                  Thaks

Answer
I hate to give code.
You could have written this by yourself!
Anyway, here is the code:
#include <stdio.h>

main()
{
       char name[24];
       char str[10];
       char *ptr;

       printf("Enter name => ");
       scanf("%s", name);
       printf("Enter substring => ");
       scanf("%s", str);

       printf("Before removing \"%s\" the main string is => %s\n", str, name);

       ptr = strstr(name, str);
       if (ptr != NULL) *ptr = '\0';

       printf("Before removing \"%s\" the main string is => %s\n", str, name);
}

C

All Answers


Answers by Expert:


Ask Experts

Volunteer


Narendra

Expertise

I can answer questions in C related to programming, data structures, pointers and file manipulation. I use Solaris for doing C code and if you have questions related to C programming on Solaris, I will be able to help better.

Experience

6.5

Organizations belong to
Sun Microsystems

Awards and Honors
Brain Bench Certified Expert C programmer.
Advanced System Software Certified

©2012 About.com, a part of The New York Times Company. All rights reserved.