Dear Allo,
Recently i was attended one interview i got one question like this
Code:
#include<stdio.h>
#define MAX_STR1_LEN 15
#define MAX_STR2_LEN 16
void main()
{
char a,b,c,d,e,f,g,h,j,k,l,m,n,o,count;
char i=4;
char str2[MAX_STR2_LEN]="0123456789abcdef";
chat str1[MAX_STR1_LEN]="0123456789abcde";
str2[MAX_STR2_LEN]=0;
str1[MAX_STR1_LEN]=0;
printf("1.str1:%s str2:%s\n",str1,str2);
strcpy(str1,str2);
printf("2.str1:%s str2:%s\n",str1,str2);
for(count=0;count<i;count++);
str2[MAX_STR2_LEN]='a';
str1[MAX_STR1_LEN]=0;
strcpy(str1,str2);
printf("3. str1:%s str2:%s\n", str1,str2);
for(; count<i;count++);
printf("4. count:%d\n",count);
return;
}
The o/p i got in my compiler
Code:
1. str1:0123456789abcde str2:0123456789abcdef
2. str1:0123456789abcdef str2:
3. str1: str2:
4. count:97
can anybody explain step by step procedure how i got this output... what is the concept beyond this program..........I am advance thankful to you