M mkristain macrumors regular Original poster Aug 18, 2011 115 0 Aug 30, 2011 #1 hi is there any option to find unsigned char buffer[50] having all null values or not. thanks.
lee1210 macrumors 68040 Jan 10, 2005 3,182 3 Dallas, TX Aug 30, 2011 #2 Code: unsigned char allNull[50] = {'\0'}; if(memcmp(allNull,buffer,50) == 0) { printf("buffer is all null"); } -Lee
Code: unsigned char allNull[50] = {'\0'}; if(memcmp(allNull,buffer,50) == 0) { printf("buffer is all null"); } -Lee
C camjknight macrumors newbie Nov 7, 2007 1 0 Aug 30, 2011 #3 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; }
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; }