Re : [algogeeks] Xplain the C code

2011-07-27 Thread Charlotte Swazki
llet 2011 16h08 Objet : [algogeeks] Xplain the C code #include #include int main() {         char a[3]="mnnitald";         int x=strlen(a);         printf("%d",x); } Plz xplain the output of this program. x comes out to be 7. if  u take a[2],den it comes to be 6 nd so on.and

Re: [algogeeks] Xplain the C code

2011-07-27 Thread rajeev bharshetty
That is because you have exceeded the character array size so i think it is providing unwanted results. To correct the program increase the size of the array a a[9] . On Wed, Jul 27, 2011 at 9:38 PM, Shantanu Sachdev wrote: > > #include > #include > int main() > { > char a[3]="mnnitald";

[algogeeks] Xplain the C code

2011-07-27 Thread Shantanu Sachdev
#include #include int main() { char a[3]="mnnitald"; int x=strlen(a); printf("%d",x); } Plz xplain the output of this program. x comes out to be 7. if u take a[2],den it comes to be 6 nd so on.and if a[7] is taken, size comes out to be 10. Compiler - GCC. -- SHANTANU SAC