jweinst1
7/27/2017 - 8:30 PM

checking for null char in c

checking for null char in c

#include "stdio.h"
#include "string.h"
#include "stdlib.h"

//string examples for c

int main(void) {
  const char* a = "foobeans";
  long len = strlen(a);
  char* b = malloc(len);
  strcpy(b, a);
  puts(b);
  printf("last is null %d\n", b[len] == '\0');
  printf("the size is %d\n", len);
  return 0;
}