You don't actually say what is wrong with either of your examples, and I am assuming that
printf("STR(%s ),yytext");
is just a typo for
printf("STR(%s )",yytext);
but there are two problems that I can see.
If you've specified your problem correctly, you don't care what's inside the quotes as long as it isn't another quote. So your rule reduces to
\"[^"]*\" { ... }
The default action if no rules match is to echo the input. So you need another rule to consume everything that doesn't match this rule. Place this afterwards:
.|\n {}