小傻子 发表于 2015-2-12 21:43:48

为什么这个代码在cfree就是对的 在vs2010就是错的?? 这个里面有什么错误

#include<iostream>
#include<string>
#include<cctype>


void fill(std::string & one);


int main()
{
        using namespace std;
        string one;
        cout << "enter a string (q to quit):\t";
        fill(one);
        cout << one;
        while (one != 'q')
        {
                fill(one);
                cout << one;
                cout << "enter another string (q to quit) :\t";
        }
        return 0 ;
}

void fill(std::string & one)
{

std::getline(std::cin, one);
int n;
n = sizeof (one);
int i;
char ch;
for(i = 0; i < n; i++)
       {
               ch = one;
          one = toupper(ch);
}
}

freeparty 发表于 2015-2-12 22:11:20

本帖最后由 freeparty 于 2015-2-12 22:13 编辑

iostream加个.h试一试

freeparty 发表于 2015-2-12 22:14:20

头文件是要加.h的,iostream是个例外。
页: [1]
查看完整版本: 为什么这个代码在cfree就是对的 在vs2010就是错的?? 这个里面有什么错误