コード例 #1
0
ファイル: get_next_line.c プロジェクト: lp177/libft
static int		loop(t_str *str, t_hist *historic,\
char **line, int success)
{
	int				i;

	while (success && str)
	{
		i = -1;
		while (str->str[++i] && str->str[i] != '\n' && str->str[i] != '\r')
			;
		if (str->str[i] == '\n' || str->str[i] == '\r')
		{
			while (str->str[i] == '\n')
				str->str[i++] = '\0';
			historic->garbage = &str->str[i];
			return (achievement(historic, line));
		}
		str->next = new_str();
		str = str->next;
		str->str = (char *)malloc(sizeof(char) * BUFF_SIZE + 1);
		ft_bzero(str->str, BUFF_SIZE + 1);
		success = read(historic->fd, str->str, BUFF_SIZE);
	}
	return (0);
}
コード例 #2
0
int main()
{
	int x = 1,y,count=0;
	printf("给我2个自然数\n决定圣诞树的层数 !\n以及每层高度系数(建议 2 )\n");
	while (x)
	{

		int n1, n2, n3;
		scanf_s("%d%d", &n1, &n3);
		n2 = 2;

		printf("\nDuangDuang~~~\n", n1);
		tree(n1, n2, n3);
		count++;
		achievement(count);
		printf("\n欢迎再来~继续哦\n");


	}
	return main();
}
コード例 #3
0
ファイル: get_next_line.c プロジェクト: lp177/libft
int				get_next_line(int const fd, char **line)
{
	static t_hist	*historic;
	t_str			*str;
	int				success;

	success = 1;
	str = new_str();
	if (historic && historic->fd == fd && historic->garbage)
		str->str = historic->garbage;
	else
	{
		historic = new_historic(fd);
		str->str = (char *)malloc(sizeof(char) * BUFF_SIZE + 1);
		ft_bzero(str->str, BUFF_SIZE + 1);
		success = read(fd, str->str, BUFF_SIZE);
	}
	historic->start = str;
	if (loop(str, historic, line, success))
		return (1);
	achievement(historic, line);
	return (0);
}