| | |
Weird bug...
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Jul 2004
Posts: 494
Reputation:
Solved Threads: 21
I'm working on a program where you find any path through a graph. When inputting the graph using an array, I found the number in position[0][8][9] gets set as 1 rather than 0 after position[0][9][1] is read in to memory.
I've tried both gcc 3.3.2 and 4.0, and get the same result on both. Does anyone else get the same results?
I've tried both gcc 3.3.2 and 4.0, and get the same result on both. Does anyone else get the same results?
C++ Syntax (Toggle Plain Text)
#include <iostream> using namespace std; typedef char board[4][9][9]; board maze; //maze is global so we don't have to pass it in every recursive call. int main() { cout << "Position [0][8][9] should be a 0. It is a 1." << endl; //Enter just a simple 1-level maze maze[0][0][0] = '0'; maze[0][0][1] = '0'; maze[0][0][2] = '0'; maze[0][0][3] = '0'; maze[0][0][4] = '1'; maze[0][0][5] = '1'; maze[0][0][6] = '1'; maze[0][0][7] = '1'; maze[0][0][8] = '1'; maze[0][0][9] = '1'; maze[0][1][0] = '1'; maze[0][1][1] = '1'; maze[0][1][2] = '1'; maze[0][1][3] = '0'; maze[0][1][4] = '1'; maze[0][1][5] = '1'; maze[0][1][6] = '1'; maze[0][1][7] = '1'; maze[0][1][8] = '1'; maze[0][1][9] = '1'; maze[0][2][0] = '1'; maze[0][2][1] = '1'; maze[0][2][2] = '1'; maze[0][2][3] = '0'; maze[0][2][4] = '1'; maze[0][2][5] = '1'; maze[0][2][6] = '1'; maze[0][2][7] = '1'; maze[0][2][8] = '1'; maze[0][2][9] = '1'; maze[0][3][0] = '1'; maze[0][3][1] = '0'; maze[0][3][2] = '0'; maze[0][3][3] = '0'; maze[0][3][4] = '1'; maze[0][3][5] = '0'; maze[0][3][6] = '0'; maze[0][3][7] = '0'; maze[0][3][8] = '0'; maze[0][3][9] = '1'; maze[0][4][0] = '1'; maze[0][4][1] = '0'; maze[0][4][2] = '1'; maze[0][4][3] = '1'; maze[0][4][4] = '1'; maze[0][4][5] = '0'; maze[0][4][6] = '1'; maze[0][4][7] = '1'; maze[0][4][8] = '0'; maze[0][4][9] = '1'; maze[0][5][0] = '1'; maze[0][5][1] = '0'; maze[0][5][2] = '0'; maze[0][5][3] = '0'; maze[0][5][4] = '0'; maze[0][5][5] = '0'; maze[0][5][6] = '1'; maze[0][5][7] = '0'; maze[0][5][8] = '0'; maze[0][5][9] = '1'; maze[0][6][0] = '1'; maze[0][6][1] = '0'; maze[0][6][2] = '0'; maze[0][6][3] = '0'; maze[0][6][4] = '0'; maze[0][6][5] = '1'; maze[0][6][6] = '1'; maze[0][6][7] = '0'; maze[0][6][8] = '0'; maze[0][6][9] = '1'; maze[0][7][0] = '1'; maze[0][7][1] = '0'; maze[0][7][2] = '1'; maze[0][7][3] = '1'; maze[0][7][4] = '0'; maze[0][7][5] = '1'; maze[0][7][6] = '1'; maze[0][7][7] = '0'; maze[0][7][8] = '0'; maze[0][7][9] = '1'; maze[0][8][0] = '1'; maze[0][8][1] = '0'; maze[0][8][2] = '0'; maze[0][8][3] = '0'; maze[0][8][4] = '0'; maze[0][8][5] = '1'; maze[0][8][6] = '1'; maze[0][8][7] = '0'; maze[0][8][8] = '0'; maze[0][8][9] = '0'; maze[0][9][0] = '1'; maze[0][9][1] = '1'; maze[0][9][2] = '1'; maze[0][9][3] = '1'; maze[0][9][4] = '1'; maze[0][9][5] = '1'; maze[0][9][6] = '1'; maze[0][9][7] = '1'; maze[0][9][8] = '0'; maze[0][9][9] = '0'; //Debug: Print out the maze and wait for enter to be pressed for (int i=0; i<=9; i++) { cout << i << " "; for (int column=0; column<=9; column++) cout << maze[0][i][column]; cout << endl; } }
www.uncreativelabs.net
Old computers are getting to be a lost art. Here at Uncreative Labs, we still enjoy using the old computers. Sometimes we want to see how far a particular system can go, other times we use a stock system to remind ourselves of what we once had.
Old computers are getting to be a lost art. Here at Uncreative Labs, we still enjoy using the old computers. Sometimes we want to see how far a particular system can go, other times we use a stock system to remind ourselves of what we once had.
Arrays are zero-based. If you have
T array[10], it may be indexed from 0-9, not 0-10. "One of the methods used by statists to destroy capitalism consists in establishing controls that tie a given industry hand and foot, making it unable to solve its problems, then declaring that freedom has failed and stronger controls are necessary." --Ayn Rand
![]() |
Similar Threads
- Realy weird random number generator bug (C++)
- File doesn't upload into the directory I specified. Need help! (PHP)
- People who can't post threads (Viruses, Spyware and other Nasties)
- Dangerous Bug in HijackThis 1.97.7 Restoral Procedure (Viruses, Spyware and other Nasties)
- ie6 (winxp-peo) problem (Web Browsers)
- Games act weird (Troubleshooting Dead Machines)
- weird problem : Internet Explorer cannot load all geocities pages (Windows NT / 2000 / XP)
- CSRSS Backspace Bug in Windows NT 4/NT 2000/NT XP (Windows NT / 2000 / XP)
Other Threads in the C++ Forum
- Previous Thread: Bumping my object on a linked list
- Next Thread: C++ File I/O
| Thread Tools | Search this Thread |
api array arrays beginner binary bitmap c++ c/c++ calculator char class classes code coding compile compiler console conversion convert count data database delete desktop developer directshow dll download dynamic encryption error file forms fstream function functions game generator getline givemetehcodez google graph gui homeworkhelper iamthwee ifstream input int integer java lib linkedlist linker linux loop looping loops map math matrix memory news node number output parameter pointer problem program programming project proxy python random read recursion recursive return string strings struct temperature template templates test text text-file tree unix url variable vector video visualstudio win32 windows winsock word wordfrequency wxwidgets






