Esempio n. 1
0
//
// FUNCTION delete_zero_symbols (char* str)
//
// PURPOSE: each second symbol of source string is '\0' symbol. We delete it
//
void delete_zero_symbols(char* str)
{
	int len = nlen(str);

	for (int i = 1; i < len + 1; i++)
		str[i] = str[i * 2];
}
Esempio n. 2
0
layer
setNumber(layer l,int x, int y, unsigned int i)
{
    int itr_x, len;
    if (l->y <= y || l->x <= x) return NULL;
    len = MIN(l->x - 1, nlen(i) - 1);
    for (itr_x = x; itr_x < l->x && i > 0; itr_x++, i /= 10){
        l->matrix[y][itr_x - len] = i % 10 + '0';
    }
    return l;
}
Esempio n. 3
0
/**
 * @brief
 *
 * @param
 *
 * @return
 */
layer
vmenu(layer l, const char * txt, const char ** opts)
{
    int itr, x;
    /* get the text height + 2 lines*/
    int normalTextSize = strlen(txt) / l->x + 3;
    zeroOut(l->matrix, l->x, l->y);
    /* Get the number of options to show. */
    for (itr = 0; opts[itr] != NULL; itr++);
    if (LYR_NO_AUTO_RESIZE != (l->mode & LYR_NO_AUTO_RESIZE))
        l = resizeLayer(l, l->x, itr + normalTextSize + 1);
    idxtext(l, 1, txt);
    for (itr = 0; opts[itr] != NULL && itr + normalTextSize < l->y - 1; itr++){
        x = nlen(itr + 1) + 3;
        /* snprintf is not ANSI C (std89), it's ISO C (std99). Any
         * half-decent implementation has it. Anyway... */
        setNumber(l, 1, normalTextSize + itr, (unsigned int)(itr + 1));
        setText(l, x - 2, normalTextSize + itr, ")");
        setText(l, x, normalTextSize + itr, opts[itr]);
    }
    return l;
}
Esempio n. 4
0
File: ft_itoa.c Progetto: SN9NV/RT
char		*ft_itoa(int n)
{
	unsigned int		len;
	char				*new_str;

	len = nlen(n);
	new_str = (char *)malloc(len + 1);
	if (new_str == NULL)
		return (NULL);
	if (n == 0)
		new_str[0] = '0';
	if (n < 0)
	{
		n = -n;
		new_str[0] = '-';
	}
	new_str[len--] = '\0';
	while (n)
	{
		new_str[len--] = (n % 10) + '0';
		n /= 10;
	}
	return (new_str);
}