Question 1;
#include<stdio.h>
void abc(char a[]){
a++;
printf("%c\n",*a);
a++;
printf("%c\n",*a);
}
int main(){
char a[100];
a[0]='a';a[1]='b';a[2]='c';a[4]='d';
abc(a);
printf("%c",*a);
getchar();
}
Output:bca
Explanation:
The base address is modified only in function and as a result a points
to 'b' then after incrementing to 'c' so bc will be printed.
#include<stdio.h>
void abc(char a[]){
a++;
printf("%c\n",*a);
a++;
printf("%c\n",*a);
}
int main(){
char a[100];
a[0]='a';a[1]='b';a[2]='c';a[4]='d';
abc(a);
printf("%c",*a);
getchar();
}
Output:bca
Explanation:
The base address is modified only in function and as a result a points
to 'b' then after incrementing to 'c' so bc will be printed.
No comments:
Post a Comment