On Thu, Nov 09, 2006 at 11:59:12AM -0500, Jason Dixon wrote:
> > I have problems to print '%' in stdout... Suppose code below:
> >
> > #include <stdio.h>
> >
> > main() {
> > char foo[] = "bar=30%\n";
> > fprintf(stdout, bar);
> > }
> >
> > OpenBSD returns : bar=30
> > Linux returns : bar=30%
> >
> > How can I solve this? Thanks,
>
> $ cat foo.c
> #include <stdio.h>
>
> main() {
> char foo[] = "bar=30%%\n";
> fprintf(stdout, foo);
heh, you found the bug. i just wanted to bet that the code would not
run under linux...
> }
> $ gcc foo.c -o foo
> $ ./foo
> bar=30%
>
you should also completely avoid the format string in this case.
printf("%s", foo);
reyk