Toggle menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

새싹교실/2020/새싹부터나무까지/박소은/실습/20.10.09: Difference between revisions

From ZeroWiki
No edit summary
No edit summary
Line 1: Line 1:
== 1 ==
== 1 ==
//strcpy
   
   
char* strcpy(char s1[], char s2[])
{
int i = 0;
while (*(s1 + i))
{
s1[i] = s2[i];
i++;
}
return s1;
}
== 2 ==
== 2 ==
  //strlen
  //strlen

Revision as of 16:21, 4 November 2020

1

//strcpy

char* strcpy(char s1[], char s2[])
{
	int i = 0;
	while (*(s1 + i))
	{
		s1[i] = s2[i];
		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); i < strlen(s1) + strlen(s2); i++)
	{
		s1[i] = s2[i];
	}
}

4