char* p=(char*)malloc(10);
in the above state ment,has the memory been initialised??...what is the difference between allocatingg it and initialising it??
thanks in avdance...

Recommended Answers

All 3 Replies

Quote from cpp reference:

'Allocates a block of size bytes of memory, returning a pointer to the beginning of the block.

The content of the newly allocated block of memory is not initialized, remaining with indeterminate values.'

1. Allocation means to create space for your application use
2. Initialize means to assign specific values to that space

Using malloc creates space, but contents of space undefined

thanks a lot guys...:) helped...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.