print % in c

Allan Magnuson awm at shamash.cdc.com
Tue Feb 26 11:49:51 AEST 1991


In article <1991Feb25.232900.18406 at usenet.ins.cwru.edu> dean at po.CWRU.Edu writes:
>In article <31530035 at hpcvia.CV.HP.COM> brianh at hpcvia.CV.HP.COM (brian_helterline) writes:
>>Any character following a \ will be taken literally so just preceed
>>any "special" char with a \ so:
>>
>>	printf( "This is a slash \\ and a precent sign \%\n" )
>>
>>would produce: This is a slash \ and a percent sign %
>Ahhh no.
>

Well to waste more bandwith....I compiled, linked, linted and tested this one.

#include <stdio.h>

main()
        {
        printf ("This is a percent sign %c\n",'%');
        printf ("This is a percent sign %%\n");
        printf ("This is a percent sign %s\n","%");
        printf ("This is a percent sign %c\n",'\045');  /* ASCII dependent */
        printf ("This is a percent sign %c\n",0x25);    /* ASCII dependent */
        }

Eric Swildens
awm at shamash.cdc.com   ( Still using Al's account ;-) )



More information about the Comp.lang.c mailing list