-1
#include <stdio.h>    

#define get(s) #s  //***

int main()
{
    char str[] = get(hello);  //***

    printf("%s\n", str);
    return 0;
}

Help me to understand the two lines with the //*** comment? Can anyone describe what's happening in the #define?

Jabberwocky
  • 48,281
  • 17
  • 65
  • 115
AA M
  • 17
  • 6

1 Answers1

0

This is using the preprocessor's stringification feature. You can read more about it at https://en.cppreference.com/w/c/preprocessor/replace under "# and ## operators".

The effect is that the second marked line expands to

    char str[] = "hello";
Nate Eldredge
  • 48,811
  • 6
  • 54
  • 82