Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!chinacat!sequoia!unisql!pckim From: pckim@unisql.UUCP (Pyung-Chul Kim) Newsgroups: comp.lang.c Subject: Re: ANSI CPP string concatenation Summary: refer to FAQ 37. Keywords: ANSI CPP string concatenation Message-ID: <1366@unisql.UUCP> Date: 20 Jun 91 14:46:52 GMT References: <1271@cnw01.storesys.coles.oz.au> Reply-To: pckim@unisql.UUCP (Pyung-Chul Kim) Organization: UniSQL, Inc., Austin, Texas Lines: 36 In article <1271@cnw01.storesys.coles.oz.au> nigel@cnw01.storesys.coles.oz.au (Nigel Harwood) writes: >Does anyone know if you can append strings in ANSI C. > >For example I want a macro which appends one of its numeric >arguments to a string coded into the marco. > >#define APPEND(x,v) { donothing+x = v; } > >I know that the '+' isn't what I'm after but using whatever the method >turns out to be what I want it to generate from APPEND(1,123) is: > > { donothing1 = 123; } > FAQ 37. says that we can use ## for this purpose. 37. I have some old code that tries to construct identifiers with a macro like "#define Paste(a, b) a/**/b", but it doesn't work any more. A: Try the ANSI token-pasting operator ##. That is, #define APPEND(x,v) { donothing ## x = v; } Hope it helps -- Pyung-Chul Kim UniSQL, Inc. 9390 Research Blvd., Kaleido II, Suite 220, Austin, TX 78759 Internet: execu!sequoia!unisql!pckim@cs.utexas.edu UUCP: {uunet, cs.utexas.edu!execu}!sequoia!unisql!pckim TEL: (512)343-7297 Ext. 332 FAX: (512)343-7383