Hell, you should see the way I currently have it set up. its done all manually. I'll definately look into stringstream. Put it this way, I never took any coding classes, and i'm dependent on using namespace std. What does that tell ya? Thanks for the help! Btw, I already tried to make the buffer about 10 times larger than it should need to be and it did the same thing. I'll check this out and report back.
Originally Posted by vart
Well, I made my buffer:
RandomData= new char; and it still says the same thing... I don't see why, but either way i'm very new to stringstream and if someone could give me an easy out and give me an example of what stringstream functions i'd use to accomplish what i'm trying to do here?
The thing is i'm always dealing with dynamic buffers, its never just a constant stream. Some of the data is constant, but the name lengths and the commands that i'm sending/recieving with my server always change. Basically its an IRC client but for another purpose.
Basically, what i'm doing here is constructing the outgoing packet.
This is the code that i'm using that works but I know there has got to be a much better way. And it would be a good thing to notice that I create the dynamic buffer exactly the same here and it works fine when I sort through it manually.
And basically, this is what would get sent out to all the clients:
//make buffer the size of the static data(22) plus the size of the user's nickname
RandomData= new char[22+client[cNum].nicklen];
RandomData[RandomVar]=0x3a; //insert a ':'
//insert the user's nickname into the buffer
//insert the static data
//send to everyone so they all know who left the lobby
if(client[x].s>0) // 's' is the client socket
":lytar!u@h PART #Lob_18_0\r\n"
If anyone can help me out here, or let me know what I SHOULD be doing, i'd appreciate it. I have my own little crappy way of coding sometimes. But anyhow, i'd really appreciate a little direction here since this is probably one of the simpler packets I have to construct, I have some terribly confusing ones like:
After you access the same struct more than twice it starts to get mind boggling. And I may do this two or three times to create one packet. The reason I use a struct is to easily keep track of and access multiple client's data. I'm sure there is lots of optimization I can do, but hell. There has got to be an easier way. TIA.
//add the names