首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

运用std:copy在deque中前20个元素拷贝的方法//哪错了?

2013-07-04 
使用std::copy在deque中前20个元素拷贝的方法//哪错了???#include stdafx.h#include deque#include i

使用std::copy在deque中前20个元素拷贝的方法//哪错了???


#include "stdafx.h"
#include <deque>
#include <iostream>
using namespace std;
#define BYTE unsigned char

deque<BYTE> h264Buffer;
BYTE buffer[50];
BYTE* p = NULL;

int _tmain(int argc, _TCHAR* argv[])
{

for(int i=0;i<50;i++)
buffer[i] = 'a';
h264Buffer.insert(h264Buffer.end(),buffer,buffer+50);
p = new BYTE[50+1];
for(int i=0;i<50;i++)
{
p[i] = h264Buffer.front();
h264Buffer.pop_front();
}
BYTE* p2 = new BYTE[50];
std::copy(h264Buffer.begin(),h264Buffer.begin()+10;p+10);
for(int i=0;i<50;i++)
cout<<p2[i]<<' ';
cout<<'\n';
//h264Buffer.push_back
return 0;
}

[解决办法]
std::copy(h264Buffer.begin(),h264Buffer.begin()+10;p+10);有俩分号哦。 
引用:
无效是无效;但是编译都过不了 copy前俩个参数错了!~~~~~~~

Quote: 引用:


    for(int i=0;i<50;i++)
    {
        p[i] = h264Buffer.front();
        h264Buffer.pop_front();
    }
    //h264Buffer is empty now
    BYTE* p2 = new BYTE[50];
    std::copy(h264Buffer.begin(),h264Buffer.begin()+10;p+10); //[h264Buffer.begin(),h264Buffer.begin()+10) 无效的区间。

热点排行