Replace A Character in String C Program

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.


Tushar Soni

I am Tushar Soni, Co - Founder of CodingAlpha. I am a computer science student from India and passionate about Web Development and Programming. Connect with me on Facebook | LinkedIn | Google Plus

2 thoughts on “Replace A Character in String C Program

  • September 9, 2016 at 4:10 pm
    Permalink

    What is the difference between == and = operator?

    Reply
  • March 18, 2017 at 5:00 pm
    Permalink

    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

Join The Discussion