C语言中如何声明存储多个字符串的数组?
我说的字符串数组不是说仅存储一个字符串的数组,而是这样的数组:
数组【元素1】=字符串1
数组【元素2】=字符串2
类似这样的
总之就是达到把每个字符串当成一个元素放入数组的效果
那运行过程中赋值应该怎么写啊?比如:gets(s)
实现思路:使用std自带的string类进行存储字符串的操作。
例如使用如下代码:
#include<bits/stdc++.h>#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头文件中,包含即可。