... <看更多>
「scanf_s string」的推薦目錄:
- 關於scanf_s string 在 [問題] 可以用scanf存C++ String嗎? - 看板C_and_CPP 的評價
- 關於scanf_s string 在 String input using C scanf_s - Stack Overflow 的評價
- 關於scanf_s string 在 Reading Strings using scanf and gets Functions - YouTube 的評價
- 關於scanf_s string 在 ruby/scanf - GitHub 的評價
- 關於scanf_s string 在 scanf() to input string with space in C program(part_8.2.1) 的評價
- 關於scanf_s string 在 C 語言秘技(1) – 使用sscanf 模仿正規表達式的剖析功能 的評價
scanf_s string 在 ruby/scanf - GitHub 的推薦與評價
Scanf scans an input string or stream according to a format, as described below in Conversions, and returns an array of matches between the format and the ... ... <看更多>
scanf_s string 在 C 語言秘技(1) – 使用sscanf 模仿正規表達式的剖析功能 的推薦與評價
事實上,函數sscanf() 比scanf() 更為好用,sscanf() 甚至支援了類似Regular Expression 的功能,可以讓我們輕易的剖析格式化的字串。 sscanf 的函數原形如下,其中 ... ... <看更多>
scanf_s string 在 [問題] 可以用scanf存C++ String嗎? - 看板C_and_CPP 的推薦與評價
Q1: (已解決..就是此題不能這樣搞XD)
想請問我用了C++ String宣告變數之後
能否用C的Scanf把資料輸入該變數
然後用printf輸出?
像是:
string text;
scanf("%s",&text);
printf("%s\n",text);
-------------------------------------------------
Q2:
我現在用了C++ STL中的map開了一個Table
map<string,string> Table;
Table["Test"]="12345";
然後有一個char*變數為temp,其內容為"Test"
我可以用這個temp去作Table的index嗎?
像是cout<<Table[temp] <<endl;
然後顯示出"12345"
可以這樣搞嗎? 不行的話能不能作什麼修正去實行這個作法?
--
諸葛亮 :「魯肅,近來可好?」
魯肅 :「安然無恙。」
諸葛亮 :「魯夫人呢?」
魯肅 :「他應該在偉大的航道上。 」
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 118.233.40.239
關於Q2:
char code[7],op[3];
while(scanf("%s",code)!=EOF){
code[6]='\0', op[2]='\0';
printf("Input Code:%s\n",code);
strncpy(op,code,2);
cout<<op<<endl;
printf("OP-code:%s, mnemonic:%s\n",op,Table[op]);
}
其中op[3]是在while中才被指定內容.
執行到cout<<op<<endl;這邊都ok
但是最後一行printf就會掛掉..如果把Table[op]拿掉就正常...
所以..不能這樣用嗎?
※ 編輯: YCK 來自: 118.233.40.239 (03/30 00:52)
※ 編輯: YCK 來自: 118.233.40.239 (03/30 00:53)
... <看更多>