How to write a C Program sizeof & memcpy in C Programming Language ?
Solution For C Program :
/*C Program sizeof & memcpy.*/
#include <stdio.h>
#include <string.h>
int main(){
int a[100];
int b[100] = {1, 2, 3};
// copy array:
// (x) a = b; address
// (1) memcpy(a, b, sizeof(int) * 3);
/*
(2)
int i;
for( i = 0 ; i < 3 ; i++ ){
a[i] = b[i];
}
*/
printf("size of int: %d\n", sizeof(int));
printf("size of double: %d\n", sizeof(double));
printf("size of a: %d\n", sizeof(a));
printf("size of b: %d\n", sizeof(b));
// printf("b[0]: %d\n", b[0]);
printf("b: %d\n", b);
printf("b+1: %d\n", b+1);
printf("*b: %lf\n", *b); // *b => *(b+0) = b[0]
printf("*(b+1): %lf\n", *(b+1)); // *(b+1) = b[1]
return 0;
}