Printf and scanf

Printf and scanf

am 05.06.2005 14:21:05 von ankitjain1580

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@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html

Re: Printf and scanf

am 05.06.2005 15:54:13 von Arturas Moskvinas

> 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@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html

Re: Printf and scanf

am 05.06.2005 15:59:27 von Steve Graegert

On 6/5/05, Ankit Jain 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
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@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

Re: Printf and scanf

am 24.06.2005 23:20:35 von Hendrik Visage

On 6/5/05, Ankit Jain 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@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

Re: Printf and scanf

am 27.06.2005 20:11:03 von Andriot

Hendrik Visage wrote:

>On 6/5/05, Ankit Jain 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@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html

Re: Printf and scanf

am 28.06.2005 05:42:58 von joy merwin monteiro

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 wrote:
> Hendrik Visage wrote:
>
> >On 6/5/05, Ankit Jain 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@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
>


--
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@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