开发者

To convert Datatype "WORD" into char*

开发者 https://www.devze.com 2023-03-07 16:51 出处:网络
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++.

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 nee开发者_JAVA百科d 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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消