LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

how to escape % in sprintf

I am trying create an sql query string using sprintf but my query contains %f. How do I escape %f?

 

sprintf(qryStr, "SELECT * from SpecTable where part_no like '%f9%' and spectype ='%s'", mode);

0 Kudos
Message 1 of 6
(3,498 Views)

use %%:

 

sprintf(qryStr, "SELECT * from SpecTable where part_no like '%%f9%' and spectype ='%s'", mode);

0 Kudos
Message 2 of 6
(3,492 Views)

"%%"

0 Kudos
Message 3 of 6
(3,490 Views)

We doubled 😉

0 Kudos
Message 4 of 6
(3,488 Views)

matching the double % Smiley Very Happy

0 Kudos
Message 5 of 6
(3,486 Views)

Pun intended  Smiley Wink

0 Kudos
Message 6 of 6
(3,484 Views)