c++使用指针指向的字符串,如何判断字符串结束?

IplImage* img = cvLoadImage(ImageName, CV_LOAD_IMAGE_GRAYSCALE);
	unsigned char *img_data = (unsigned char *)(img->imageData);
	int widthstep = img->widthStep;
	//将一维指针img_data指向的内存中的值写入成员变量二维指针data所指的内存中
	//write your code here
	height=img->height;
	width=img->width;
	unsigned char *p=img_data;
	data=new unsigned char *[height];
	for(int i=0;i<width;i++)
	{
		data[i]=new unsigned char [width];
	}
	
    int i=0;
	while(p!=NULL)
	{
		for(int j=0;j<widthstep;j++)
		{
			*(*(data+i)+j)=*p;
			p++;
		}
		i++;
	}
WRITTEN BY:    何进鸿

欺骗世界,欺骗最初的你。