1

Assume like I have a #define something like

#define LOCATION /usr/lib/siara/

Now i want to touch a file in that location provided I have permissions to create. I want to do something like this.

system("touch $(LOCATION)/myfile.txt")

But it is not working. Any idea how to resolve this issue

mch
  • 9,424
  • 2
  • 28
  • 42
harish
  • 11
  • 1
  • can you change the define to `#define LOCATION "/usr/lib/siara/"`? In that case you can use `system("touch "LOCATION"myfile.txt");`. – mch Oct 12 '16 at 15:52
  • 1
    The particular answer OP wants is this one: http://stackoverflow.com/a/32665978/767442 – jforberg Oct 12 '16 at 15:53
  • @jforberg he can do it in compile time as mch's comment – Danh Oct 12 '16 at 15:54
  • @MichaelWalz, why is the OP's definition invalid? There's certainly nothing wrong with the identifier, and I'm missing why `/usr/lib/siara/` would fail to be a sequence of preprocessing tokens, which is the only constraint on that part. It may indeed not be what he wants, but I think it's valid. – John Bollinger Oct 12 '16 at 16:10
  • @JohnBollinger , you are right my comment is wrong, I'll delete it, thanks. – Jabberwocky Oct 12 '16 at 16:16

0 Answers0