![]() |
| ||
| Search Array I cant get this code to work it searches and finds the answer, but it gets an error once you search it. Heres the assignment. Quote:
#include <iostream> |
| ||
| Re: Search Array The error is caused by your writing a value past the end of the array's allocation. Line 74 a[9][9] = c;is the culprit. Remember, that for an array sized 10 x 9, the maximum index (the lower right corner) is [9][8]. What is the purpose of this line? Also, in functions fillarray( ) and show( ) you pass the number of rows as a parameter, then declare a variable of the same name and use hard coded limit on number of rows. Use the parameter, it makes your function more capable, it could handle an array of any number of rows, like void fillarray(int a[][9], int row) Read the compiler's warnings - it should have told you about the unused function parameters. Also, looks at the code that occurs after the return statement in main( ) - it never, ever will be executed. |
| All times are GMT -4. The time now is 11:57 am. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC