Pointers Sample application:
----------------------------------------
int Function( char* arr)
{
strcpy(arr,"sun");
return 0;
}
void Main()
{
char arr[3];
Function(arr);
printf("\n %s",arr);
}
Expected Output : sun
Actual Result : I got some invalid junk data;
So I modified the main()fn call as follows:
void Main()
{
char arr[3];
Function(&arr[0]);
printf("\n %s",arr);
}
the Output is : sun
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment