Replace A Character in String C Program

By | May 15, 2016

C Program To Replace A Character in String

Learn How To Replace A Character in String in C Programming with another User Defined Character. This C Program To Exchange Characters in an Array of Characters, also known as Strings uses three Block Structures:

  • For Loop
  • While Loop
  • If – Else Block Structure

How To Take Two Characters From User

In the second method, we have taken Two Character Inputs from the User. However, when you try it in the normal way, you will get the Input of only one character. To take both the characters from the User, you will have to add a space before %c in the scanf() method. This will ignore any spaces before the scanf().

Also Read: C Program To Remove Vowels From A String

Method 1: Code To Replace Character in String with * in C Programming

Output

C Program To Replace Character in String with Star

Also Read: Print India’s Map in C Programming (Obfuscated Code)

 

Method 2: C Program To Replace Character in a String with User – Defined Character

 

Output:

C Program To Replace A Character in String

If you have have any compilation errors or doubts with Code to Replace A Character in String in C Programming, let us about it in the Comment Section below.

5 thoughts on “Replace A Character in String C Program

  1. Meesum Hyder

    In the above program the character is not taking to replaced.I am unable to see the results of this code.please help me

    Reply
  2. vihu

    replacing a character by 2 alphabets then wat to do??
    sch as in i=Tushar i want to replace u by mf i.e Tmfshar

    Reply

Let's Discuss