So in words what I'm trying to do is copy some of the info from the passed client to info in the list, then make the client that was passed in equal to the client in the list. There are two problems, when setting the field from the passed in client to the client in the list I'm not doing that right (damn pointers). Then I try to set the one that was passed in to point to the one in the list so that back in the main function I'm no longer accessing the one that was passed in but the one in the list.
OK well I had this working for awhile, now it doesn't work and I don't even know why... At any rate, I added the delete cp; and it didn't work. debug assertion fails and it crashes. Dunno bout dat.
OK in trying to do some debugging, I did this:
1 2 3 4 5 6 7 8
Server (Server): Server has most same functi
client 5963104 sent send all hello
client 5963104 sent login mike mike
c 3748576 p 4876184
c 4876184 p 4876184
Server (all): mike logged in successfully!
client 5963104 sent send all hello
That's the output on the server. whenever anything is sent it prints c with: printf("client %d sent %s\n",c,message);
and from within login function before and after it's changed: printf("c %d p %d\n",c,&clientList[p]);
So you can see that it isn't changed for the function that called login, while it works fine for the actual log in function.
I hate to be one of 'those' posters but im running into a deadline. (midnight tonight actually).
i don't understand how this is giving me trouble now when i had it working previously, but i'm uber frustrated. :/
By the way, I meant to thank all of you who already posted. I love the forums here, they are very helpful and people posting usually know what's up :) Thanks again everyone.
Zaita Wrote:
> Hmm are you using MSVC++ 2003-2008? If so, you don't need the delete. I
> believe the GC will handle memory deallocation for you.
GC is .net so unless the OP is doing an CLR project with C++/CLI or is mixing managed and unmanaged code then GC is not present. GC is relevant to managed code objects.
Grey: yea. 2003 is the start of the .NET era. If Universities over there are anything like the ones here then it will be .NET based that they are trying to use. Fortunately, I have stayed away from C++ in .NET because I am not a fan of Microsoft's compiler.
I was addressing why the "delete pClient;" would be causing a crash. It seems this persons deadline for their assignment has passed though. So whatever answer we come up with is going to be useless :P