Пример #1
0
int		ft_lowups(char *s1, char *s2)
{
	int		i;

	i = 0;
	while (s1[i] || s2[i])
	{
		if (s1[i] != s2[i])
		{
			if (!ft_isalpha(s1[i]) || !ft_isalpha(s2[i]))
				return (ft_strcmp(s1, s2));
			else if (ft_isalpha(s1[i]) && ft_isalpha(s2[i]))
			{
				if (ft_islower(s1[i]) && ft_islower(s2[i]))
					return (ft_strcmp(s1, s2));
				else if (ft_isupper(s1[i]) && ft_isupper(s2[i]))
					return (ft_strcmp(s1, s2));
				else
					return (ft_diff_cases(s1, s2, i));
			}
		}
		i++;
	}
	return (0);
}
Пример #2
0
void check_isLower()
{
	int i = 0;
	printf( "--------\nTest ft_islower:\n" );
	for ( i = MIN; i < MAX; i++ )
	{
		if ( ft_islower( i ) != islower( i ) )
		{
			printf("[%d] -> result: %c, expected result: %c\n", i, ft_islower( i ), islower( i ) );
			exit( 0 );
		}
	}
	printf("\033[32mOk\n\033[0m");
}
Пример #3
0
int		ft_isalpha(int c)
{
	if (ft_isupper(c) || ft_islower(c))
		return (1);
	else
		return (0);
}
Пример #4
0
int		ft_isalpha(int c)
{
	int		n;

	n = ft_islower(c) + ft_isupper(c);
	return (n);
}
Пример #5
0
int		ft_nexts(char *s1, char *s2, int i)
{
	int		tp;

	tp = i;
	while (s1[i] && s2[i])
	{
		if (s1[i] != s2[i])
		{
			if (s1[i] - s2[i] != 32 && s1[i] - s2[i] != -32)
				return (ft_strcmp(s1, s2));
		}
		i++;
	}
	if (!s1[i] && !s2[i])
	{
		while (s1[tp] == s2[tp] && (s1[tp] || s2[tp]))
			tp++;
		if (ft_islower(s1[tp]))
			return (0);
		else
			return (1);
	}
	else if (!s1[i])
		return (1);
	return (0);
}
Пример #6
0
void	ft_c_c_p_else(char **str, int count[3])
{
	if (ft_strlen(str[count[0]]) == 2 &&
			ft_islower(str[count[0]][1]) &&
			str[count[0]][0] == ' ')
		str[count[0]][0] = '\0';
	else if (str[count[0]][0] == ' ' &&
			ft_strlen(str[count[0]]) == 2)
		str[count[0]] = ft_strsub(str[count[0]], 1, 2);
}
Пример #7
0
int		ft_diff_cases(char *s1, char *s2, int i)
{
	if (ft_strcmp(s1, s2) == 32 || ft_strcmp(s1, s2) == -32)
		return (ft_nexts(s1, s2, i));
	else
	{
		if (ft_islower(s1[i]))
		{
			if (s1[i] - 32 > s2[i])
				return (1);
		}
		if (ft_islower(s2[i]))
		{
			if (s2[i] - 32 < s1[i])
				return (1);
		}
	}
	return (0);
}
Пример #8
0
int		main(void)
{
	char c1;
	char c2;
	char c3;
	char c4;
	char c5;

	c1 = 'a';
	c2 = 'A';
	c3 = '#';
	c4 = '8';
	c5 = 'x';
	printf(">>> ft_islower tests: <<<\n");
	printf("%c - %d \n", c1, ft_islower(c1));
	printf("%c - %d \n", c2, ft_islower(c2));
	printf("%c - %d \n", c3, ft_islower(c3));
	printf("%c - %d \n", c4, ft_islower(c4));
	printf("%c - %d \n", c5, ft_islower(c5));
	return (0);
}
Пример #9
0
char	*ft_strupcase(char *str)
{
	int		i;

	i = 0;
	while (str[i])
	{
		if (ft_islower(str[i]))
			str[i] -= 32;
		i++;
	}
	return (str);
}
Пример #10
0
int			ft_str_is_lowercase(char *str)
{
	int		i;

	i = 0;
	while (str && str[i])
	{
		if (!ft_islower(str[i]))
			return (0);
		i++;
	}
	return (1);
}
Пример #11
0
void	test_islower(void)
{
	int		i, test[1024], ctrl[1024];

	print_test_name("------------ISLOWER------------");
	i = 0;
	while (i < 1024)
	{
		ctrl[i] = islower(i);
		test[i] = ft_islower(i);
		++i;
	}
	test_hard();
	print_test_results_summary(test, ctrl, 1024);
	printf("\n");
}
Пример #12
0
char	*ft_rotn(char *str, int n)
{
	int	i;

	i = 0;
	while (str[i])
	{
		if (ft_islower(str[i]))
			str[i] = (str[i] - 'a' + n) % 26 + 'a';
		else if (ft_isupper(str[i]))
			str[i] = (str[i] - 'A' + n) % 26 + 'A';
		else
			str[i] = str[i];
		++i;
	}
	return (str);
}
Пример #13
0
char	*ft_strupper(char const *str)
{
	char	*out_str;
	int		cnt;
	
	out_str = NULL;
	cnt = 0;
	out_str = (char *)malloc(sizeof(char) * (ft_strlen(str) + 1));
	while (str[cnt] != '\0')
	{
		if (ft_islower(str[cnt]))
			out_str[cnt] = ft_toupper(str[cnt]);
		else
			out_str[cnt] = str[cnt];
		cnt++;
	}
	out_str[cnt] = '\0';
	return (out_str);
}
Пример #14
0
int				main(int argc, char **argv)
{
	int			i;
	int			j;
	int			ret;

	if (argc == 3)
	{
		i = atoi(argv[1]);
		j = -9;
		while (j < 255)
		{
			ret = ft_islower(j);
			if (j % 10 == 0)
				printf("%d ", ret);
			else
				printf("%d", ret);
			j++;
		}
	}
	return (0);
}
Пример #15
0
int		ft_toupper(int c)
{
	if (ft_islower(c) == 1)
		c = c - 32;
	return (c);
}
Пример #16
0
int	ft_isalpha(int c)
{
	if (ft_isupper(c) == 1 || ft_islower(c) == 1)
		return (1);
	return (0);
}
Пример #17
0
int		ft_toupper(int c)
{
	return (ft_islower(c) ? c - 0x20 : c);
}
Пример #18
0
int	ft_toupper(int c)
{
	if (ft_islower(c))
		c -= 32;
	return (c);
}
Пример #19
0
int	ft_toupper(int c)
{
	if (ft_islower(c))
		c -= 'a' - 'A';
	return (c);
}
Пример #20
0
int		ft_isalpha(int c)
{
	return (ft_islower(c) || ft_isupper(c));
}
Пример #21
0
int		ft_tolower(int c)
{
	if (ft_isalpha(c) && !ft_islower(c))
		return (c + 32);
	return (c);
}
Пример #22
0
int		ft_toupper(int c)
{
	return (ft_islower(c) ? c + ('A' - 'a') : c);
}
Пример #23
0
int	ft_toupper(int c)
{
	if (ft_islower(c))
		return (c - 32);
	return (c);
}
Пример #24
0
int		ft_isalpha(int c)
{
	return (ft_isupper(c) == 1 || ft_islower(c) == 1);
}