• C

integer to string

How do you code this QB code below in TC??

i% =  3
A$ = "Test" + STR(i%)  ' << Test 3

STR & VAL... ^_^
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

num = 3;
/* a is a string */

sprintf(a, "Test %i", num);

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
KuosterAuthor Commented:
Thanks! I never thought that it would be that easy.

Have a very happy Y2K!
Thank you, and a Happy New Year to you!
Making Bulk Changes to Active Directory

Watch this video to see how easy it is to make mass changes to Active Directory from an external text file without using complicated scripts.

KuosterAuthor Commented:
One more question, what can I do if I want to write something like this??

a$ = a$ + STR$(3)
I'm not familiar with QB, but it looks like you are trying to add something to an existing string.  If that is the case, you have two options.

1) If you are adding a string to another string, use the strcat function.

2) If you want to add a number to a string, copy the original string to a temporary string, and then use sprintf.

The reason you copy to a temporary string is that according to the C Standard, you cannot use the same string as both the target and source with sprintf.
For example, the following will compile, but may cause your program to crash.
sprintf(aString, "%s %i", aString, aNum);

So, given an array of characters called aString, a temporary array called aTemp, and a number aNum, you could do the following:

strcpy(aTemp, aString);
sprintf(aString, "%s%i", aTemp, aNum);
KuosterAuthor Commented:
thanks ^^
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.