注册 登录
编程论坛 C++教室

c++ primer上的一段程序为何无法通过编译?

zhengxiang3014 发布于 2010-02-01 21:01, 762 次点击
程序代码:
#include <string>
#include <iostream>

using std::cin;
using std::cout;
using std::endl;
using std::string;

int main()
{
    string word;
    // read until end-of-file, writing each word to a new line
    while (cin >> word) 
        cout << word << endl;
    return 0;
}
上面这段程序是C++ Primer上的,为何出现无法编译的错误啊?


5 回复
#2
luxiaocheng2010-02-01 22:15
头文件夹.h
#include<iostream.h>
#include<string.h>
不知道下面你有没有错。要睡觉了
不然帮你在 VC中看看
#3
pangding2010-02-02 01:57
出的错误提示是什么?
#4
pangding2010-02-02 01:58
出的错误提示是什么?
#5
zhengxiang30142010-02-02 14:10
错误提示如下:
13:parse error befor character 035
16:confused by earlier errors,bailing out

我用的编译器是C-Free 3.5
#6
luxiaocheng2010-02-02 14:37
#include <string>
#include <iostream>

using std::cin;
using std::cout;
using std::endl;
using std::string;

int main()
{
    string word;
    // read until end-of-file, writing each word to a new line
    while (cin >> word) .
        cout << word << endl;
    return 0;
}

把你的代码复制到VC中while (cin >> word) .多了个点,去掉就OK。。。
是不是这原因
只有本站会员才能查看附件,请 登录
1