Write your question here.
Very much a BEGINNER. Can someone explain to me what this line is for in this program? (*realmessage)[6] = 'i'; It seems to have no use at all. Also when [6] is changed to [3] or less it actually does something. i.e. is [4] and above it has no affect at all. Also note that if the line is commented out it changes nothing and the code compiles and runs fine(i think) the code is from C++ all-in-one for dummies 2nd ed
Can someone explain to me what this line is for in this program? (*realmessage)[6] = 'i';
This line changes the character at position 6 in given string to 'i'. As is it has no effect because the character at this position is already 'i'.This explains why commenting out the line changes nothing to the program.
First, thank you for responding to my post. I understand what you are saying but when I changed the 'i' to a 'W', it did not change. I then played around with it and through experimenting I found that the only characters I could change were at positions [0] through [3]. This confused me as I thought I was starting to understand what I was reading.
Oh I think I understand now.This must be cause of the last line realmessage->replace(4, 3, "ali");
No matter what you change at the first line it will be 'i' again cause of this line replacing substring 'fri' to 'ali'.
The friends are having dinner
*** beginning string conversion! ***
The friends are having dinner
The friens are having dinner
The friens are havading dinner
The friens are invading dinner
The friens are invading!
The aliens are invading!
*** string conversion complete! ***
The aliens are invading!
The command to change the string is correct and working, changing an 'i' to an "i'.