How is stack map
Stack map for above code is as the below from the high address to the low address:
#define MAX_STR1_LEN 15
#define MAX_STR2_LEN 16
printf("3. str1:%s str2:%s\n", str1,str2);
High:a b c d e f g h j k l m n o c i
str2: 0 1 2 3 4 5 6 7 8 9 a b c d e f
str1: 0 1 2 3 4 5 6 7 8 9 a b c d e x
low: x x x x x x x..........
my doubt is "How high address will get a b c d e f g h j k l m n.........weather these values are declared values or what"
I have absolutely no idea what you're asking.
Your code has issues. You've got two for() loops that doesn't do anything at all, it's int main(), not void main(). Both of your strings are too small to hold the string literals you initialize them with, and you promptly overstep the end of the arrays immediately afterwards. I believe your strcpy() is also doomed. If your program compiles, I rather doubt it'll make it through execution. (No pun intended.)
Edit: Alright, I can't help myself... "My program dies when I execute it" would be the perfect thread opener.
Stack implementation isn't a question for C, but rather a question for the architecture of the machine you're programming on.
We did this already
If you really want to map the addresses of all the local variables, do something like
printf( "a is at %p\n", (void*)&a );
And stop trying to analyse undefined behaviour because it isn't going to make you a better programmer.
1. Don't friggin duplicate post!
Originally Posted by Shidlingayya
2. Don't ever use the word 'doubt' if English is not your first language. Use the word 'question' instead. I'm not explaining this again today. It is just easier for all if you never touch the word 'doubt'. Forget it ever existed.
3. Your question lacks a question mark.
4. You means 'whether', not 'weather'. I don't care whether it's snowing or sweltering where you are.
5. The program is full of bugs and undefined behaviour. There is no right answer when UB is involved.
6. "void main" is not valid C code!