关于字串符的有关问题

关于字串符的问题
相比较两个字串符中的值是否相同,写了个用for循环然后比较每个字串符中元素的程序 但是不对,麻烦给看一下,另外想问一个问题是vector<string> i 和string i 这两个对象从实质上来说有什么区别么,还有能不能把string对象看作是字符数组?谢谢啦

#include<iostream>
#include<string>

using namespace std;

int main()
{
string s1;
string s2;
cout<<"Please enter words for s1:"<<endl;
getline(cin,s1);
cout<<"Please enter words for s2:"<<endl;
getline(cin,s2);
if (s1.size()==s2.size())
{
for ( i=0;i!=s1.size();++i)
{
if (s1[i]!=s2[i])
{
cout<<"s1 and s2 are different."<<endl;

}
    

}
cout<<"s1 and s2 are same."<<endl;
}
else
cout<<"s1 and s2 are different."<<endl;
return 0;
}

------解决方案--------------------
当字符串长度相等时,你的代码会对所有字符一一比较,只要有不相等的字符就输出"s1 and s2 are different.",然后无论字符串是否相等都输出"s1 and s2 are same."是这样吧?


    if (s1.size()==s2.size())
    {
        for ( i=0;(i!=s1.size()) && (s1[i] == s2[i]);++i)
        //加一个循环退出条件,找到第一个不相等的字符
        //其实非计数循环应该改用while实现,我是在你的代码上改,就还用for
        {
        }
        if( i == s1.size() )//未找到不相等的字符
        {
           cout<<"s1 and s2 are same."<<endl;
        }
        else
        {
           cout<<"s1 and s2 are diffrent."<<endl;

         }
    }
    else
        cout<<"s1 and s2 are different."<<endl;



------解决方案--------------------
晕,我刚才那个不对,说一遍吧,第16行的i你没有定义就使用不行,i前面加上int;第20行当判断出不同时虽然输出错误信息了但是没有相应处理,21行加上return 0;
应该差不多了。
vector<string> i 和string i 这两个对象从实质上来说有什么区别么?
当然有区别,前面是string类数组,后面是string类。
还有能不能把string对象看作是字符数组?
你可能看到他们的赋值挺像的,但不能看成一样,不过他、它们两个之间能够互相转化。