Puas yog printf sau rau stdout?
Puas yog printf sau rau stdout?

Video: Puas yog printf sau rau stdout?

Video: Puas yog printf sau rau stdout?
Video: Statistics with Python! Variance and Standard Deviation 2024, Kaum ib hlis
Anonim

printf () - thiab qee qhov "luam tawm" ua haujlwm xws li puts() - sau rau tus qauv tso zis , kuj hu ua stdout los yog thaum kawg File descriptor 1.fprintf(stderr, …) - sau nws tso zis rau standarderror tso zis , tseem hu ua stderr lossis File Descriptor2.

Raws li txoj cai, tus qauv tso zis yog dab tsi?

Txheem tso zis , tej zaum abbreviated stdout , yog hais txog tus qauv kwj ntawm cov ntaub ntawv uas yog tsim los ntawm cov kab lus hais kom ua (piv txwv li, txhua hom ntawv hom kev pab cuam) hauv Linux thiab lwm yam kev ua haujlwm zoo li Unix. Vim lub txheem cov kwj deg yog cov ntawv dawb, lawv txhais tau tias tib neeg nyeem tau.

Tom qab, lo lus nug yog, qhov system hu li cas printf siv? printf () yog ib qho ntawm APIs lossis interfaces nthuav tawm cov neeg siv qhov chaw rau hu ua haujlwm los ntawm C lub tsev qiv ntawv. printf () ua tau siv sau() system hu . Tus sau () system hu yog tiag lub luag hauj lwm rau xa cov ntaub ntawv rau cov zis.

Ua kom qhov no saib, stdin thiab stdout yog dab tsi?

Yog kuv to taub yog lawm, stdin yog filein uas ib qho program sau rau hauv nws qhov kev thov kom khiav ib txoj haujlwm hauv tus txheej txheem, stdout yog cov ntaub ntawv uas cov ntsiav sau nws cov zis thiab cov txheej txheem thov nws nkag tau cov ntaub ntawv los ntawm, thiab stderr yog cov ntaub ntawv uas txhua qhov kev zam tau nkag.

Tus qauv tswv yim thiab cov zis yog dab tsi?

Cov txheem tswv yim ntaus ntawv, kuj hu ua stdin , yog lub cuab yeej los ntawm qhov twg nkag mus rau qhov systemis coj. Cov txheem tso zis ntaus ntawv, tseem hu ua asstdout, yog lub cuab yeej rau qhov twg tso zis los ntawm qhov system issent. Feem ntau qhov no yog cov zaub, tab sis koj tuaj yeem hloov pauv tso zis mus rau qhov chaw nres nkoj serial lossis cov ntaub ntawv.

Pom zoo: