🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: fr.comp.lang.c
Article #15303

Re: Param�tre constant

#15303
From: Alain CROS
Date: Sat, 01 Oct 2005 17:34
48 lines
2146 bytes
Bonjour.

| > mais interdire la modification de
| > la chaine en la d�clarant avec const. Je ne trouve pas o� mettre le const.
| >
| > const char *c et char const *c me donne :
| >     [Warning] assignment discards qualifiers from pointer target type
|
| C'est portant la bonne solution. Poste le code de la ligne qui g�n�re
| ce warning.
|

Le code avec en commentaire la ligne du Warning.

*pt pointe sur un tableau de splitab r�serv� par un malloc.
pos est le nombre de char de la sous-chaine qui commence � *ptch.

typedef struct
    {
        int pos;
        char *ptch;
    }splitab;

int split(splitab *pt, const char *c, const int taille, const char sep)
{
    int i, j = 0, k = 0;
    if(taille)
    for(i = 0; i <= taille; i++, *c++, k++)
    {
        if(!k)
        pt->ptch = c;                            /* ligne g�n�rant le Warning */
        if(*c == sep || i == taille)
        {
            pt->pos = k;
            if(i != taille)
            {
                k = -1;
                *pt++;
            }
            j++;
        }
    }
    return j;
}

Merci.

Alain CROS
Technical Details
Message-ID: <433ec7e3$0$14035$626a14ce@news.free.fr>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.nwr.nac.net!colt.net!newsfeed.icl.net!proxad.net!infeed-2.proxad.net!news18-e.free.fr!not-for-mail
References: <433eafec$0$18071$626a14ce@news.free.fr> <mn.0c457d5a4b1d92ea.15512@YOURBRAnoos.fr>

Show Full Headers
Complete Article Headers
X-Google-Thread: f9822,8be8da6b5abaf548
X-Google-Attributes: gidf9822,public
X-Google-Language: FRENCH,ASCII
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.nwr.nac.net!colt.net!newsfeed.icl.net!proxad.net!infeed-2.proxad.net!news18-e.free.fr!not-for-mail
From: "Alain CROS" <Personne@ICI>
Newsgroups: fr.comp.lang.c
References: <433eafec$0$18071$626a14ce@news.free.fr> <mn.0c457d5a4b1d92ea.15512@YOURBRAnoos.fr>
Subject: Re: Param�tre constant
Date: Sat, 1 Oct 2005 19:34:23 +0200
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
Lines: 51
Message-ID: <433ec7e3$0$14035$626a14ce@news.free.fr>
Organization: Guest of ProXad - France
NNTP-Posting-Date: 01 Oct 2005 19:31:15 MEST
NNTP-Posting-Host: 62.147.9.244
X-Trace: 1128187875 news18-e.free.fr 14035 62.147.9.244:1057
X-Complaints-To: abuse@proxad.net