VS中輸入字串和輸出字串問題

2021-09-23 14:36:05 字數 736 閱讀 2403

**

因為自己剛開始用vs,不是很習慣,今天發現乙個問題,就是我想實現輸入一段字串,然後在將它輸出來,發現沒有輸出,反而是聽了一會兒,然後閃退了,同樣的**放到dev c++執行卻很好使,我的**如下:

#include "stdio.h"

#include "stdlib.h"

#include "string.h"

int main(void)

找了挺久的問題,最後發現,因為vs自己加入了安全輸入函式,scanf_s(),而這個函式的用法不能像上面那麼用,正確的用法應該是:

#include "stdio.h"

#include "stdlib.h"

#include "string.h"

int main(void)

這時候執行就正常了,不想這麼麻煩的話可以不用scanf_s(),而是用scanf(),**如下:

#define _crt_secure_no_warnings 1

#include "stdio.h"

#include "stdlib.h"

#include "string.h"

int main(void)

這樣也能成功,至於#define _crt_secure_no_warnings 1這個怎麼實現一勞永逸,請參考我的另一篇部落格。

輸出字串

5.連線字串 半形句號 是字串連線符,可以把兩個字串連線成乙個字串。例如7 5 echo str.url 技巧 我們可以使用字串連線符累加字串。例如7 6 第一句我們給 str賦值,str表示字串 php中文社群位址是 第二句表示在 str的值上累加字串 www.phpnet.cn 所以,str最後...

輸入輸出字元和字串總結

scanf輸入單個字元 char letter scanf c letter scanf輸入字串 給數值型陣列賦值時,只能用for迴圈乙個乙個的賦值,但是字元陣列賦值時可以直接賦值,不需要使用迴圈,系統會在最後新增結束標誌符 0 char a 30 scanf s a 可以有 也可以沒有 inclu...

輸出字串Count and Say

最近研究輸出字串,稍微總結一下,以後繼續補充 標題如下 the count and say sequence is the sequence of integers beginning as follows 1,11,21,1211,111221,1is read off as one 1 or11...