2009-04-28 105 views

回答

15
#include <string> 

std::string my_strings[100]; 

這是使用STL的C++。在C語言中,你會做這樣的:

char * my_strings[100]; 

該讀作「我的琴絃是100指針數組爲char」,而後者是一個字符串是如何在C.

13

我會代表而推薦使用字符串矢量在幾乎所有情況下:

#include <string> 
#include <vector> 
std::vector<std::string> strings; 
0

傳統的單串:

char foo[100] // foo is a 100 character string 

你需要的可能是:

char foobar[100][100] // foobar is a 100 member array of 100 character strings 
相關問題