Commit 6a39fd0b by triazo

write simple memcpy function

parent 55d156d8
Showing with 15 additions and 2 deletions
#include "string.h"
#include <stdbool.h>
void *memset(void *s, int c, size_t n){
void *memset(void *s, int c, size_t n)
{
unsigned char* p=s;
while(n--)
*p++=(unsigned char) c;
return s;
}
void memcpy(void* dest, void* src, size_t n)
{
size_t i;
char* d = (char*) dest;
char* s = (char*) src;
for (i = 0; i < n; ++i)
{
d[i] = s[i];
}
}
void reverse ( char s[] )
{
int c, i, j;
......
......@@ -2,7 +2,8 @@
#define _STRING_ING
#include<stddef.h>
void* memset(void *s, int c, size_t n);
void* memset(void* s, int c, size_t n);
void memcpy(void* dest, void* src, size_t n);
void itoa(int n, char s[]);
size_t strlen(const char* str);
int strcmp(const char* s1, const char* s2);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment