Link to home
Start Free TrialLog in
Avatar of Kuoster
Kuoster

asked on

integer to string

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

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

STR & VAL... ^_^
ASKER CERTIFIED SOLUTION
Avatar of marcjb
marcjb
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Kuoster
Kuoster

ASKER

Thanks! I never thought that it would be that easy.

Have a very happy Y2K!
Thank you, and a Happy New Year to you!
Avatar of Kuoster

ASKER

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);
Avatar of Kuoster

ASKER

thanks ^^