10.2作业

//strcpy
#include 
int main(int argc, const char *argv[])
{
	char buf1[]="hello";
	char buf2[]="world";
	printf("%s\t",buf1);
	printf("%s\n",buf2);
	int i=0;
	for( i=0;buf2[i]!='\0';i++)
	{
		buf1[i]=buf2[i];
	}
		buf1[i]='\0';
	puts(buf1);
	puts(buf2);
	return 0;
}
//strlen
#include 
int main(int argc, const char *argv[])
{
	char a[]="hello world";
	int count=0;
	for(int i=0;a[i]!='\0';i++)
	{
		count++;
	}
	printf("%d\n",count);
	
	return 0;
}
//strcmp
#include 
int main(int argc, const char *argv[])
{
	char a[]="hello";
	char b[]="world";
	int i=0;
	while(a[i]==b[i])
	{
		if(a[i]=='\0')
		{
			break;
		}
		i++;
	}
	if(a[i]>b[i])
		printf("a>b\n");
	else if(a[i]
//strcat
#include 
int main(int argc, const char *argv[])
{
	char a[100]="hello";
	char b[100]="world";
	int i=0;
	while(a[i]!='\0'){
		i++;
	}
	int j;
	for(j=0;b[j]!='\0';j++)
	{
		a[i]=b[j];
		i++;
	}
	a[i]='\0';
	puts(a);
	return 0;
}

你可能感兴趣的:(java,算法,前端)