these function are called from main - I am just trying to copy string st1 to string st2 from character position 0 to character position unsigned int to (3 as in this example) but I can't figure out where to stop the increment in order to stop at the unsigned int to.....

any help would be appreciated....

Code:
void g_strtcpy()
{
	char ST1[30]="abcdefg";
	char ST2[30]="";
	


	/*Example 1*/
	printf("\n\n strtcpy() function demonstration #1:");
	printf("\n Input string is =%s= ",ST1);
	printf("\n Output string is =%s= ",ST2);
	printf("\n Copy to character position 3");

	strtcpy(ST2,ST1,3);

	printf("\n\n Input string is =%s= ",ST1);
	printf("\n Output string is =%s= ",ST2);
	printf("\n\n");

}
void strtcpy(char *outstring, char *instring, unsigned int to)
{
	int i=0;
	int j=0;
	int k=to-1;
	
	if (k<=-1)
		{
			outstring[0]=EOS;
			
		}

	else if (k>=0)
		{	
		
			while (instring[j]!=EOS)
			{	
				outstring[i]=instring[j];				++i;
				++j;
				

			}
			
			outstring[i]=EOS;
		}
	
	
}

&#91;code]&#91;/code]tagged by Salem