Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

program

Status
Not open for further replies.

swaroop

Programmer
Feb 4, 2001
100
US
Here is a statement
cout << &quot;Variable Name : &quot; << Variable << endl;
I wanted to change that to
PN(Variable);
I wanted the same result.

Could any one give Idea(program ) for this.

Thanks in advance.

Swaroop.

 
YOu could always try to define it, something like this:

#define PN(variable) cout << &quot;Varialbe name : &quot; << variable << endl;

all you need to do from here is to call
PN(/*statement here*/)

PN(&quot;HELLO&quot;) // this would give the result

Varialbe name : HELLO Martin G Broman
mgb_svea@thevortex.com

DWS - Alpha Whitin Dead Wolf Society
Xaner Software, DB programer
 
Thankyou for your reply.

There was a typographical error in my program.

I want to see the program as shown example below.

#include <string.h>
.
.
.

char *Variable;

strcpy(Variable, &quot;Swaroop&quot;);
PN(Variable);
.
.
.

For the above statement I want the RESULT as

Variable : Swaroop

That I was expecting.

Regret my mistake.

 
if u don't want to use cout to print u can always overload insertion operator and use any thing u want
 
Do you mean something like:
Code:
void PN (string Something)
{
    cout << &quot;Variable Name : &quot; << Something << endl;
}

.
.
.

int main()
{
    string Variable = &quot;Swaroop&quot;;
    PN(Variable);
    return 0;
}

James P. Cottingham
 
Thank you for reply.

But The output of your code will give a result look something like this

Variable Name : Swaroop

I wanted my code output have to give a result look something like this

Something : Swaroop

I think you got my point.
 
So the varialbe thing is just the name for a variable??
such as integers, char string etc.?? Martin G Broman
mgb_svea@thevortex.com

DWS - Alpha Whitin Dead Wolf Society
Xaner Software, DB programer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top