Hi
I am writing programm to print pattern like below
1
22
333
4444
55555
666666
up to n given as a parametr.
my code below
Code:
char* pattern(const int n)
{
	char *result = (char*)malloc(sizeof(char)*n*n*n*n);
	char *temp = (char*)malloc(sizeof(char) * 4);
	memset(result, '\0', (n*n*n*n));
	if (n<1)
		return "";
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= i; j++)
		{
			sprintf(temp, "%d", i);
			strcat(result, temp);
		}
		strcat(result, "\n");
	}
	result[strlen(result) - 1] = '\0';
	return result;
}
I pass all basic test but on random test i got some errors. Can you tell me where is mistake