Programación General > C/C++

 Arreglos de punteros.

<< < (2/2)

ivanmvega:
Chamo, intentá esto
declará char *a
pasalo funcion (&a);
y en la funcion recibílo
funcion (char **a)

Eternal Idol:
leusss: para poder escribir en la variable tenes que pasar su direccion, ahora la estas pasando por valor. &a y en la funcion ***.

ivanmvega: de esa manera pasas la direccion de un puntero y no de un doble puntero como el intenta.

ivanmvega:
Si tienes razon no lo estoy haciendo tal como lo puse..mira abajo te pongo como lo estoy haciendo

 char
         *lenstr,
         *resp,
         *item,
         *aux_item;
lxml_get_item_tag ( _data, N2B_REQUEST, "", i ,&resp);
        if ( resp == NULL )
        {
                printf("XML Syntax Errorn");
                ok = FALSE;
        }

int lxml_get_item_tag ( char *xml, char *tag, char *atributos, int posicion, char** res )
{
    char
            *ini,
            *fin,
            tag_entrada     [512],
            tag_salida      [512],
            tag_aux         [512];

    int
            cantidad_renglones=0,
            len=0,
            tipo_xml= -1;

        memset ( tag_entrada, 0, sizeof (tag_entrada) );
        memset ( tag_salida, 0, sizeof (tag_salida) );
        memset ( tag_aux, 0, sizeof (tag_aux) );

        ini = xml;
        fin = xml;

        if ( (atributos) && strcmp(atributos, "NULL") !=0  && strcmp(atributos, "") )
                sprintf ( tag_aux, "%s %s", tag, atributos);
    else
                sprintf ( tag_aux, "%s", tag );

        if (lxml_search_symbol (ini, "&lt;") == TRUE )
                tipo_xml = TAG_POR_ENTIDAD;
        else if (lxml_search_symbol (ini, "<") == TRUE )
        tipo_xml = TAG_POR_CARACTER;

        sprintf ( tag_entrada, "%s",( char* ) lxml_open_tag( tag_aux, tipo_xml ) );

        sprintf ( tag_salida, "%s",( char* ) lxml_close_tag( tag, tipo_xml ) );

    while ( ( ini = strstr ( ini, tag_entrada ) ) != NULL && posicion > cantidad_renglones)
    {
                cantidad_renglones++;
                ini += strlen ( tag_entrada );
    }

        if ( ini == NULL )
        {
                *res = NULL;

                printf ( "Error. ini=NULL. No puedo seguirn" );
                exit ( EXIT_FAILURE );
        }

    fin = (char*) strstr ( ini, tag_salida );
    len = (fin - ini + strlen (tag_salida));

        // Reservo la memoria que necesito
        *res = (char*) malloc ( len );
        strncpy ( *res, ini, len );

        (*res) [ len ] = '';

    return len;
}

Navegación

[0] Índice de Mensajes

[*] Página Anterior

Ir a la versión completa