vector 转换为 int*

// libvtftp.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include 
#include 

void ShowIntArray(int* p, int nSize)
{
	if (NULL == p || nSize <= 0)
	{
		return;
	}

	TCHAR szBuff[36];
	::memset(szBuff, 0, sizeof(szBuff));

	for (int i = 0; i < nSize; i++)
	{
		int j = *(p + i);
		std::cout < vtInt;

	vtInt a;
	for (int i = 0; i < 10; i++)
	{
		a.push_back(i);
	}

	// 假设不知道vector容器大小
	int*p = NULL;
	p = new int[a.size()];
	
	for (int i = 0; i < a.size(); i++)
	{
		p[i] = a[i];
	}

	// 调用C的库函数
	ShowIntArray(p, a.size());

	delete []p;
	p = NULL;

	system("pause");

	return 0;
}

你可能感兴趣的:(c/c++)