I have following two questions
- Given the statement like char * str = "999999999999"; how does compiler determine how much space to allocate on stack? 
- How can i iterate over the memory pointed by str and determine the value of various bits inside it? 
I have following two questions
Given the statement like char * str = "999999999999"; how does compiler determine how much space to allocate on stack?
How can i iterate over the memory pointed by str and determine the value of various bits inside it?
 
    
    "999999999999" is not on the stack.  The pointer may be on the stack, the compiler knows how big the pointer should be.  The  "999999999999" really has a null termination that lets you know when it is at the end.
To iterate over each bit, maybe something like:
for(i=0; str[i]; i++)  // str[i] will evaluate to false(0) when that character is the null
    for(j=7; j>=0; j--)
        printf("%d", (str[i] >> j) & 0x01)
but I prefer looking at bits in hex representation instead of binary so I would just
for(i=0; str[i]; i++)
    print("%X ", str[i])
 
    
    1) In C, strings are terminated by byte which is set to zero. So, in your example, 13 bytes will be allocated for this string - 12 bytes for 12 ascii characters and one byte for '\0' character (NULL terminator).
2) You could just iterate over it and include some bitwise arithmetics:
for(i = 0; i < strlen(str); i++)
{
    for(j = 7; j >= 0; j--)
     printf("%d", (str[i] & (1 << j)) == 0 ? 0 : 1);
    printf(" ");
}
 
    
    Is a string litteral and the compiler can see the literal and calculate the needed space + the null terminator
str is a pointer that points the first character in the array of characters you enumerate over it just as you would any array. The std library offers a slew of functions to help with character arrays.
