PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.c > Smarter ways to define MACRO to strings?
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Smarter ways to define MACRO to strings?

Réponse
 
LinkBack Outils de la discussion
Vieux 22/11/2007, 07h59   #1
George2
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Smarter ways to define MACRO to strings?

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
  Réponse avec citation
Vieux 22/11/2007, 09h11   #2
santosh
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Smarter ways to define MACRO to strings?

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.

  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 13h54.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,08391 seconds with 10 queries