+ 7

Why can't '#define' define this?

#define ... ; Why is the preprocessor not allowing it? I wanted to make things like this: #define printing cout //Working. !!! #define ... ; //Error. !!! printing<<"Hi"... //In main #define is used for substitutions, right? Then this should work! Is it that alphabets are required, and define won't work without them??

6th Apr 2017, 11:45 AM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
6 Antworten
+ 10
You're prolly trying to do something like this? https://code.sololearn.com/cuN2aN7mD9v6/?ref=app
6th Apr 2017, 1:42 PM
Hatsy Rei
Hatsy Rei - avatar
+ 9
Yeah I've looked at the MSDN C++ docs and ... is not a valid identifier. Here is the list of valid identifiers: https://msdn.microsoft.com/en-us/library/565w213d.aspx
6th Apr 2017, 1:33 PM
Karl T.
Karl T. - avatar
+ 8
Because the second argument must be a keyword a constant or a statement.
6th Apr 2017, 12:14 PM
Karl T.
Karl T. - avatar
+ 6
Ok, so I can only use valid identifiers in the first argument? That explains the error... Thank You!!!
6th Apr 2017, 1:41 PM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
+ 6
Yes! ... Something more 'English'...
6th Apr 2017, 1:43 PM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
+ 5
Its a null statement. And anyway, this works: #define ever ;; for(ever) //in main {}
6th Apr 2017, 1:28 PM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar