Oct 12, 2006 - 2:04 AM
|
|
![]() 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...
|
![]() |
Oct 13, 2006 - 12:48 AM
|
|
|
Enthusiast ![]() ![]() ![]() ![]() ![]() Joined Mar 3, '04 From Portsmouth, RI Currently Offline Reputation: 33 (100%) |
yeah I got that far (not sure if it'll work yet). its the end where you tell it to say 'you survive' if you dont go over the waterfall or 'you die' if you go over that I am stuck on.
heres what I have so far, I know there are things wrong: #include <iostream> #include <cmath> using namespace std; int main () float ddown, wriver, vwater, vrow, dwf; cout << endl << "Enter value of width of the river"; cin >> ddown; ddown=(wriver*(vwater/vrow)) do { if ; done='y'; } while (done='y'); cout << endl << "Congrats! You Survive."; { if ; done='x'; } while (done='x'); cout << endl << "Ouch! You have drowned."; return 0; } -------------------- |
Coomer Anyone know C++? Oct 12, 2006 - 2:04 AM
hurley97 when I put that in and ran the program I got essen... Oct 12, 2006 - 3:21 AM
JonCars17 I asked a net friend of mine and this is what he s... Oct 12, 2006 - 6:32 AM
Rjb23 QUOTE(JonCars17 @ Oct 12, 2006 - 11... Oct 12, 2006 - 8:55 AM
phonex98 I agree with Jon. Its been a while since ive done ... Oct 12, 2006 - 8:37 AM
Starcraftjunkie x2. Initalize with the [10][5] and it should be f... Oct 12, 2006 - 12:05 PM
phonex98 im pretty sure he's using the cin (input) as a... Oct 12, 2006 - 9:38 AM
Coomer Awesome...that worked. Thanks a ton guys. Oct 12, 2006 - 12:17 PM
tomazws wow... haven't seen a C++ code for quite a whi... Oct 12, 2006 - 3:21 PM
hurley97 speaking of which... I should be writing a program... Oct 12, 2006 - 3:34 PM
Starcraftjunkie Coomer is using buckets as a variable name. He ca... Oct 12, 2006 - 8:27 PM
hurley97 ahh. the use of "int" confused me, I jus... Oct 12, 2006 - 10:49 PM
phonex98 QUOTE(hurley97 @ Oct 12, 2006 - 8:49... Oct 13, 2006 - 12:08 AM
XS4lv1Truch0x lmao i thought visual basic wass bad now im lookin... Oct 12, 2006 - 11:14 PM
Steevo < Pulls out hair <_<
I prefer Delphi... Oct 12, 2006 - 11:33 PM
XS4lv1Truch0x QUOTE(Steevo @ Oct 12, 2006 - 9:33 P... Oct 12, 2006 - 11:40 PM
Starcraftjunkie err. Hurley, your program doesn't make any sen... Oct 13, 2006 - 1:11 AM
hurley97 QUOTE(Starcraftjunkie @ Oct 13, 2006 - 2... Oct 13, 2006 - 1:15 AM
Starcraftjunkie o ya.. make sure you have a line to check the inpu... Oct 13, 2006 - 1:17 AM
hurley97 QUOTE(Starcraftjunkie @ Oct 13, 2006 - 2... Oct 13, 2006 - 1:18 AM
Starcraftjunkie ez. Just use an IF loop.
you calculated your Ddo... Oct 13, 2006 - 7:56 AM
Rjb23 What is a if loop and why would you need a loop?
... Oct 13, 2006 - 8:13 AM
hurley97 31 errors
#include <iostream>
#include ... Oct 13, 2006 - 9:42 AM
tomazws CODE
#include <iostream>
#include <cma... Oct 13, 2006 - 11:40 AM
hurley97 hey thanks! that helped A LOT!
now hopef... Oct 13, 2006 - 2:00 PM
Starcraftjunkie Is the Dwf provided by the question? or do you hav... Oct 14, 2006 - 12:19 AM
hurley97 it wasn't provided but it didn't say to as... Oct 14, 2006 - 7:33 PM![]() ![]() |
| Lo-Fi Version | Time is now: November 23rd, 2025 - 1:25 PM |