Printf and scanf

hi

this is a simple problem which somebody asked me and i
am not able to solve. if somebody here can help me out

i just want to know how scanf function can be used on
the place of printf and vice versa

thanks

ankit

Send instant messages to your online friends http://uk.messenger.yahoo.com
-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo [at] vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
ankitjain1580 [ So, 05 Juni 2005 14:21 ] [ ID #823869 ]

Re: Printf and scanf

> hi
>
> this is a simple problem which somebody asked me and i
> am not able to solve. if somebody here can help me out
>
> i just want to know how scanf function can be used on
> the place of printf and vice versa

Scanf reads from STDIN and printf writes into STDOUT. I do not think
there is any way to change reading operation with writing... Of course
some alchemy might help you :)

I think you misinterpreted something...

Arturas Moskvinas
-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo [at] vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Arturas Moskvinas [ So, 05 Juni 2005 15:54 ] [ ID #823871 ]

Re: Printf and scanf

On 6/5/05, Ankit Jain <ankitjain1580 [at] yahoo.com> wrote:
> hi

Hello,

> i just want to know how scanf function can be used on
> the place of printf and vice versa

Hmm, I think I do not understand your question. Can you give an
example of what you want to achive?

Kind Regards

\Steve

--

Steve Graegert <graegerts [at] gmail.com>
Independent Software Consultant {C/C++ && Java && .NET}
Mobile: +49 (176) 21 24 88 69
Office: +49 (9131) 71 26 40 9
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo [at] vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
Steve Graegert [ So, 05 Juni 2005 15:59 ] [ ID #823872 ]

Re: Printf and scanf

On 6/5/05, Ankit Jain <ankitjain1580 [at] yahoo.com> wrote:

> i just want to know how scanf function can be used on
> the place of printf and vice versa

In the Obfuscated C contest one of the first/early entries is one that
states "Using read to write" (Or something to similar extend, or
perhaps even using scanf to print). Reading that code is hackery, and
from my first glance at the code, it was don't with quote and macro
hackery.

Thus you could #define scanf __prinf and #define printf __scanf... or
something with similar confusing

--
Hendrik Visage
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo [at] vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
Hendrik Visage [ Fr, 24 Juni 2005 23:20 ] [ ID #851255 ]

Re: Printf and scanf

Hendrik Visage wrote:

>On 6/5/05, Ankit Jain <ankitjain1580 [at] yahoo.com> wrote:
>
>
>
>>i just want to know how scanf function can be used on
>>the place of printf and vice versa
>>
>>
>
>In the Obfuscated C contest one of the first/early entries is one that
>states "Using read to write" (Or something to similar extend, or
>perhaps even using scanf to print). Reading that code is hackery, and
>from my first glance at the code, it was don't with quote and macro
>hackery.
>
>Thus you could #define scanf __prinf and #define printf __scanf... or
>something with similar confusing
>
>

Of course, it is not possible to use directly printf like a scanf ;)
But you can use printf to write some values into arguments when you call
the function. This uses special caracters you put in the format string.
And this should prevent you to call printf with a string the user wrote,
because this is a very big security hole.

JP


-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo [at] vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Andriot [ Mo, 27 Juni 2005 20:11 ] [ ID #854608 ]

Re: Printf and scanf

Now you have piqued my interest.......
what special characters??
any place on the net I can read up on this?

Joy


On 6/27/05, Andriot <andriot [at] 6wind.com> wrote:
> Hendrik Visage wrote:
>
> >On 6/5/05, Ankit Jain <ankitjain1580 [at] yahoo.com> wrote:
> >
> >
> >
> >>i just want to know how scanf function can be used on
> >>the place of printf and vice versa
> >>
> >>
> >
> >In the Obfuscated C contest one of the first/early entries is one that
> >states "Using read to write" (Or something to similar extend, or
> >perhaps even using scanf to print). Reading that code is hackery, and
> >from my first glance at the code, it was don't with quote and macro
> >hackery.
> >
> >Thus you could #define scanf __prinf and #define printf __scanf... or
> >something with similar confusing
> >
> >
>
> Of course, it is not possible to use directly printf like a scanf ;)
> But you can use printf to write some values into arguments when you call
> the function. This uses special caracters you put in the format string.
> And this should prevent you to call printf with a string the user wrote,
> because this is a very big security hole.
>
> JP
>
>
> -
> To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
> the body of a message to majordomo [at] vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.linux-learn.org/faqs
>


--
<ed__> riel: if it were a vax, gcc would probably be an opcode

- excerpt from #kernelnewbies
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo [at] vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
joy merwin monteiro [ Di, 28 Juni 2005 05:42 ] [ ID #856202 ]
Linux » gmane.linux.newbie » Printf and scanf

Vorheriges Thema: Additional earning! More than 750 EUROS per week
Nächstes Thema: How to install redhat9.0 on SATA harddisk