Puas yog Fscanf xa rov qab EOF?
Puas yog Fscanf xa rov qab EOF?

Video: Puas yog Fscanf xa rov qab EOF?

Video: Puas yog Fscanf xa rov qab EOF?
Video: Da Vang - Puas Yog Nyuab2 Koj (nkauj tawm tshiab 2021) 2024, Kaum ib hlis
Anonim

fscanf rov EOF yog kawg ntawm cov ntaub ntawv (lossis ib qho yuam kev input) tshwm sim ua ntej yuav muab qhov tseem ceeb. Yog tias muaj nuj nqis khaws cia, nws rov qab los tus naj npawb ntawm cov khoom khaws cia; uas yog, tus naj npawb ntawm lub sij hawm tus nqi raug muab nrog ib qho ntawm cov fscanf ua argument pointers. EOF yog rov qab los yog tias muaj qhov yuam kev tshwm sim ua ntej txhua yam khoom sib tw.

Ntawm no, Fscanf rov qab los li cas?

Cov fscanf ua () ua haujlwm rov qab los tus naj npawb ntawm cov teb uas nws ntse hloov dua siab tshiab thiab muab. Cov rov qab los tus nqi ua tsis suav cov teb uas cov fscanf ua () muaj nuj nqi nyeem tab sis tsis muab. Cov rov qab los tus nqi yog EOF yog tias qhov kev nkag tsis tau tshwm sim ua ntej kev hloov pauv, lossis tus naj npawb ntawm cov khoom nkag tau muab yog tias ua tiav.

Ib yam li ntawd, Fscanf puas nyeem kab los ntawm kab? Qhov teeb meem yog tas koj fscanf xav yeej tsis nyeem cov kab tshiab kawg ntawm thawj kab . Yog li thaum nws yog hu ua zaum ob, nws yuav poob (rov qab 0, tsis yog EOF) thiab nyeem tsis muaj dab tsi, tawm hauv qhov tsis hloov pauv.

Ib yam li ntawd, koj tuaj yeem nug, Fscanf ua dab tsi hauv C?

Cov fscanf ua () muaj nuj nqi yog siv los nyeem formatted input los ntawm cov ntaub ntawv. Nws ua haujlwm ib yam li scanf() muaj nuj nqi tab sis tsis txhob nyeem cov ntaub ntawv los ntawm tus qauv nkag nws nyeem cov ntaub ntawv los ntawm cov ntaub ntawv.

Dab tsi yog qhov kawg ntawm cov ntaub ntawv hauv C?

EOF txhais tau tias kawg ntawm cov ntaub ntawv . Nws yog ib qho kos npe tias kawg ntawm a ntaub ntawv mus txog, thiab hais tias yuav tsis muaj ntaub ntawv ntxiv lawm. Ntawm Linux systems thiab OS X, tus cwj pwm los tawm tswv yim ua rau EOF yog CTRL + D. Rau Windows, nws yog CTRL + Z.

Pom zoo: