Search
 
SCRIPT & CODE EXAMPLE
 

C

replacing a character in string in C

#include<stdio.h>
#include<conio.h>
main()
{
int i;
char a,b,str[100];
printf("Enter the string");
gets(str);
//asking for replacement
printf("enter the character to be replaced");
scanf("%c",&a);
// which letter to replace the existing one
printf("enter the character to replace");
scanf("%c",&b);
for(i=0;str[i]!='';i++)
{
    if(str[i]==a)
    {
    str[i] = b;
    }
    else
    continue;
}
printf("the new string is");
puts(str);
}
Comment

PREVIOUS NEXT
Code Example
C :: Grepper VSCode Add On 
C :: search in gz file 
C :: C program to check whether character is lowercase or not using ASCII values 
C :: to run Blazor project using CLI 
C :: functions in c 
C :: signal function c 
C :: how to add 1 to 10 in c 
C :: c program that replace vowels in a string with char 
C :: passing two dimensional array to function in c 
C :: pointers to a function in c 
C :: do...while loop c 
C :: how to get file size in c 
C :: print float in c 
C :: c print 2d array 
C :: c linked list 
C :: . Simulate MVT and MFT. 
C :: c memcpy 
C :: ltoa in c 
C :: read from command line c 
C :: C# special character display 
C :: mc dropout pytorch 
C :: typedef c 
C :: c for result 
C :: metw.cc 
C :: convert c code to python online free 
C :: can torch light bring change in chemical reaction 
C :: call cuda kernel from c parameters 
C :: georgia institute of technology 
C :: gnunet 
C :: Array in element from lowest 
ADD CONTENT
Topic
Content
Source link
Name
5+1 =