Answer to Question #259283 in C for tom

Question #259283

1. In the following program, what would be the final output? Explain in

detail.

void copyarr( char ∗p1 , char p2 [ ] ) {

memcpy ( p2 , p1 , size of ( p1 ) ) ;

memcpy ( p2 , ‘ ‘ABCD’ ’ , 4 ) ;

}

int main ( ) {

char arr1 [ 100 ] ;

char arr2 [ 100 ] ;

printf( ‘ ‘ Enter a string : ’ ’ ) ;

scanf ( ‘ ‘%[ ˆ\n ] s ’ ’ , arr1 ) ;

copyarr ( arr1 , arr2 ) ;

printf ( ‘ ‘ \ n %s ’ ’ , arr2 ) ;

return 0 ;

}


1
Expert's answer
2021-11-01T08:28:10-0400
void copyarr( char ∗p1 , char p2 [ ] ) {
memcpy ( p2 , p1 , size of ( p1 ) ) ;
memcpy ( p2 , ‘ ‘ABCD’ ’ , 4 ) ;
}
int main ( ) {
char arr1 [ 100 ] ;
char arr2 [ 100 ] ;
printf( ‘ ‘ Enter a string : ’ ’ ) ;
scanf ( ‘ ‘%[ ˆ\n ] s ’ ’ , arr1 ) ;
copyarr ( arr1 , arr2 ) ;
printf ( ‘ ‘ \ n %s ’ ’ , arr2 ) ;
return 0 ;
}

The program does not compile.

It contains errors



Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS