![]() |
| | #1 |
| Registered User Join Date: Dec 2008
Posts: 14
| Every time I use %d I get an incorrect number Code: #include <stdio.h>
int main( void )
{
int f = 2;
printf("%d", &f);
getchar();
return 0;
}
2293620 halp plz |
| Demipimp is offline | |
| | #2 |
| C++ Witch Join Date: Oct 2003 Location: Singapore
Posts: 10,356
| Since you want to print the value of f, you should not be taking its address: Code: #include <stdio.h>
int main( void )
{
int f = 2;
printf("%d", f);
getchar();
return 0;
}
__________________ C + C++ Compiler: MinGW port of GCC Build + Version Control System: SCons + Bazaar Look up a C/C++ Reference and learn How To Ask Questions The Smart Way |
| laserlight is online now | |
| | #3 |
| Registered User Join Date: Nov 2008
Posts: 25
| Wow, I actually sort of knew that. Astonishing. |
| newbcore is offline | |
| | #4 |
| Registered User Join Date: Dec 2008
Posts: 14
| God Ham ok right OMG I forgot |
| Demipimp is offline | |
![]() |
| Tags |
| error |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Stone Age Rumble | KONI | Contests Board | 30 | 04-02-2007 09:53 PM |
| Need help with time | Gong | C++ Programming | 7 | 01-11-2007 02:43 PM |
| How can I read one number at a time? | Bad_Scooter | C++ Programming | 2 | 07-18-2003 09:58 PM |
| I apologize. Good bye. | doubleanti | A Brief History of Cprogramming.com | 14 | 05-03-2002 06:51 PM |
| Random Number problem in number guessing game... | -leech- | Windows Programming | 8 | 01-15-2002 05:00 PM |