Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * =====================================================================================
- *
- * Filename: cpy.c
- *
- * Description:
- *
- * Version: 1.0
- * Created: 06/10/2011 09:39:13 AM
- * Revision: none
- * Compiler: gcc
- *
- * Author: FamiHug (fh), famihug@gmail.com
- * Company: familug.blogspot.com
- *
- * =====================================================================================
- */
- #include <stdio.h>
- #include <string.h>
- #include <stdlib.h>
- void NhapMaTran(float **matrix)
- {
- int size = 3;
- int i,j;
- *matrix = (float *)malloc(size * (size + 1) * sizeof(float));
- printf("Nhap vao ma tran: \n");
- for(i = 0; i < 3; i++)
- {
- for(j = 0; j < 4; j++)
- {
- scanf("%f",*matrix + i * (size + 1) + j);
- }
- }
- printf("Nhap xong!\n");
- return;
- }
- void InRaMatran(float **matrix)
- {
- int size = 3;
- int i,j;
- printf("Ma Tran: \n");
- for(i = 0; i < size; i++)
- {
- for(j = 0; j < size + 1; j++)
- {
- printf("%3.3f ",*(*matrix + i * (size + 1) + j));
- }
- printf("\n");
- }
- return;
- }
- void copyMatran(float **matrix, float **q)
- {
- memcpy(q,matrix,sizeof(float) * 3 * 4);
- }
- int main()
- {
- float *p, *q;
- q = (float *)malloc(sizeof(float) * 3 * 4);
- NhapMaTran(&p);
- InRaMatran(&p);
- copyMatran(&p,&q);
- InRaMatran(&q);
- //
- // memcpy(cp,c,strlen(c) + 1);
- // int i;
- // for(i = 0; i < 4; i++)
- // {
- // printf("%d ",cp[i]);
- // }
- //
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement