Answers for "delete char at"

C
0

remove char from string

def replace_(input_:str,latter:int):
    name_ = ""
    checkList=[]
    for num in range(latter):
        checkList.append(num)
    for i in range(0, len(input_)):
        if i not in checkList:
            name_ = name_ + input_[i]
    return  name_

name_=replace_("give hello",5)
print(name_) #will print hello
Posted by: Guest on June-05-2021
0

remove char from string

/* C Program to Remove All Occurrences of a Character in a String */
 
#include <stdio.h>
#include <string.h>
 
int main()
{
  	char str[100], ch;
  	int i, len, j;
 
  	printf("n Please Enter any String :  ");
  	gets(str);
  	
  	printf("n Please Enter the Character that you want to Remove :  ");
  	scanf("%c", &ch);
  	
	len = strlen(str);
	   	
  	for(i = 0; i < len; i++)
	{
		if(str[i] == ch)
		{
			for(j = i; j < len; j++)
			{
				str[j] = str[j + 1];
			}
			len--;
			i--;	
		} 
	}	
	printf("n The Final String after Removing All Occurrences of '%c' = %s ", ch, str);
	
  	return 0;
}
Posted by: Guest on February-25-2022

Code answers related to "C"

Browse Popular Code Answers by Language