Spaces to Underscores
Hey everyone, I just have a quick question I'm trying to code something in c programming, where I have to ask the user for a string, change all the spaces inside that string to an underscore. And print both strings on the console. So I'm not allowed to change the first string. Does anyone have a suggestions for me on how to do so? I'm supposed to implement pointers as well. Thank you
4/16/2020 8:02:34 AMGursher Singh
2 AnswersNew Answer
Make a new variable and store the value of string in it. Now you can make changes in the old variable without disturbing new one. And you will be able to use both of the strings.
copy the string char by char to another location (another variable), and while iteration, replace the spaces encountered by underscores ;)