|
|
|
|
||||||
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
Hello everyone,
I have a number of strings in an array, "FILE1", "FILE2", "FILE3", ... , "FILEN" I want to add the common prefix to all the string, like (for example, the common prefix is "FOO") "FOOFILE1", "FOOFILE2", "FOOFILE3", ... , "FOOFILEN". Are there any smarter ways to use a macro to define all of them altogether? thanks in advance, George |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
In article
<7846795f-e214-4f7e-9d6d-f6e4c36106ae@w40g2000hsb.googlegroups.com>, George2 <george4academic@yahoo.com> wrote on Thursday 22 Nov 2007 1:29 pm: > Hello everyone, > > > I have a number of strings in an array, > > "FILE1", "FILE2", "FILE3", ... , "FILEN" > > I want to add the common prefix to all the string, like > > (for example, the common prefix is "FOO") > > "FOOFILE1", "FOOFILE2", "FOOFILE3", ... , "FOOFILEN". > > Are there any smarter ways to use a macro to define all of them > altogether? Yes. Just write "FOOFILE1", ..., instead. Also adjacent string literals are concatenated by the compiler. Thus: "FOO" "FILE2" becomes "FOOFILE2" During runtime you can use sprintf() or strcat()/strncat() do to the same as well. |
|
![]() |
| Outils de la discussion | |
|
|