Author Topic: Turbo C - Null Pointer Assignment Reason  (Read 1553 times)


  • Administrator
  • Sr. Member
  • *****
  • Posts: 283
Turbo C - Null Pointer Assignment Reason
« on: January 19, 2012, 01:23:03 am »
There are many scenarios where you can see problems. But the key thing is, you did not allocate the memory correctly. The following code would produce Null pointer assignment error message after you run the program. Note: It will compile correctly.

The solution is you need to allocate memory the src pointer in main function char * src = malloc(100);

//Source Code Listing

    void CopyMessage(char *p)
        strcpy(p, "welcome");
    void main()
       char *src;


Disclaimer: This web site is for educational and informational purposes only. Click here to read the Disclaimer.
Content copyright 2010-2014. Kathiresan. All rights reserved.
This page is using SMF version 2.0.1