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