#include <iostream> using std::cout; using std::endl; int main() { char * s = "hello world"; char * buffer; int bufferSize = 15; memcpy(&buffer, &s, 5); for (int i = 0; i < bufferSize; i++) { cout << buffer[i]; } cout << endl; delete [] buffer; return 0; }
If I comment out the memcpy line, it doesn't seg fault.
Edited by benobi, 09 June 2005 - 01:51 PM.