Posted by: arch119 August 2, 2005
Information technology
Login in to Rate this Post:     0       ?        

>>sojodude char* p; char* q; p = (char*)malloc(6); q = (char*)malloc(6); // u don't need this 'coz u have pointed q to a different address in the next line. The memory u just allocated becomes completely useless. q = "abcde"; while(*p=*q) { p++; q++; } char* r; // r = p; //move these lines before the while loop because at this point, pointer r points to a memory region that points to the end of "abcde".
Read Full Discussion Thread for this article