第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會有你想問的

c中的什么scanf函數(shù)返回?

c中的什么scanf函數(shù)返回?

C
紅顏莎娜 2019-09-03 15:54:48
我知道簽名是int scanf(const char *format, ...)這個(gè)int值與什么有關(guān)?
查看完整描述

3 回答

?
喵喔喔

TA貢獻(xiàn)1735條經(jīng)驗(yàn) 獲得超5個(gè)贊

來自scanf:


成功時(shí),該函數(shù)返回成功讀取的項(xiàng)目數(shù)。如果發(fā)生匹配故障,此計(jì)數(shù)可以匹配預(yù)期的讀數(shù)或更少,甚至為零。如果在成功讀取任何數(shù)據(jù)之前輸入失敗,則返回EOF。


查看完整回答
反對 回復(fù) 2019-09-03
?
忽然笑

TA貢獻(xiàn)1806條經(jīng)驗(yàn) 獲得超5個(gè)贊

從技術(shù)上講,這是UB(未定義的行為)。


int g;

int p=scanf("%d",g);

                 ^

您將一個(gè)整數(shù)化的整數(shù)傳遞給scanf以將其用作要寫入的地址。從現(xiàn)在開始,任何事情都可能發(fā)生。很可能你的應(yīng)用程序會崩潰。


查看完整回答
反對 回復(fù) 2019-09-03
?
catspeake

TA貢獻(xiàn)1111條經(jīng)驗(yàn) 獲得超0個(gè)贊

從man頁面:


NAME

       scanf,  fscanf, sscanf, vscanf, vsscanf, vfscanf 


       ...


RETURN VALUE

       These functions return the number of input items  successfully  matched

       and assigned, which can be fewer than provided for, or even zero in the

       event of an early matching failure.


       The value EOF is returned if the end of input is reached before  either

       the  first  successful conversion or a matching failure occurs.  EOF is

       also returned if a read error occurs, in which case the error indicator

       for  the  stream  (see ferror(3)) is set, and errno is set indicate the

       error.

在你的情況下,scanf()可以返回0,1或EOF。


PS正如其他人所指出的那樣,你在前面錯過了一個(gè)&符號g:


int p=scanf("%d",&g);

沒有&符號,代碼的行為是不確定的。


查看完整回答
反對 回復(fù) 2019-09-03
  • 3 回答
  • 0 關(guān)注
  • 391 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號