-2

I think it's put in the stack because the string "Hello world" is a parameter of function printf?

If i'm wrong, can someone give and explane the correct answer?

Hladni
  • 11
  • 3

1 Answers1

1

String literals have static storage duration. Commonly they are stored in read-only memory. They usually go into sections called .rodata (linux) or .rdata (windows). Providing the string literal as a function parameter behaves the same as defining it as const char *s = "Hello world" beforehand.

Have a look at these discussions:

Community
  • 1
  • 1
nucleon
  • 1,128
  • 1
  • 6
  • 19