房天下 > 房天下问答 > 业主生活 > 其他
  • C++编译问题

    程序代码如下:#include <iostream>#include <string>using namespace std;int main(){string c; int n; cin>>c; n=(int)sizeof(c); string temp; for (int i=0;i<n;i++) { temp[i]=c[i]-32; } string c1; c1= temp; cout << c1 << endl; return 0;}是一个大写变小写的的程序。结果是能编译通过,但是执行是显示停止工作。望高手解答原因。谢谢。(和我在vista下用VC++6.0有关系吗?)

    提问者:lucy_kaka

    发布于2011-01-25

共1个回答
  • huarongdd 丨Lv 0
    程序是有问题的,帮你修改了下,顺便去掉了多余的变量#include <iostream> #include <string> using namespace std; int main() { string c; cin >> c; for (int n = c.length() - 1; n >= 0; n--) if (c[n] >= 65 && c[n] <= 90) c[n] += 32; cout << c << endl; return 0; }vista下一般是不能用6.0的,不过也听说有人能正常使用的
    +1 2011-01-25 举报
热门人气推荐
免责声明:问答内容均来源于互联网用户,房天下对其内容不负责任,如有版权或其他问题可以联系房天下进行删除。