![]() |
![]() |
![]() |
|
![]() Administrator ![]() ![]() ![]() ![]() ![]() Joined Aug 23, '02 From Seattle, WA Currently Offline Reputation: 14 (100%) ![]() |
I've been writing a program for class and was getting strange errors,
so I went through everything and eventually simplified it down to this super-simple program: CODE #include <iostream> using std::cout; using std::cin; int main() { int buckets[9][4] = {0}; for (int j = 0; j <= 9; j++) { for (int k = 0; k <= 4; k++) { cout << buckets[j][k] << " "; } cout << "\n"; } char ch; cin >> ch; } Sounds simple, right? Create a 10 row, 5 column 2-dimensional array filled with zeroes, right? The problem is that my output is this: Anyone have any idea as to what could be going on? If I manually fill the array with zeroes using two for loops, I get the correct output, but when the program tries to exit after I enter a character, I get this error: Any of you programmers out there have any ideas?
Attached image(s)
![]() ![]() -------------------- New Toyota project coming soon...
|
![]() |
![]() |
|
![]() Enthusiast ![]() ![]() ![]() ![]() ![]() Joined Mar 3, '04 From Portsmouth, RI Currently Offline Reputation: 33 (100%) ![]() |
ahh. the use of "int" confused me, I just use "short" and "long". I believe long is the same as int when used to define variables.
I'm starting to understand... but still overall confused ![]() I'm working on this right now: "Write a program that calculates the distance, Ddown, given the river width, Wriver, the rowing velocity, Vrow, and the water flow velocity, Vwater." -------------------- |
![]() |
|
![]() Enthusiast ![]() ![]() Joined Mar 25, '06 Currently Offline Reputation: 0 (0%) ![]() |
QUOTE(hurley97 @ Oct 12, 2006 - 8:49 PM) [snapback]491032[/snapback] ahh. the use of "int" confused me, I just use "short" and "long". I believe long is the same as int when used to define variables. I'm starting to understand... but still overall confused ![]() I'm working on this right now: "Write a program that calculates the distance, Ddown, given the river width, Wriver, the rowing velocity, Vrow, and the water flow velocity, Vwater." Ive actually got a physics midterm tomororw so i cant spend too much time helping you... But if you need help with that program its actually a very simple program. Input Wriver Input Vrow Input Vwater Ddown = (Time to cross [Vrow/Width])*Vwater Or something like that... oh how i miss programming and simple physics ![]() And i'd have to bust out my old c++ text but im pretty sure long and int are not that same.. -------------------- ----- '94 ST hatch --- Yellow ----- |
![]() ![]() |
Lo-Fi Version | Time is now: July 27th, 2025 - 9:51 AM |