Write a c program to replace word form String

Write a c program to replace word form String

#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
   char a[20] ,w[10],b[10],c[10],*s,*f,*d;
   int count=0,i,j,k;
   clrscr();
   printf("Enter any String   ");
   flushall();
   gets(a);
   /*printf("any word from your string to find");
   scanf("%s", b);
   printf("Enter word to be replaced");
   scanf("%s",c);  */
   s=a;
   f=b;
while(*s!='\0')
{
 if(*s==' ')
 {
count+=1;
 }
 s++;
}
s=a;
   for(j=0;j<=count;j++)
{
 i=0;
 while(*s!=' '&& *s!='\0')
 {
  i++;
  s++;
 }
 w[j]=i;
 s++;
}
printf("\ncount=%d",count+1);
for(j=0;j<count+1;j++)
printf("\n%d",w[j]);
for(i=0;i<count;i++)
{
  for(j=0;j<count;j++)
  {
if(w[j]>w[j+1])
{
int t;
t=w[j];
w[j]=w[j+1];
w[j+1]=t;
 }
 }
   }
   printf("\nlowest=%d",w[0]);
   printf("\nhighest=%d",w[j]);
   getch();
  }




Previous
Next Post »

Disqus Shortname

Comments system