Basic Programs

If Else based Programs

Loop Based Programs

Array Based Programs

String Programs

Function Programs

Pointers Programs

Structure & File Handling Programs

Data Structure Programs

String based programs

C Program to replace a word with another in string

#include<stdio.h>
#include<conio.h>
void main()
{
int i=0,count=0;
char str[80];
printf("enter the string\n");
gets(str);
while(str[i]!=NULL) 
{
if(str[i]=='a'&& str[i+1]=='n' && str[i+2]=='d')//replace and with the
{
str[i]='t';
str[i+1]='h';
str[i+2]='e';
i=i+2;
}
i++;
}
printf("the change string is ");
puts(str);
}

Output of the above program is as following.

Video/ C Introduction

Watch video in full size
Wordpress Social Share Plugin powered by Ultimatelysocial