C语言中如何声明存储多个字符串的数组?

C语言中如何声明存储多个字符串的数组?
我说的字符串数组不是说仅存储一个字符串的数组,而是这样的数组:
数组【元素1】=字符串1
数组【元素2】=字符串2
类似这样的
总之就是达到把每个字符串当成一个元素放入数组的效果
那运行过程中赋值应该怎么写啊?比如:gets(s)

实现思路:使用std自带的string类进行存储字符串的操作。

例如使用如下代码:

#include<bits/stdc++.h>
using namespace std;
string a[233];
int main()
{
    do something;    
    }


#include<bits/stdc++.h>这个头文件包含以下等等C++中包含的所有头文件:   

#include <iostream>    

   #include <cstdio>    

   #include <fstream>    

   #include <algorithm>    

   #include <cmath>    

   #include <deque>    

   #include <vector>    

   #include <queue>    

   #include <string>    

   #include <cstring>    

   #include <map>    

   #include <stack>    

   #include <set>     等等……

string类型定义在string头文件中,包含即可。

温馨提示:答案为网友推荐,仅供参考
第1个回答  2010-06-18
那就是二位数组,每一行表示一个字符串
char s[5][10];
表示s是可以存放5行容量为10个字符的字符串的二维数组

gets(s[i]);即可本回答被提问者采纳
相似回答