All pastes #1621748 Raw Edit

clueless

public text v1 · immutable
#1621748 ·published 2009-10-15 09:12 UTC
rendered paste body
#include <stdio.h>int strcompare(char array [10], char arraytwo[10]) // function to compare two strings and see if they are equal{	int i;	for(i = 0; array[i] != '\0'; i++)	{		if(array[i] != arraytwo[i])		{			return 0;					}	}	return 1;}int strlen(char array[10]) // Function to return the number of characters in a string{	int i;	int counter = 0;	for(i = 0; array[i] != '\0'; i++)	{		counter++;	}	return counter;}int strcpy(char array[10], char arraytwo[10]) // Function to copy array one to array two{	int i;	for(i = 0; array[i] != '\0'; i++)	{		arraytwo[i] = array[i];	}	//check so that they are indeed equal	if(strcompare(array, arraytwo))		return 1;	else		strcpy(array, arraytwo);}int main(){		char array[10] = "mingel";	char arraytwo[10] = "Snigel";	if(strcompare(array, arraytwo))		printf("Equal!\n moving on...\n");	else	{		printf("Not equal! \n Copy array to arraytwo so that they become equal!\n");		if(strcpy(array,arraytwo))			printf("Equal!\n Moving on...\n");		else		{			printf("Something went wrong, sorry could not copy. But moving on now!\n");		}	}	printf("%d characters\n",strlen(array));}