Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!think.com!spool.mu.edu!rex!rouge!dlbres14 From: dlbres14@pc.usl.edu (Brumley David M) Newsgroups: comp.lang.c Subject: Can pre-ANSI C Preprocessor handle symbolic constants in strings? Message-ID: Date: 31 May 91 10:03:15 GMT Article-I.D.: pc.DLBRES14.91May31050315 Sender: anon@rouge.usl.edu Organization: Univ. of Southwestern LA, Lafayette Lines: 30 In ANSI C it seems possible to use the Preprocessor to do macro substitution of constants in strings: #define FIELDSIZE 42 #define quote(val) #val char buffer[FIELDSIZE+1]; ... /* read a field of length FIELDSIZE */ scanf("%" quote(FIELDSIZE) "s", buffer); ... So that after the Preprocessor, the 'scanf' call becomes: scanf("%42s", buffer); Question: How do I do this with a preprocessor that doesn't understand the new ANSI '#' operator nor string concatenation? Do I have to build the string argument dynamically (allocating an extra buffer in the process)? P.S. I've searched the FAQ list, and the Second (ANSI) edition of K&R to no avail. -- David M. Brumley