Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!samsung!think!barmar From: barmar@think.com (Barry Margolin) Newsgroups: comp.lang.c Subject: Re: character strings, macros, ANSI c, multicharacter chars question Keywords: string, multicharacter, ebcdic/ascii Message-ID: <32685@news.Think.COM> Date: 5 Jan 90 05:05:28 GMT References: <1990Jan4.190431.19748@ultra.com> Sender: news@Think.COM Distribution: na Organization: Thinking Machines Corporation, Cambridge MA, USA Lines: 21 In article <1990Jan4.190431.19748@ultra.com> ted@ultra.com (Ted Schroeder) writes: >Also, I would like to create an integer that is full of '+' characters >i.e. on an ASCII machine the four byte integer would be 0x2b2b2b2b. >Unfortunately the code must run on both ASCII and EBCDIC machines. >Is there any portable way to do this? I don't think this can be done fully portably, because you can't assume that integers and chars are 32 and 8 bits wise, respectively. If you're will to be portably only to such systems (which is better than your previous solution), I think the following will do it: '+'<<24 | '+'<<16 | '+'<<8 | '+' You could also create a union of an integer and a four-character array full of '+' characters. This also isn't truly portable, but it will also work on many systems. -- Barry Margolin, Thinking Machines Corp. barmar@think.com {uunet,harvard}!think!barmar