int main()
{
	int i;
	char paragraph[50];             //paragraph string
	int sizeofpara;                 //size of paragraph
	char wrongword[50];             //word going to be replaced
	int wsize;                      //size of the wrong word
	char correctword[50];           //replacing word
	int csize;                      //size of the correct word
	int wrongwordposition;          //position where wrong word is located in the paragraph

	printf("Enter the paragraph :\n");
	readline(paragraph);                            //paragraph input
	sizeofpara = strlen(paragraph);
M:
	printf("Enter the word to be removed :\n");
	readline(wrongword);                            //wrongword input
	wsize = strlen(wrongword);

	wrongwordposition = findword(paragraph , sizeofpara , wrongword , wsize);   //finding wrong word
	if (wrongwordposition > sizeofpara) {
	    goto M;                                     //since word is not found requesting to input again
	} else {
        removeword(paragraph , sizeofpara , wrongwordposition , wsize);             //removing wrong word
	}
	printf("Enter the word you want to replace it with :\n");
    readline(correctword);                          //correct word input
    csize = strlen(correctword);

    insertword(paragraph , sizeofpara - wsize , wrongwordposition , correctword , csize);   //replacing with correct word

	return 0;
}
Exemple #2
0
//***********************************************************************************************************************
long  open(tree_t** t,FILE* fp,FILE* fmeaning)
{   char a[1000];
    char word[100] ;//= "apple";
    long count=0;
	
	
	
    while(fgets(a,1000,fp))
    {
        ++count;
        int i=0;
        int n=strlen(a); 
        while((i<=n)&&(isalpha(a[i])))
            i++;
        strncpy(word,a,i);
        strcpy(a,(a+i));
        *(word+i) = '\n';
        *(word+i) = '\0';
        //fprintf(fword,"%s",word);
        insertword(t,word,count,a,fmeaning);
        //fprintf(fmeaning,"%ld %s",count,a);
    }
    fclose(fp);   
    //fclose(fword);
    fclose(fmeaning);
    printf("Finished insertion\n");
    /*
    fp=fopen("words.txt","r");
    while(fgets(word,100,fp))// what does this do??? 
    {
        if(strcmp(word,"\n"))
        {
            word[0] +=32;
            insertword(t,word);
        }
    }
    fclose(fp);
	
    */
    return count;
	
}