Ok, I added this:
but my output did not change.Code:for(int a=0; a<5; a++) for(int b=0; b<10; b++) table[a][b] = ' ';
...?
Ok, I added this:
but my output did not change.Code:for(int a=0; a<5; a++) for(int b=0; b<10; b++) table[a][b] = ' ';
...?
My fault... while the previous suggestion is still a good idea, I didn't realize you have the same problem in your input as you do in your output. That problem is that you continue to add characters from statement after you have passed the end of the statement char array.
So, you have the variable i in your encode method that you can use to check against the messagelength variable. You really shouldn't be accessing a char off the end of the statement string anyway -- so if i is greater than or equal to message length then you should stop copying characters. There might be other ways of doing this, the point is that you are accessing the garbage characters passed the end of the statement array and copying them into your table. If you can fix that, you should clean up the garbage.
Thank you soooooo much.
With that addition of a line, my program is complete.
I added:
to my loop when I read in my message so it will stop when it reads in the last character.Code:if(i == messagelength) break;
Sorry to burst your bubble, but when I was playing with the code I entered the following statement and key:
statement: thisisastatementthatislessthanfiftycharacters
key: myke
When the program was terminating I got a bunch of access violations and a stack overflow. I'm sorry I can't see what was causing that or look into it right now, but you may want to look into it before you consider yourself done. Make sure you are not accessing or overwriting data passed array bounds.
Well, it isn't technically complete, but I did fulfull the requirements of the project. I do realize that a statement that is more than 5 times the length of the key will cause an overflow. But I am not concerned with that at the moment seeing as it needs to be handed in during my next lab class, which is 10:10 AM, 9/9/03.