How to convert variable from ascii to string?

How to convert variable from ascii to string?

If We want to generate characters from their ascii codes, We can use the sprintf() function, example :

sprintf(\"%c\",65) will generate \"A\"

If we want to add a number onto the end of a string, We can simply stick it next to the string, example :

ball=5;

print \"and the winning number is : \" ball;

Putting them together can get some interesting effects, example :

public arr[] = {72,101,108,108,111,32,102,114,111,109,32,77,105,115,104,97};

msg = \"\";

for(i in arr) msg = msg sprintf(\"%c\",arr[i]);

print msg;

Hmmm, interesting effect from the elements not being in order. I\'ll try it again :

msg = \"\";

for(i=0;i<16;i++) msg = msg sprintf(\"%c\",arr[i]);

print msg;



By:UMANG
Date:2002-02-09 00:00:00

Post Your Answers


User Email:

User Name:
Answers:

Related TESTING Subjective Links

TESTING Subjective interview questions and answers for experienced and fresher