Attic/programs/C1.c
changeset 198 2ce98ee39990
parent 112 0711775cb6b0
equal deleted inserted replaced
197:9c968d0de9a0 198:2ce98ee39990
       
     1 #include <string.h>
       
     2 #include <stdio.h>
       
     3 #include <stdlib.h>
       
     4 
       
     5 
       
     6 void foo (char *bar)
       
     7 {
       
     8   float my_float = 10.5;    // in hex: \x41\x28\x00\x00
       
     9   char  buffer[28];        
       
    10 
       
    11   printf("my float value = %f\n", my_float);
       
    12   strcpy(buffer, bar);   
       
    13   printf("my float value = %f\n", my_float);
       
    14 }
       
    15  
       
    16 int main (int argc, char **argv)
       
    17 {
       
    18   // only float overwritten
       
    19   foo("my string is too long !!!!! \x10\x10\xc0\x42"); 
       
    20   // also calls can_never_run
       
    21   foo("my string is too long !!!!! \x10\x10\xc0\x42\x90\x90\x90\x90\x55\x84\x04\x08"); 
       
    22   return 0;
       
    23 }
       
    24 
       
    25 // its address in my setup is \x08048455
       
    26 void can_never_run()
       
    27 { 
       
    28   printf("This can never be executed!\n");
       
    29   exit(0);
       
    30 }
       
    31 
       
    32