#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
char compliance[256] = {'\0'};
if(compliance == NULL)
{
printf("compliance is null \n");
return 0;
}
printf("length of compliance %zd \n",strlen(compliance));
return 0;
}
Output:
length of compliance 0
int main(int argc, char *argv[])
{
char compliance[256] = {'\0'};
memset(compliance,0,256);
if(compliance == NULL)
{
printf("compliance is null \n");
return 0;
}
printf("length of compliance %zd \n",strlen(compliance));
return 0;
}
Output length of compliance 0
As many of you have pointed out I wanted to use memset (instead of memcpy).But still don't get why in the second program compliance is not NULL? or in other words How do I make it NULL?
memset, notmemcpy, just as i'm sure It is entirely unneeded given your initializer presence.