samprat
samprat

Reputation: 2214

To convert Datatype "WORD" into char*

I have to convert word datatype into char* to pass in a function. Could anyone show me how to do it. IT should be in C and not C++.

Also I need to pass into function something like 2000-3000-2 where 2000 = word datatype 3000 = word datatype 2 = word and "-" while function takes char* as an argument.

so basically i need to convert above combination of word datatype into char*.

Any help or criticism will be helpful

Upvotes: 0

Views: 3620

Answers (1)

David Heffernan
David Heffernan

Reputation: 613252

You are looking for sprintf(), perhaps something like this:

sprintf(buffer, "%.4d-%.4d-%d", w1, w2, w3);

where w1, w2 and w3 are integer variables holding values 2000, 3000 and 2 in your example.

Upvotes: 4

Related Questions