Difference between r1.5 and the current
@@ -1,19 +1,17 @@
== 1 ==
{{{
#include <stdio.h>
int main(void)
int i, * p;
for (i = 0; i < 10; i++)
printf("%d\n", *(number + i));
}}}
== 2 ==
{{{
//*를 사용하되, 포인터(p)를 사용하지 마시오.
//strcpy
char* strcpy(char s1[], char s2[])
{ int number[10] = { 1,3,5,7,9,11,13,15,17,19 };
int i = 0;
while (*(s2 + i))
{ s1[i] = s2[i];
i++;
} return 0;
s1[i] = s2[i];
return s1;
}}}}
== 2 ==
@@ -35,33 +33,30 @@
{{{
//strcat
}
}}}
== 4 ==
{{{
#include <stdio.h>
int i, j, * p;
for (i = 0; i < 3; i++)
for (j = 0; j < 4; j++)
{
printf("%d\n", *(*(number + i) + j));
}
return 0;
}
}}}
//strcat
void strcat(char s1[], const char s2[])
void strcat(char s1[], char s2[])
{ for (int i = strlen(s1); i < strlen(s1) + strlen(s2); i++)
for (int i = strlen(s1), j = 0; i <= strlen(s1) + strlen(s2); i++, j++)
{ s1[i] = s2[i];
s1[i] = s2[j];
}}
}}}
== 4 ==
{{{
//포인터를 사용하지 마시오.
//strcmp
int main(void)
int strcmp(char s1[], char s2[])
{ int number[3][4] = { {1,3,5,7},{9,11,13,15},{17,19,21,23} };
int i = 0;
while (s1[i] != '\0' || s2[i] != '\0')
{ if (s1[i] > s2[i])
return 1;
else if (s1[i] < s2[i])
return -1;
i++;
}}
}}}
1 ¶
//strcpy char* strcpy(char s1[], char s2[]) { int i = 0; while (*(s2 + i)) { s1[i] = s2[i]; i++; } s1[i] = s2[i]; return s1; }
2 ¶
//strlen int strlen(char* p) { int length = 0, i = 0; while (*(p + i)) { length++; i++; } return length; }
3 ¶
//strcat void strcat(char s1[], char s2[]) { for (int i = strlen(s1), j = 0; i <= strlen(s1) + strlen(s2); i++, j++) { s1[i] = s2[j]; } }
4 ¶
//strcmp int strcmp(char s1[], char s2[]) { int i = 0; while (s1[i] != '\0' || s2[i] != '\0') { if (s1[i] > s2[i]) return 1; else if (s1[i] < s2[i]) return -1; i++; } return 0; }