progs/test.c
author Christian Urban <christian dot urban at kcl dot ac dot uk>
Thu, 26 Nov 2015 11:59:38 +0000
changeset 436 8bf6704fc991
parent 211 e6e160c7ea33
permissions -rw-r--r--
update

#include <string.h>
#include <stdio.h>
//#include <stdlib.h>

void foo (char *bar)
{
  unsigned long my_long = 101010101;    // in hex: \xB5\x4A\x05\x06
  char  buffer[28];        

  printf("my_long value = %lu\n", my_long);

  strcpy(buffer, bar);  
 
  printf("my_long value = %lu\n", my_long);
}
 
int main (int argc, char **argv)
{
  foo("my string is too long !!!!!");                  // all is normal
  foo("my string is too long !!!!! \x15\xcd\x5b\x07"); // overwrites my_long
  return 0;
}