HI friends, <br> Suppose for the the following (using the "gcc" compiler) - <br>Please note- Underlining used only to draw your kind attention to my precise question which follows shortly.<br> <br> 1. int main()<br>
{<br> int c[5]={1,2,3,4,5};<br> <u>int *p=c;</u> //For this code gcc compiles normally without any error or problem<br> <br> //some lines of code <br>
return 0;<br> }<br><br>2. int main()<br> {<br><br> int c[5]={1,2,3,4,5};<br><br>
<u>int *p;</u> <br><br> <u>*p=c;</u> //GCC gives a typecast error (ofcourse). Even if I do <u> </u><b><u>*p=(int) c</u>,</b> gcc gives me a Segmentation fault later but no typecast error<br>
<br>
//some lines of code <br>
return 0;<br>
}<br> <br> <br> I am slighttly confused in the explantion of this. I mean how does the compiler interpret these two statements differently although apparentely (just my mere look, they seem to do the same thing).<br>
<br> I would appreciate if someone could explain the differece between compiler's interpretation for the above underlined statements. Thanks in advance.<br clear="all"><br>-- <br>Hermes<br>Think Free, Think Open Source<br>