use a pointer and memcpy:
void * memcpy ( void * destination, const void * source, size_t num );
Suppose you want to copy an array A of length n into an array B
memcpy (B, A, n * sizeof(char));
This is more C than C++, the string class have copy capabilities you can use.
size_t length;
char buffer[20];
string str ("Test string...");
length=str.copy(buffer,6,5);
buffer[length]='';
Here's a more specific sample with a complete code:
#include <stdio.h>
#include <string>
#include <string.h>
#include <iostream>
using namespace std;
int main()
{
string s("Hello World");
char buffer [255];
void * p = buffer; // Or void * p = getPosition()
memcpy(p,s.c_str(),s.length()+1);
cout << s << endl;
cout << buffer << endl;
return 0;
}
let me know if you need more details
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…