vector oneToNine;
for(int i = 1; i <= 9; i++)
oneToNine.push_back(i);
use vectors
Oh thanks! I learned something even though i didn't ask the question xD Thanks!
Nope none of that....
If i make a array im gonna need to make like shit[9] = {0,1,2,3,4,5,6,7,9,+,9,859,89,8,96............}
There is not a way like..
shit[]= {1-9}
?
You can define almost anything you want, but you need to remember that the compiler won't give you a numerical result from #define.
#define is a preprocessor(Hence the '#'). The compiler will go through anything with a '#' before compiling the program, and with #define (in reference to your original post) it will replace every 'n1to9' it finds with '(i == (1 to 9))'. Then compile the program.
As long as whatever you are using it with can take an expression instead of just a variable you shouldn't have a problem.
But i don't know if it will work with any spaces. You will have to figure that out yourself.
@-Away
or something?
Like if i is 1 to 9, but in a declaration..
I dont want answers like tell me to do:
if(i <= 9 && i > 0) or something...
i just wanna know if is possible and how to declare a variable like that..
1 to 9 or something....
Well, I guess you could...
Since C++ isn't VB, you can't use VB syntax <<
Replace
Code:
#define n1to9 (i == (1 to 9))
with
Code:
#define n1to9 (i >= 1 && i <= 9)
Originally Posted by Disturbed
You can define almost anything you want, but you need to remember that the compiler won't give you a numerical result from #define.
#define is a preprocessor(Hence the '#'). The compiler will go through anything with a '#' before compiling the program, and with #define (in reference to your original post) it will replace every 'n1to9' it finds with '(i == (1 to 9))'. Then compile the program.
As long as whatever you are using it with can take an expression instead of just a variable you shouldn't have a problem.
But i don't know if it will work with any spaces. You will have to figure that out yourself.
@-Away
I always end up mindfucking myself over vectors. :confused:
Vectors aren't thread safe :(
Well ty, I see what i want is not possible...Thank you all anyway