60 745
Assignments Done
97,8%
Successfully Done
In April 2018

Answer to Question #52468 in C for sara

Question #52468
Write a function called removeString to remove a specified number of characters from a character string. The function should take three arguments: the source string, the starting index number in the source string, and the number of characters to remove. So, if the character array text contains the string "the wrong son", the call
removeString(text,4,6);
has the effect of removing the characters “wrong“ (the word “wrong” plus the space that follows) from the array text. The resulting string inside text is then "the son".
Expert's answer
Answer:
#include <stdio.h>
 
void removeString(char *text,int start,int number)
{
    int i;
   for(i=start;text[number+i]!='\0';i++)
        text[i]=text[i+number];
    text[i]='\0';
}
 
int main(){
    char text[100];
    printf("Input string:");
    scanf("%s",text);
    removeString(text,3,2);
    printf("Result:%s",text);
    return 0;
}


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions