-2

Problem statement :- I am searching for a tool that automatically include a line in c functions , line is printf("%s",FILE); , since i do not found any tool i decided to write my own script that write line at start of every function .

i am trying to print statement printf("%s",__FILE__); using python

print(   printf("%s",__FILE__);   )

I am facing issue when trying to print double quotes and %s , i have tried raw(r) but it doesn't help.

jonty
  • 29
  • 5
  • So you want to print the script's name? If so, [this question](https://stackoverflow.com/questions/4152963/get-name-of-current-script-in-python) might help you. – albert Mar 30 '21 at 15:29
  • Please clarify what you are trying to do, how you try to do it, and what error you get. The code shown is not valid syntax, regardless of quotes or ``%s``; please provide a [mcve]. Did you mean to ``print('printf("%s",__FILE__);')``? – MisterMiyagi Mar 30 '21 at 15:35
  • @MisterMiyagi i am trying to include printf("%s",__FILE__); for every function in c source code , i thought to automate this process as it takes days to include printf("%s",__FILE__); manually – jonty Mar 30 '21 at 15:43
  • @MisterMiyagi Your suggestion worked well only issue when i include printf("%s\n",__FILE__); \n is not working properly – jonty Mar 30 '21 at 15:44
  • 1
    What do you mean by "not working properly"? Does it result in unexpected output? Does it throw an error? – MisterMiyagi Mar 30 '21 at 15:53
  • as soon as \n is executed standard output goes to new line . please this at your end print('printf("%s\n",__FILE__);') – jonty Mar 30 '21 at 15:54
  • Well, yes of course ``\n`` creates a new line – that literally is what it means. Do you want to print a literal ``\`` followed by a literal ``n``? As in ``print('printf("%s\\n",FILE);')``? – MisterMiyagi Mar 30 '21 at 15:57
  • Just use this, we have to use a back slash to escape the characters print(" printf(\"%s\",__FILE__); " ) – SARAN SURYA Mar 30 '21 at 16:07
  • Look folks, when posting code in comments please use \`\`code quotes\`\`. – MisterMiyagi Mar 30 '21 at 16:09

1 Answers1

0

Maybe you can try :

print('    printf("%s",__FILE__); ')
Zerty91
  • 1
  • 2