.

OJO este Reto es apra los que quieren aprender sufuriendo ( Asi aprendi VB6 al derecho y viceversa ).

* El Reto Consiste en Rear TODAS las funciones de String.h Sin depender de otras librerias, es decir ANSI C

Estas Son las funciones:

Código: Seleccionar todo


C Strings
This header file defines several functions to manipulate C strings and arrays.

Functions
Copying:
memcpy	Copy block of memory (function)
memmove	Move block of memory (function)
strcpy	Copy string (function)
strncpy	Copy characters from string (function)

Concatenation:
strcat	Concatenate strings (function)
strncat	Append characters from string (function)

Comparison:
memcmp	Compare two blocks of memory (function)
strcmp	Compare two strings (function)
strcoll	Compare two strings using locale (function)
strncmp	Compare characters of two strings (function)
strxfrm	Transform string using locale (function)

Searching:
memchr	Locate character in block of memory (function)
strchr	Locate first occurrence of character in string (function)
strcspn	Get span until character in string (function)
strpbrk	Locate character in string (function)
strrchr	Locate last occurrence of character in string (function)
strspn	Get span of character set in string (function)
strstr	Locate substring (function)
strtok	Split string into tokens (function)

Other:
memset	Fill block of memory (function)
strerror	Get pointer to error message string (function)
strlen	Get string length (function)

Web: http://infrangelux.sytes.net/
ScanX: http://ScanX.sytes.net/
FileX: http://FileX.sytes.net/
Blog: http://BlogX.sytes.net/

Imagen


The Dark Shadow is my passion.
El infierno es mi Hogar, mi novia es Lilith y el metal mi religion
Reglas:

Comentarios limitados y muy Breves, ya que en ocaciones tanto comentario fastidia y hace que el codigo no sea legible Ejemplo ( Imaginen que asi son los comentarios de largos y en cada LINEA xS )

Código: Seleccionar todo


if (a=(int)'b') /* esta linea Compara el valor Asscii de 'b' con la variable a pero antes haciend un casting de tipos */
{
    ...
}

Forma Deseable

Código: Seleccionar todo


if (a=(int)'b') /* ¿a = b? en Ascci? */
{
    ...
}

La cosa es que no hay que tratar de enseñar a otros como si fueran 35tup1d0s.. y si solo se comenta la funcion = de forma breve seria mejor xP es decir que hace, que retorna, parametros etc..

ejemplo de la manera deseable:

Código: Seleccionar todo


Retorna: Longitud de la cadena.
Parametro 1: Puntero a la cadena.
unsigned long int strlen(char* s)
{
     ...
}

Todo esto es para poder Aprender adecuadamente de otros pero sin tener tanto que leer.

Por ejemplo este codigo ( Esta demasiado entendible, y quien no lo entienda debera leer mas sobre la sintasys de C ):

Código: Seleccionar todo


double  atof(char* string)
/*
    Return: Valor de la cadena.
    Parametro 1: puntero a la cadena a convertir
*/
{   //  By BlackZeroX ( http://Infrangelux.sytes.net/ )
    double n, p;
    int i, s;
    
    /* Salta Blancos */
    for ( i=0; string[i]==' ' || string[i]=='\n' || string[i]=='\t'; i++ );
    
    /* Signo? */
    if ( string[i]=='+' || string[i]=='-' )
        s=(string[i++]=='+') ? 1:-1;
    else
        s=1;
    
    /* Valores enteros */
    for ( n=0 ; string[i]>='0' && string[i]<='9'; i++ )
        n = 10*n+string[i]-'0';
    
    /* Punto Decimal? */
    if (string[i]=='.')
        i++;
    
    /* Valores Decimales */
    for ( p=1 ; string[i]>='0' && string[i]<='9'; i++ )
    {
        n = 10*n+string[i]-'0';
        p *= 10; /* Por cuanto Dividiremos? */
    }
    
    /* Al dividir entre p se obtienen los decimales */
    return s * n / p;
}

Todo esto es para que podamos aprender uno del otro pero de forma legible que asi es como realmente se aprende un lenguaje... viendo codigos ajenos.

Dulces Lunas!¡.
.
Web: http://infrangelux.sytes.net/
ScanX: http://ScanX.sytes.net/
FileX: http://FileX.sytes.net/
Blog: http://BlogX.sytes.net/

Imagen


The Dark Shadow is my passion.
El infierno es mi Hogar, mi novia es Lilith y el metal mi religion
Responder

Volver a “C/C++”