My objective is to remove user defined amount of characters from a string in C.
The code requires the user to input a string, indicate the start of the characters they want removed and indicate how many characters from that position they want removed & then the code displays the result.
I'm hoping someone out there can come up with a code that does the required function and with step-by-step info because I only started coding yesterday
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int a,b;
char text[20];
char new_sentence[20];
int how_much;
void removeString(char* text, int b, int how_much);
int main(void)
{
printf("\nEnter your sentence: ");
gets(text);
printf("\nWhere to start: ");
scanf("%d",&a);
printf("\nHow many characters do you want to remove: ");
scanf("%d",&how_much);
removeString(char* text, int b, int how_much);
printf("\nNew sentence: %s",text);
return 0;
}
void removeString(char* text, int b, int how_much)
{
how_much = b - a;
memmove(&text[a], &text[b],how_much);
}