α׷

 3206, 4/161 ȸ  α  
   jeongmin9946
   c ޸

http://www.hackerschool.org/HS_Boards/zboard.php?id=QNA_programming&no=6542 []


#include<stdio.h>
#include <stdlib.h>
#include <string.h>

struct tagM1
{
        int x;
        int y;
        char buffer[30];
};

void* My_memcpy(void * dst, const void *src, unsigned int count);

void main (void)
{
        struct tagM1 x1,x2;

        x1.x=5;
        x1.y=10;
        strcpy(x1.buffer,"memory copy");
        printf("%d %d %d \n", sizeof(x1.x),sizeof(x1.y),sizeof(x1.buffer));

        My_memcpy(&x2,&x1,sizeof(x1));

        puts(x2.buffer);
        printf("%d %d \n", x2.x, x2.y);
}

void* My_memcpy(void * dst, const void *src, unsigned int count)
{
        void * ptr= dst;

        while(count--)
        {
                *(char*)dst = *(char*)src;
                dst= (char*)dst +1 ;
                src= (char*)src +1 ;
        }

        return ptr;
}

ҽ ޸𸮸 ϴ Լ ε.  
Լ
void* My_memcpy(void * dst, const void *src, unsigned int count)
⼭ void* ϳ?
ü ϴ Լ void* °ǰ?
׸ while ȿ (char*) void* ڷ ޾ƿͼ ڷ ִ Ȱΰ??
x2 ü x,y 簡 ƴµ int
Ѱ °Ű ? 簡 Ȱǰ ?

  Hit : 3469     Date : 2015/07/12 09:36



    
Ͽ丮 void* ϸ ̶ ׷ ƴұ?
(char*) ϴ° 1byte ̵Ͽ 縦 ϱ ׷° ϴ.
2016/01/15  
menial return ptr;
̸ ׸Ͽ, Լ ϱ ε
2018/11/21  
3146   c Լ ּ [2]     δٴٴٴ
09/16 4350
3145   α׷ε,ѹ 鷯ּ![1]     cndygks1030
09/12 3282
3144   JSP /ٿε ֽϴ.     hsg0154
07/30 6748
  c ޸ [2]     jeongmin9946
07/12 3468
3142   Ϳ ԰..[1]     hogil123
06/28 3519
3141   ̽ Դϴ٤̤     chdl1227
06/14 3001
3140   ۼ cε..[5]     narasa430
06/12 3311
3139 бԴϴ  c ּФ    
05/30 2
3138   [1]     gg5085
05/19 4192
3137   c programming Դϴ.[1]     alexparkjw
05/17 3560
3136   ȳϼ ó ޴µ ڵ ϳ ɱ??     shh9547
05/14 4881
3135   C int Դϴ.[9]     suho0722
05/13 3214
3134   c ͿñѰ ϴ. [1]     rnjsqhs1628
05/08 3331
3133   Ŀθ忡 process Ȯϴ ֳ?     juhyun16
05/03 3641
3132   帳ϴ!     edge12
04/29 3660
3131     [re] 帳ϴ!     cosine
06/28 3173
3130   ms os °ǰ.    
04/18 3148
3129   ǽù Green guard α׷ ˷ ּ [1]     wqw3
04/16 4405
3128   ̰ ϰ Ź帳ϴ.[1]     ys9658
04/06 3357
3127   ڸ ޾ õ,,, ڸ иϿ ϴ α׷ ۼϴ¹[1]     ys9658
04/04 57644
[1][2][3] 4 [5][6][7][8][9][10]..[161]

Copyright 1999-2024 Zeroboard / skin by Hackerschool.org / Secure Patch by Hackerschool.org