I have been working on writing a few preprocessor macros in C to help me with my work.
# define printSTRING(s) printf( # s " has the value"); \
for( ; *s != '\0'; s++) \
printf(*s); \
getch();
I am getting the error: C2105: '++' needs l-value
when I call printSTRING(Payload); where Payload is char Payload[] = "wjdoidnjdeioejneiodejndo";
I take it that its not seeing Payload as a char pointer, but I don’t know how to fix the issue.
That’s not they only error you will get. You probably want to use
putchar()instead, which takes a singlecharargument (printf()takes achar *format string, which you’re not giving it). Or, you can useputs()which prints the whole string (there’s no need to write a loop yourself in that case).The reason you are getting the error is that
Payloadis the name of an array, not a pointer. You cannot “increment” an array, although you can use the name of an array as if it were a pointer to the start of the array.