programs/C0.c
author Christian Urban <christian dot urban at kcl dot ac dot uk>
Tue, 23 Sep 2014 11:45:21 +0100
changeset 170 1c8ad2848d3b
parent 112 0711775cb6b0
permissions -rw-r--r--
updated

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

void foo (char *bar)
{
  float my_float = 10.5;    // in hex: \x41\x28\x00\x00
  char  buffer[28];        

  printf("my float value = %f\n", my_float);

  strcpy(buffer, bar);  
 
  printf("my float value = %f\n", my_float);
}
 
int main (int argc, char **argv)
{
  foo("my string is too long !!!!! ");                  // all is normal
  //foo("my string is too long !!!!! \x10\x10\xc0\x42");  // overwrites my_float
  return 0;
}