α׷

 3204, 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 : 3497     Date : 2015/07/12 09:36



    
Ͽ丮 void* ϸ ̶ ׷ ƴұ?
(char*) ϴ° 1byte ̵Ͽ 縦 ϱ ׷° ϴ.
2016/01/15  
menial return ptr;
̸ ׸Ͽ, Լ ϱ ε
2018/11/21  
3144   JSP /ٿε ֽϴ.     hsg0154
07/30 6760
  c ޸ [2]     jeongmin9946
07/12 3496
3142   Ϳ ԰..[1]     hogil123
06/28 3538
3141   ̽ Դϴ٤̤     chdl1227
06/14 3017
3140   ۼ cε..[5]     narasa430
06/12 3328
3139 бԴϴ  c ּФ    
05/30 2
3138   [1]     gg5085
05/19 4210
3137   c programming Դϴ.[1]     alexparkjw
05/17 3573
3136   ȳϼ ó ޴µ ڵ ϳ ɱ??     shh9547
05/14 4904
3135   C int Դϴ.[9]     suho0722
05/13 3235
3134   c ͿñѰ ϴ. [1]     rnjsqhs1628
05/08 3352
3133   Ŀθ忡 process Ȯϴ ֳ?     juhyun16
05/03 3673
3132   帳ϴ!     edge12
04/29 3681
3131     [re] 帳ϴ!     cosine
06/28 3195
3130   ms os °ǰ.    
04/18 3162
3129   ǽù Green guard α׷ ˷ ּ [1]     wqw3
04/16 4424
3128   ̰ ϰ Ź帳ϴ.[1]     ys9658
04/06 3372
3127   ڸ ޾ õ,,, ڸ иϿ ϴ α׷ ۼϴ¹[1]     ys9658
04/04 57726
3126   б Ʈ Դϴ.     rlagusgh125
03/29 2927
3125   ȣ ҽڵ м.....     h@cking2013
03/24 3413
[1][2][3] 4 [5][6][7][8][9][10]..[161]

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