首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

关于 string,该怎么处理

2012-03-03 
关于 string请教各位大虾#includeiostream#includestringusingnamespacestdintmain(){strings1,s2co

关于 string
请教各位大虾

#include   <iostream>
#include   <string>
using   namespace   std;
int   main()
{
        string   s1,s2;
        cout < < "Enter   two   strings: " < <endl;
        cin> > s1> > s2;
        string::size_type   len1,len2;
              len1=s1.size();
              len2=s2.size();
          if   (len1=len2)
          cout < < "They   have   some   length. " < <endl;
          else     if(len1> len2)
          cout < < "\ " " < <s1 < < "\ "is   longer   than "
                  < < "\ " " < <s2 < < "\ " " < <endl;
          else
          cout < < "\ " " < <s2 < < "\ "is   longer   than "
                  < < "\ " " < <s1 < < "\ " " < <endl;
                  getchar   ();
          return   0;
         
        }

运行输入俩个string对象后没出现结果?
这是C++primer   书上例题!


[解决办法]
这样应该编译时都通不过吧.
getchar ();这是哪里的啊,没有包含头文件#include <stdio.h>



[解决办法]
==号让你打成了=
这样只会有一个结果They have some length.
[解决办法]
请添加#include <stdio.h>
请修改=为==
问题解决.

以后写代码,仔细点

热点排行