The following webpage http://www.mekong.net/tech/printf.htm indicates that the format specifier %% will print one % but in hoc it prints 2 of them. So printf("aaa %%g bbb") will print:
aaa %%g bbb
If this is a deviation from the standard, could it be fixed?
Escaping backslashes works well, so printf("aaa %%g bbb\\n") will print:
aaa %%g bbb\n
escape % in printf
Re: escape % in printf
The fix is at http://www.neuron.yale.edu/hg/neuron/nr ... 3444e22186
This fix was applied to the trunk (NEURON -- VERSION 7.4) and NEURON -- Release 7.3 continues to have the old behavior. Consider
The 7.3 gives
And 7.4 with the fix gives
This fix was applied to the trunk (NEURON -- VERSION 7.4) and NEURON -- Release 7.3 continues to have the old behavior. Consider
Code: Select all
$ cat temp.hoc
printf("%%\n")
printf("abc%%def\n")
printf("%\n")
printf("abc%def", 2)
printf("abc%def")
Code: Select all
%%
3
abc%%def
9
%
2
abc2ef 6
nrniv: printf not enough arguments
Code: Select all
%
2
abc%def
8
%
2
abc2ef 6
nrniv: printf not enough arguments
Re: escape % in printf
Sorry. I botched the previous fix which introduced much more serious problems. See:
http://www.neuron.yale.edu/hg/neuron/nr ... 8d1dbd1346
http://www.neuron.yale.edu/hg/neuron/nr ... 8d1dbd1346