亚洲最大看欧美片,亚洲图揄拍自拍另类图片,欧美精品v国产精品v呦,日本在线精品视频免费

  • 站長(zhǎng)資訊網(wǎng)
    最全最豐富的資訊網(wǎng)站

    C 中使用 gets() 提示 warning: this program uses gets(), which is unsafe.

    C 中使用 gets() ,編譯時(shí)會(huì)出現(xiàn)如下警告:

    warning: this program uses gets(), which is unsafe.

    gets() 不安全是因?yàn)槟憬o了他一個(gè)緩沖區(qū),但是你卻沒(méi)有告訴它這個(gè)緩沖區(qū)到底有多大,也不知道輸入的內(nèi)容到底有多大,輸入的內(nèi)容可能超出緩沖區(qū)的結(jié)尾,引起你的程序崩潰。

    解決方法可以使用 fgets 替代:

    char buffer[bufsize];  fgets(buffer, bufsize, stdin);

    實(shí)例:

      // 使用 gets()  char buffer[4096];  gets(buffer);     // 使用 fgets() 替換 gets()  char buffer[4096];  fgets(buffer, (sizeof buffer / sizeof buffer[0]), stdin);  
    贊(0)
    分享到: 更多 (0)
    網(wǎng)站地圖   滬ICP備18035694號(hào)-2    滬公網(wǎng)安備31011702889846號(hào)