Hi,
I'm programming a simple line editor but I'm running into 1 issue that I just can't seem to figure out. I'm not the greatest at C++, if somebody could have a look I would be grateful.
Basically I have this Main...
Then I have this source file...
and header file...
Now the problem is in dtioEdit(). What I want to be able to do is make changes to a string and press Escape and have the string revert back to do its original state. You can find the code for that in the source file's line 392.
Now my problem is that I do properly revert the string back to the original state in dtioEdit() and then the program returns to the Main to do a strcmp (line 74) to check if the strings are the same. For some reason the string does not revert back to its original state in the Main but it does when I'm in the dtioEdit() function. I'm guessing it is a pointer issue.
So for example this is what should happen...
string: My name is Bob <----- Original string
Make change to string: My name is Jen
Press Escape
currently string: My name is Bob
Currently this is what is happening...
string: My name is Bob <----- Original string
Make change to string: My name is Jen
Press Escape
currently string: My name is Jen
I Keep a copy of the original string (called s) and I revert it on line 406 in the source file. Then the function exits because Escape is supposed to revert back to the original string and then end editing. Now we go back to the Main but for some reason my string has not been reverted back to the original string like it had within the function. I don't understand why that is happening..
I'm pretty sure the problem is in the if(keyPress == ESCAPE) block (line 392). Anyone know what I can do for my string s, to be updated in the Main properly and not just only in the function itself?
Thanks