Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Need help please: Write a function in C++ which takes one string variable (not C

ID: 3540825 • Letter: N

Question

Need help please:

Write a function in C++ which takes one string variable (not C string) as input and modifies the existing string. Try to find "Ohio" or "OHIO" in the input string. If the input string contains either of these, replace those 4 characters with "OH". As an example,
                Original string = "Blacklick, Ohio 43004"
                Modified string = "Blacklick, OH 43004"
Use an appropriate parameter passing mechanism. Your function will not do any cin or cout. Do not write a main function. Make sure to properly format all your code.

Explanation / Answer

void modify( char str[]) // you can also use char *str

{

int c=0; //index of the str array

  

while(str[c] != '')

{

if( str[c] == 'O' &&( str[c+1]='h || str[c+!]='H'))'

{

str[c+2]=' ' ;

str[c+3] = ' ' ;

}   

c++;

}

}