Posts: 1,813
Threads: 284
Joined: Mar 2003
http://www.google.com/search?hl=en&ie=UT...%23declare
I can't figure out how to use #declare the same way you use CONST. I found this page:
http://www.povray.org/documentation/view/146/
But I'm not sure if it's even C!
Please help.
earn.
Posts: 1,752
Threads: 21
Joined: Jun 2002
Use #define.
Code:
#define YOURCONST 1234
printf("%d", YOURCONST);
Posts: 691
Threads: 5
Joined: Apr 2002
Plasma's solution will work but as an alternative you can use the const keyword:
Code:
const int x = 5;
printf("Constant x = %d\n", x);
The #define method given by Plasma has the preprocessor replace all occurances of YOURCONST with the string of text (its not actually a value as such) 1234 before compiling. This is fine for most solutions, except when you want some finer control, for example:
Code:
#define YOURCONST 1234
const int x = 5;
/* Okay, because x is a variable */
printf("Address of x = %d\n", &x);
/* Not okay, because YOURCONST is just a number */
printf("Address of YOURCONST = %d\n", &YOURCONST);
esus saves.... Passes to Moses, shoots, he scores!
Posts: 1,813
Threads: 284
Joined: Mar 2003