Article View: be.comp.programming
Article #1712Re: [Java] Precision los char -> byte
From: Aquila
Date: Wed, 15 Dec 2004 10:56
Date: Wed, 15 Dec 2004 10:56
40 lines
2150 bytes
2150 bytes
Vincent De Baere wrote:
> Opmerkingen op de C++ zijn meer dan welkom, dit is
> zowat het eerste stukje code dat ik daarin schrijf, excuses dus voor
> eventuele blunders.
>
> #include <iostream>
> #include <string>
>
> using namespace std;
>
> int main(){
> /* unsigned char should allow us for 8bit latin1 */
> unsigned char array[10];
> string str = "";
hoeft niet, strings worden standaard op "" ge�nitialiseerd
> int seed(0);
> int result(0);
>
idem voor ints en 0
> for(int i = 0; i < 10; i++){
> cout << "input char"<< endl;
> cin >> array[i];
> result = seed ^ (int)array[i];
je hoeft niet te casten naar int want in C++ zijn int en char volledig
compatibel
> seed = result;
> str += array[i];
waarom gebruik je niet ineens die array van chars? die kan je ook outputten
en dan hoef je geen extra string te gebruiken, cout << array werkt ook...
--
"May the source be with you"
Technical Details
Message-ID:
<Xs2dnVReHJXqhV3cRVnysA@scarlet.biz>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local1.nntp.dca.giganews.com!nntp.scarlet.biz!news.scarlet.biz.POSTED!not-for-mailReferences:
<pan.2004.12.15.10.48.05.274938@lilly.csoft.net>Show Full Headers
Complete Article Headers
X-Google-Thread: fcea4,344e68e2aa7407 X-Google-Attributes: gidfcea4,public X-Google-Language: DUTCH,ASCII Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local1.nntp.dca.giganews.com!nntp.scarlet.biz!news.scarlet.biz.POSTED!not-for-mail NNTP-Posting-Date: Wed, 15 Dec 2004 04:56:55 -0600 From: Aquila <braempje@netscape.net> Subject: Re: [Java] Precision los char -> byte Newsgroups: be.comp.programming Date: Wed, 15 Dec 2004 11:56:55 +0100 References: <pan.2004.12.15.10.48.05.274938@lilly.csoft.net> User-Agent: KNode/0.8.1 MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8Bit Message-ID: <Xs2dnVReHJXqhV3cRVnysA@scarlet.biz> Lines: 40 NNTP-Posting-Host: 81.11.150.5 X-Trace: sv3-5bE5Lo1L0qC/31gr3FvwihdEAMUG5fvmtykSSUJ/cpk4XrTQ5Uli3+hRVM8/sV6jaD6G4hSweKVPLcG!apUdEJkub8z6UJgB12VwsTiw4MvDPdvO0Y84PvunnBM5jrG5rwhTWAFaj3tPvGId9ziLhQWt X-Complaints-To: abuse@scarlet.be X-DMCA-Complaints-To: abuse@scarlet.biz X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.20