Free2Code
The majority of forums are now only available as archives, which means posting/editing is disabled.

The Anything and Everything forum is still open.
 
Time: 2013-05-18, 12:15pm
C++ problem
Subject: C++ problem  ·  Posted: 2003-10-23, 05:49am
Rank: Unregistered
I wanted to know if it is possible to see if something is defined using a variable. For example, say you have the following code:

#define NAME "Scott"

main()
{
char pszStr[50];
strcpy(pszStr, "NAME";

//At this point pszStr = "NAME"

cout << NAME; // this will output "Scott"
cout << pszStr; // this will ouput "NAME"

}


Is there some way you can see if NAME is defined using the variable pszStr? If so, is there then a way to get the value of NAME?
 
  Reply to this ·  Post link ·  Top
Subject: Re: C++ problem  ·  Posted: 2003-10-23, 08:02am
Rank: ? (4827)
Member #: 3416
use: strcpy(pszStr, NAME);

alternately, you can find out if NAME is defined using something like this:

#ifdef NAME


my mind is like a steel trap! it only hangs on to the big stuff. visit my forums at track7.org
 
  Reply to this ·  Post link ·  Top

Pages: 1

Please login or register to post a reply.

Penguino AVR

Want to learn about robotics or microcontrollers?
Check out the Penguino AVR from our friends at
Icy Labs