六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 80|回复: 0

gcc的cin & C++标准地址

[复制链接]

升级  59.33%

114

主题

114

主题

114

主题

举人

Rank: 3Rank: 3

积分
378
 楼主| 发表于 2013-2-5 01:07:02 | 显示全部楼层 |阅读模式
还是我们公司给新人培训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里面最有价值的东西也就是这个几个链接了. 其余的都是废话. :)
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表