Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!dali.cs.montana.edu!uakari.primate.wisc.edu!samsung!olivea!tardis!tymix!uunet!email!vmars!hp From: hp@vmars.tuwien.ac.at (Peter Holzer) Newsgroups: comp.lang.c Subject: Re: ANSI CPP string concatenation Keywords: ANSI CPP string concatenation Message-ID: <1991Jun20.154758.3957@email.tuwien.ac.at> Date: 20 Jun 91 15:47:58 GMT References: <1271@cnw01.storesys.coles.oz.au> Sender: news@email.tuwien.ac.at Organization: Technical University Vienna, Dept. for Realtime Systems, AUSTRIA Lines: 28 Nntp-Posting-Host: nowhere.vmars.tuwien.ac.at 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; } Nitpick: I do not see any strings here, just tokens (a string is something between double quotes) >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; } >Anyone know the secret ? Yes. The token pasting operator is ##. So your macro should read: #define APPEND(x,v) {donothing ## x = v;} -- | _ | Peter J. Holzer | Think of it | | |_|_) | Technical University Vienna | as evolution | | | | | Dept. for Real-Time Systems | in action! | | __/ | hp@vmars.tuwien.ac.at | Tony Rand |