Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

mkristain

macrumors regular
Original poster
Aug 18, 2011
115
0
hi is there any option to find unsigned char buffer[50] having all null values or not.

thanks.
 
Code:
unsigned char allNull[50] = {'\0'};
if(memcmp(allNull,buffer,50) == 0) {
  printf("buffer is all null");
}

-Lee
 
Here's a simple function.

Code:
bool allNull(char * string, int length) {
	for (int i = 0; i < length; ++i) {
		if (string[i] != NULL) return false;
	}
	
	return true;
}
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.