gcc的cin & C++标准地址

还是我们公司给新人培训C++的问题, 有一个作业是这样的:

从控制台读入一些字符串,然后放到链表里(这个自己实现), 然后排序输出.

培训负责人的目的是联系一下指针, 链表, 还有看一下编码规范, 还是释放内存等细节.

 

当然, 如若撇去这些目的, 这样一个功能, 我可能写出这样的代码:

 

#include <string.h>
#include <list>
#include <iostream>
#include <algorithm>
#include <iterator>

using namespace std;

int main() {

    list<string> strs;

    //input
    cout<<"please input ten string, and press CTRL+Z to press."<<endl;
    istream_iterator<string> input(cin);
    istream_iterator<string> end_of_stream;    
    copy(input,end_of_stream,inserter(strs,strs.begin()));

    //sort
    strs.sort();

    //output
    cout << "the sorted result is below." << endl;
    copy(strs.begin(), strs.end(), ostream_iterator<string > (cout, "\n"));
    return 0;

}

 

用gcc 3.2.3一编译, 没问题, 跑得很不错.

但在vc2008里面一跑, 傻了, 说cin 没有>>string这个方法.

查了一下, 原来cin>> string确实不是标准的做法.

看来gcc也..... 呵呵, 虽然我很喜欢他 :)

 

记录一下:

standards在线查看地址:

http://www.csci.csusb.edu/dick/c++std/#Drafts

http://www.csci.csusb.edu/dick/c++std/cd2/index.html

 

当然还可以google到pdf版本的,下面是一个可下载链接.

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1905.pdf

 

记得C同学告诉过我, 这个标准的打印版要19$,

所以很显然, 这篇blog里面最有价值的东西也就是这个几个链接了. 其余的都是废话. :)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值