geester
11-08-2006, 05:21 PM
Im not very experienced with C so this is probably a basic question. I have a script that opens up 5 sockets, it then runs through a loop and on a given event reconnects to the relevant socket and sends some data. The socket to be reconnected to is kept track of with a 'count' variable. The sockets are named s0,s1,s2 etc. This is the code I have to send the data:
if (count == 0) write(s0,"some data",9);
if (count == 1) write(s1,"some data",9);
if (count == 2) write(s2,"some data",9);
if (count == 3) write(s3,"some data",9);
if (count == 4) write(s4,"dome data",9);
Instead of this I simply want to use:
write(s+count,"some data",9)
But how do I append the count integer onto the 's'
Thanks, G
if (count == 0) write(s0,"some data",9);
if (count == 1) write(s1,"some data",9);
if (count == 2) write(s2,"some data",9);
if (count == 3) write(s3,"some data",9);
if (count == 4) write(s4,"dome data",9);
Instead of this I simply want to use:
write(s+count,"some data",9)
But how do I append the count integer onto the 's'
Thanks, G