🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: be.comp.programming
Article #1336

Re: omzetten van integer naar char

#1336
From: Philip Paeps
Date: Thu, 26 May 2005 16:00
25 lines
2030 bytes
JanC <usenet@janc.invalid> wrote:
> Op Thu, 26 May 2005 14:35:27 +0200, schreef Rik:
> > De taal die ik gebruik is C.
> > Die 1 is een integer waarde .
> > Dit is voor omzetting van binair naar decimaal....de 1 is gewoon de rest 
> > door deling, en die wil ik wegschrijven naar een string.
> > De 0x30 is hexadecimaal voor 0, als ik dus 1+ 0x30 in de array schrijf ( 
> > char array ) krijg ik dan 1 , niet als integer?
>
> In C kan je allerlei typen variabelen door elkaar gebruiken zonder
> foutmeldingen te krijgen, je kan dus gewoon een letterlijke char '0'
> gebruiken ipv die hexadecimale waarde, en daar 0 of 1 bij optellen.
>
> cijferteken0of1 = "0" + (x % 2);

Je bedoelt '0', niet "0", die laatste is een const char * met 0\0 erin.

 - Philip

-- 
Philip Paeps                              Please don't email any replies
philip@paeps.cx                               I follow the newsgroup.

  BOFH Excuse #241:
    _Rosin_ core solder? But...
Technical Details
Message-ID: <slrnd9bsli.smh.philip+usenet@fasolt.home.paeps.cx>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!dotsrc.org!news.dotsrc.org!not-for-mail
References: <hpmdndIYErxoVQnfRVnytg@scarlet.biz> <slrnd99v8t.m2.philip+usenet@fasolt.home.paeps.cx> <_e2dndyubqUQXwjfRVnyvg@scarlet.biz> <pan.2005.05.26.15.51.16.723266@janc.invalid>

Show Full Headers
Complete Article Headers
X-Google-Thread: fcea4,c59addd1ec4c7578
X-Google-Attributes: gidfcea4,public
X-Google-Language: DUTCH,ASCII-7-bit
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!dotsrc.org!news.dotsrc.org!not-for-mail
Newsgroups: be.comp.programming
From: Philip Paeps <philip+usenet@paeps.cx>
Subject: Re: omzetten van integer naar char
References: <hpmdndIYErxoVQnfRVnytg@scarlet.biz> <slrnd99v8t.m2.philip+usenet@fasolt.home.paeps.cx> <_e2dndyubqUQXwjfRVnyvg@scarlet.biz> <pan.2005.05.26.15.51.16.723266@janc.invalid>
Organization: Happily Disorganized
X-PGP-Fingerprint: FA74 3C27 91A6 79D5 F6D3  FC53 BF4B D0E6 049D B879
X-Date-in-Rome: ante diem VII Kalendas Iunias MMDCCLVIII ab Urbe Condida
Message-ID: <slrnd9bsli.smh.philip+usenet@fasolt.home.paeps.cx>
User-Agent: slrn/0.9.8.1 (FreeBSD)
Date: 26 May 2005 16:00:50 GMT
Lines: 25
NNTP-Posting-Host: 213.118.102.166
X-Trace: news.sunsite.dk DXC=FC``n1g77VV[eoV[BRG`:]YSB=nbEKnk[31k3>6NnZ@Y9U;h4\3F?GWiM[k@0X\k?^c7MKXFi2^]_lKk;CYU5F>PlESfOWgO1<Y
X-Complaints-To: staff@sunsite.dk