🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: be.comp.programming
Article #9420

Re: [C++]: Splitten van een string ... Wat doe ik fout ???

#9420
From: Christof Laeremans
Date: Tue, 30 Apr 2002 08:57
76 lines
3172 bytes
On 4/29/02 8:25 PM, in article khgz8.1798$X47.873206@iguano.antw.online.be,
"Alain Cloet" <nospam@tijd.com> wrote:

> 't was toch niet de bedoeling dat het door ons opgelost werd ?  Enkele tips
> toegevoegd ...(eentje is oplossing van de fout) ;-)
> 
> "Christof Laeremans" <christof_laeremans@hotmail.com> wrote in message
> news:B8F31C5C.2817%christof_laeremans@hotmail.com...
> 
>> #include <iostream>
>> #include <string>
>> 
>> using namespace std;
>> 
>> 
>> int main()
>> {
>>     char string[80] = "VOLVO OPEL VOLKSWAGEN ";
>>     char *split;
>>     int start = 0;
>>     int spatie = 0;
>>     cout<<"Afdrukken van de string: "<<string<<endl;
>>     cout<<"lengte van de string is: "<<strlen(string)<<endl;
>> 
>>     for(int i = 0; i < strlen(string); i++)
>>     {
>>         if(string[i] == ' ')
>>         {
>> 
>>             cout<<"Er komt een spatie voor op positie: "<<i<<endl;
>> 
>>             spatie = i;
>>             split = new char[spatie - 1];
> 
> Te klein de eerste keer (na aanpassing fout ; kan wel werken, maar dan
> eerder "toevallig") ; te groot anders...
> 
>> 
>>             //Splitsen van de string
>>             for(int j = start; j < spatie+1; j++)
> 
> Waarom tot "spatie + 1", spatie is toch al voldoende ...
> Je laatste char moet 0 zijn, dus moet je dit nog 'toevoegen' na de laatste
> positie van de tijdelijke string die in onderstaande for-lus gemaakt
> wordt...
> 
> 
>>             {
>>                 split[j-start] = string[j];
>>             }
>>             start = spatie +1;
>> 
>>             cout<<split<<endl;
>> 
>>             delete[] split;
>>         }
>>     }
>> 
>> 
>> }
> 
> Hopelijk lukt het hiermee... anders geef ik de letterlijke aanpassing wel...
> Groeten,
> 
> Alain
> 
> 

Hallo,

Ik kom er niet uit .... Zou je mij de juiste code kunnen mailen (aub) ?
Om te mailen nospam verwijderen uit het e-mail adres

Mvg,

Christof Laeremans(Die het niet meer ziet zitten)
Technical Details
Message-ID: <B8F42913.29CF%christof_laeremans@hotmail.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-01!supernews.com!mtu.ru!image.surnet.ru!surnet.ru!news.mailgate.org!newsfeeder.edisontel.com!news.be.wanadoo.com!news.wanadoo.be!not-for-mail
References: <B8F31C5C.2817%christof_laeremans@hotmail.com> <khgz8.1798$X47.873206@iguano.antw.online.be>

Show Full Headers
Complete Article Headers
X-Google-Language: DUTCH,ASCII-7-bit
X-Google-Thread: fcea4,966929e88b6c33f1
X-Google-Attributes: gidfcea4,public
X-Google-ArrivalTime: 2002-04-30 02:20:13 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-01!supernews.com!mtu.ru!image.surnet.ru!surnet.ru!news.mailgate.org!newsfeeder.edisontel.com!news.be.wanadoo.com!news.wanadoo.be!not-for-mail
From: Christof Laeremans <christof_laeremans@hotmail.com>
Newsgroups: be.comp.programming
Subject: Re: [C++]: Splitten van een string ... Wat doe ik fout ???
Date: Tue, 30 Apr 2002 10:57:23 +0200
Organization: Wanadoo Belgium
Lines: 77
Message-ID: <B8F42913.29CF%christof_laeremans@hotmail.com>
References: <B8F31C5C.2817%christof_laeremans@hotmail.com> <khgz8.1798$X47.873206@iguano.antw.online.be>
NNTP-Posting-Host: adsl-143-136.wanadoo.be
Mime-Version: 1.0
Content-Type: text/plain; charset="US-ASCII"
Content-Transfer-Encoding: 7bit
X-Trace: sinclair.be.wanadoo.com 1020157045 1094385 213.177.143.136 (30 Apr 2002 08:57:25 GMT)
X-Complaints-To: abuse@wanadoo.be
NNTP-Posting-Date: Tue, 30 Apr 2002 08:57:25 +0000 (UTC)
User-Agent: Microsoft-Entourage/10.0.0.1309