Need a little help with my project

This is a discussion on Need a little help with my project within the C++ Programming forums, part of the General Programming Boards category; Ok, I added this: Code: for(int a=0; a<5; a++) for(int b=0; b<10; b++) table[a][b] = ' '; but my output ...

  1. #16
    Registered User
    Join Date
    Sep 2003
    Posts
    16
    Ok, I added this:

    Code:
    for(int a=0; a<5; a++)
           for(int b=0; b<10; b++)
                  table[a][b] = ' ';
    but my output did not change.

    ...?

  2. #17
    Registered User jlou's Avatar
    Join Date
    Jul 2003
    Posts
    1,088
    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.

  3. #18
    Registered User
    Join Date
    Sep 2003
    Posts
    16
    Thank you soooooo much.

    With that addition of a line, my program is complete.

    I added:
    Code:
    if(i == messagelength)
        break;
    to my loop when I read in my message so it will stop when it reads in the last character.

  4. #19
    Registered User jlou's Avatar
    Join Date
    Jul 2003
    Posts
    1,088
    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.

  5. #20
    Registered User
    Join Date
    Sep 2003
    Posts
    16
    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.

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem Displaying a Struct
    By rockstarpirate in forum C++ Programming
    Replies: 16
    Last Post: 05-05-2008, 10:05 AM
  2. added start menu crashes game
    By avgprogamerjoe in forum Game Programming
    Replies: 6
    Last Post: 08-29-2007, 02:30 PM
  3. Dynamic Binding
    By gpr1me in forum C++ Programming
    Replies: 1
    Last Post: 03-24-2006, 09:01 AM
  4. Game Independent Anti-cheat Project Needs Programmers
    By GIA Project Lea in forum Projects and Job Recruitment
    Replies: 3
    Last Post: 09-15-2005, 08:41 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21