• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Please help! C++ Question

dmurray14

Golden Member
Hey guys,

I'm trying to finish up a program that's running fine except for one thing: my doubles aren't being read correctly from an array.

For instance, if I do:

double array[2][2];

array[0][0] = 1.2;

cout << array[0][0];

What I get is "0"

What am I doing wrong? I thought you could put doubles into an array just as easily as ints, but maybe not? Any help much appreciated!

Thanks,
Dan
 
I take it back! After staring at it for 2 hours I couldn't find anythign. Walked away and found the error right away. I was putting the value into an int before displaying it!! Agh..
 
lol, glad that you solved your problem.

Things like that happen all the time to me. When I am stuck, usually I'll take a break, and half of the time, I'll be able to spot the problem afterward.
 
🙂

Yeah that happens to me with JAVA and also happened to me when I was working with C++. Its hard for me to walk away until I figure it out. But more often than not when I walk away and do something else for a while, the answer just comes to me.

 
I figure out 99% of my stumpers by either:

1) Bothering somebody else with it and the process of explaining the bug makes me think of the solution
2) Goto the bathroom
3) Drive home
 
I learned that I could spend countless hours trying to debug a program only to finally give up in frustration, then find the problem within 15 minutes the next day. Tunnel vision I guess.
 
Originally posted by: Ryland
I figure out 99% of my stumpers by either:

1) Bothering somebody else with it and the process of explaining the bug makes me think of the solution
2) Goto the bathroom
3) Drive home

Yes on 1. and 3.
I got nothing on 2. though - toilets don't inspire me I guess 😛
 
Back
Top