|
-
Aug 6th, 2002, 09:57 PM
#1
Thread Starter
Fanatic Member
Arrays
Is it possible to convert Arrays into Chars?
I want to use Arrays in strcat.

prog_tom
JOIN THE REVOLUTION!!!! Dual T3 backedup science community.
http://physics.sviesoft.com/forum
-
Aug 6th, 2002, 10:26 PM
#2
PowerPoster
What type of array is it and are you trying to convert an item of the array or the whole array? If the whole array then how should it be appended to your string using strcat()?
-
Aug 7th, 2002, 10:25 AM
#3
Thread Starter
Fanatic Member
Just an item in the array, a[1];

prog_tom
JOIN THE REVOLUTION!!!! Dual T3 backedup science community.
http://physics.sviesoft.com/forum
-
Aug 7th, 2002, 12:26 PM
#4
PowerPoster
Try this:
PHP Code:
char mychar[10];
itoa(a[1], mychar,10);
//Now you can use "mychar" as your string
strcat(mychar......
-
Aug 7th, 2002, 08:26 PM
#5
Thread Starter
Fanatic Member
how about a whole array?, say a[0],a[1],a[2]

prog_tom
JOIN THE REVOLUTION!!!! Dual T3 backedup science community.
http://physics.sviesoft.com/forum
-
Aug 7th, 2002, 08:43 PM
#6
Thread Starter
Fanatic Member
and isn't itoa used only for integers to strings? a[] are also chars in this case, would it report error?

prog_tom
JOIN THE REVOLUTION!!!! Dual T3 backedup science community.
http://physics.sviesoft.com/forum
-
Aug 7th, 2002, 10:56 PM
#7
PowerPoster
If you have characters in the elements of your array then you can simply loop through each item and append the text from it to your main string. So the code I wrote above won't work if you have anything other than integers in your array.
PHP Code:
for(int i=0;i<=sizeof(a);i++)
{
strcat(mainstring, a[i]);
}
-
Aug 13th, 2002, 06:01 AM
#8
Abdul: that code won't work
prog_tom: how about saying exactly what you want to do. What is in the array, what are you trying to do with it, maybe give an example.
Only if it still matters of course.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|