看板 C_and_CPP 關於我們 聯絡資訊
小弟剛開始學程式,上網爬文爬不到,請教一下各位高手 開發環境:visual studio 2019 程式碼: #include<stdio.h> int main(void) { int a = 0; int b = 0; scanf_s("%d", &a); b = scanf_s("%d", &a); printf("%d",b); return 0; } 請問為什麼我無法看到scanf_s的回傳值呢? 每次程式都會卡在我輸入完a之後,就沒有反應 ----- Sent from JPTT on my iPhone -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 49.216.168.91 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/C_and_CPP/M.1594784659.A.9AB.html
Schottky: 你的 scanf_s 寫了兩次是正確的嗎 07/15 11:56
Schottky: 然後 printf 忘了加換行符號 \n 07/15 11:57
Eveismywife: 你寫了2個scanf 那就要輸入2次R 07/15 12:09
Eveismywife: 2次都是輸入a的值 只是第二次取了scanf函式的回傳值 07/15 12:09
Eveismywife: 給b 07/15 12:09
loveme00835: 難得看到有接回傳值 :) 07/15 12:51
sweetfat: 問題解決了,謝謝兩位大大的幫助!另外第一次發文,突然 07/15 13:49
sweetfat: 發現自己沒有分類.. 07/15 13:49