close

cin.get(array ,size n , delimit  '\n' )

delimit  '\n'代表當擷取輸入字元遇到'\n',即停止擷取擷取輸入,而非代表停止擷取字串的字元為字串結束字元'\0'.

結束字元'\0'無法從鍵盤輸入,故無法作為標準輸入的停止擷取字元.

(但檔案物件從檔案輸入字元,可否使用結束字元'\0'作為停止擷取字元???)

cin.get(array ,size n , delimit  '\n' )會被下一個擷取函數接收的是停止擷取字元'\n',而非結束字元'\0'

cin.get(array ,size n )  與  cin.getline(array ,size n  )預設停止擷取字元均為按enter鍵'\n'

cin.get(array ,size n ,'ch')會將停止擷取字元'ch'保留在buffer內.讓下一個擷取函式接收.

 cin.getline(array ,size n ,'ch')則會將停止擷取字元'ch'捨去.

(並非將enter鍵'\n'空白鍵捨去,除非使用enter鍵'\n'空白鍵作為停止擷取字元)

arrow
arrow
    全站熱搜

    minsin 發表在 痞客邦 留言(0) 人氣()