author | Christian Urban <christian dot urban at kcl dot ac dot uk> |
Tue, 12 Nov 2013 10:51:02 +0000 | |
changeset 130 | 4e8482e50590 |
parent 112 | 0711775cb6b0 |
permissions | -rw-r--r-- |
24 | 1 |
#include <string.h> |
2 |
#include <stdio.h> |
|
3 |
#include <stdlib.h> |
|
4 |
||
5 |
void foo (char *bar) |
|
6 |
{ |
|
7 |
float my_float = 10.5; // in hex: \x41\x28\x00\x00 |
|
8 |
char buffer[28]; |
|
9 |
||
10 |
printf("my float value = %f\n", my_float); |
|
11 |
||
12 |
strcpy(buffer, bar); |
|
13 |
||
14 |
printf("my float value = %f\n", my_float); |
|
15 |
} |
|
16 |
||
17 |
int main (int argc, char **argv) |
|
18 |
{ |
|
111
677179c76e35
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
24
diff
changeset
|
19 |
foo("my string is too long !!!!! "); // all is normal |
112
0711775cb6b0
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
111
diff
changeset
|
20 |
//foo("my string is too long !!!!! \x10\x10\xc0\x42"); // overwrites my_float |
24 | 21 |
return 0; |
22 |
} |
|
23 |