Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!elroy.jpl.nasa.gov!ncar!hsdndev!cmcl2!adm!smoke!gwyn From: gwyn@smoke.brl.mil (Doug Gwyn) Newsgroups: comp.lang.c Subject: Re: help with a macro Message-ID: <16126@smoke.brl.mil> Date: 11 May 91 03:42:13 GMT References: <595@afc-tci.UUCP> Organization: U.S. Army Ballistic Research Laboratory, APG, MD. Lines: 15 In article <595@afc-tci.UUCP> joubert@afc-tci.UUCP (Joubert Berger) writes: >I want to define a macro, lets call it UNDERLINE that would take a string >as a parameter. This macro should add some characters in front and behind >the string. Is this possible? >I want to be able to say: > fprintf(f, "%s\n", UNDERLINE("test")); >and it replaces the the "test" with the newly created string. >Am I asking to much of the preprocessor? Since you want to do this with the preprocessor, we may assume that you want to do this only for STRING LITERAL arguments to the UNDERLINE() macro. In ANSI C, it is trivial: #define UNDERLINE(s) "\033[4m" s "\033[0m" for example. In older C implementations, it is unlikely that you will be able to perform this operation via preprocessing.