| |
| |
| |
|
Page: 1 2 3 4 5 6 7 8 9 10 11 12 13
Comments:
<0> thank heavens, we're saved <1> glukak nieu jaar <1> or some such <2> i think Cowmoo doesn't want to be friends with me <2> bealtine: gelukkig nieuwjaar <2> but it's not really the moment <1> close <0> solely based on the stupid comment you made earlier, perhaps not <1> its all i know in dutch <2> Cowmoo: i know <2> first impression is crucial <3> Off to office <4> heh, if cowmoo was friends only with people that didn't ridicule him constantly, he'd have no friends at all <4> wait <4> clearly that's the case <5> hi guys.. was thinking of havin a struct something like this.. but not allowed. i'm looking for a better implementation or advice. "struct temp { int type; int nSize; char strData[nSize]; int temps; }" any help in strData?
<6> you could use an STL string <6> if that is what you are asking <1> or a vector <4> K_r3aPeR: the compiler always needs to know the size of things <5> hmm.. but declaring it's size? cause I want to memcpy() some data into the struct directly.. <1> ogh so C <4> if you're stuck on the C way of doing things, I'd suggest a MAX_SIZE macro <4> heh <5> peterhu, yeah that's it.. the problem is the size of it.. im reading from a packet of data.. and memcpy() it into the struct temp <5> so the length would vary <5> bealtine, is memcpy() really bigtime to be not in c++? <1> i just use a vector <6> if you are set on doing ikt the way you have it now, you need to use a pionter and hten allocate memory for it <5> cn28h, huh? sample? <4> or have strData use a constant size which is the maximum amount of data it can hold, and have strData's declaration come last <5> bealtine, i still dont understand how vector helps <6> char *p; p = new char[100]; /* this is not ususally the best way to do things, but it works */ <1> you can set the size <5> cn28h, erngh.. sorry.. that doesnt help <6> why not? <1> he just see the 100 <5> peterhu, declare a constant size? that'd overlap into temps or underlap sometimes.. when i set a constant of 100, but the packet/data only has 50.. then where will temps be? <4> which is why i said strData needs to come after temps <5> peterhu, ahh ok i got ur point.. but the *PACKET* has the temps after the strdata <5> which is having me problems <4> clearly not written by a good C developer <5> i dunno if it's not really written good.. it's from a GAME.. <4> so then use a maximum expression and forget the memcpy <5> maximum expression? <5> read each data and ***ign ? <4> const int MAX_SIZE = 100; struct temp { ... char strData[MAX_SIZE + 1]; ... }; ... /* read packet */ temp t; memcpy(t.strData, packetData, packetDataLen > MAX_SIZE ? MAX_SIZE : packetDataLen); /* does it need a null? */ <4> christ does C **** <6> that wouldn't be valid C ;P <4> yeah <7> i think when having structs like that wiht many diffrent datatype members you should always do a #pragma <7> dunno if its related <4> #define MAX_SIZE 100 <4> heh <1> your original "christ does C ****" comment still stands :) <5> hmm.. lemme read it clear <6> I'm currently doing a project ofr work that is completely in C heheh <1> why C ? <1> no compiler ? <6> kernel code <6> (BSD) <1> big swinging **** ? <5> peterhu, sorry.. but the whole PACKET is.. the TEMP itself <1> couldnt resist :) <6> you've been hanging around peterhu too much <5> so -> temp t; memcpy(t, packetData, packetDataLen) <1> eh? <6> that's not going to work <1> you want to shove the whole packet in one struct ? <1> apart from the syntax errors... <4> honestly, what programmer writes his packets so that variable sized data is sandwiched between fixed sized data? <5> yeap that's it <5> the whole packet in one struct <1> oh gawd <5> i have all of my other packets in one struct.. am just stuck on this one which contains the STRING part <4> what's "temps" supposed to hold?
<6> the time, maybe <1> how do you know how long the "string" supposed to be? <5> temps hold some value in-game.. that i still dunno yet.. a DWORD it should be <5> bealtine, the string's length is the INT before the start of the string <1> so what wrong with a pointer then? <4> he needs to read in 4 bytes (***uming 32 bit int) into "type", 4 bytes into size, allocate a buffer of size "size" (***uming there's no max), read in "size" number of bytes, read in 4 bytes into "temps" <5> a pointer? and when I allocate the whole struct? defeats the purpose <1> ummm <5> peterhu, yep <1> why would you do that? <5> so I'd not memcpy() this then.. any better advice? <1> a vector usuulay works fine for me ymmv <8> yah <8> make ur own memcpy <5> i read my packet till I reach the SIZE? <8> say standard library, you ****ing **** <8> i'll ****ing kill the standard library <1> got that off your chest then? <5> thanks for your time guys <5> i'll re-think all of your advices <4> K_r3aPeR: http://www.noidea128.org/sourcefiles/16346.html <4> might give you some ideas <4> it should really have a sizeof(char) in there, and you could avoid a second string copy if you wanted to, but i just pounded it out to give you some ideas <4> oh, and noidea128 formating blows hard <0> for the millionth time, rafb.net/paste <4> std::vector<char> buffer => std::vector < char >buffer? blech <4> pfft <4> rafb sounds dubious <0> which says nothing about its functionality <0> f00l <1> thats so efnet <0> too bad, since it's rather superior <4> everyone should use sourceforge <0> if rafb had a compile option then it would be superior to sf <0> sf looks like poo <4> http://cpp.sourceforge.net/ <4> far superior <4> even compiles it <0> my statement still stands <4> plus, it's editable <0> oh, true <0> but still rafb looks better <0> mo betta <4> pfft <4> you = baffoon <9> I have a program that is going to spit position data several times a second, so I don't want to use fprint, etc. What is the easist way to have the program make one line that says "Position: XX" where the XX is updated, without printing a whole new line? <0> I really wish NI would either improve his pastebin or the link would be to another more competent one <0> the link in topic, that is <1> we wish for many things <0> Christoph66: eh? is creating a function ok? <4> Christoph66: firstly, fprintf is a legacy C function and rarely used by C++ developers; secondly, you would have to seek backwards from the write to write again <0> ohh <9> peterhu: yeah fprint was simply an example of printing a whole new line. OK, what function or library should I look at for the functionality <4> seekp is what you want on fstream <4> lunch time <4> bbl <9> ok thanks <5> peterhu, tnx <10> today is Update Tuesday! <10> Microsoft Windows updaten <6> ich ben rebooten <11> how do you perform simple addition in c++?| <11> cout<<x+y; <11> ? <0> ? <11> oh. <0> where are all you people coming from <0> with your strange question <0> s <11> z = x + y; | cout>>z; <0> << <12> cout<<z; <11> i am a beginner <12> cout<<z<<endl;;
Return to
#c++ or Go to some related
logs:
mihaypotter #php scorpaen (gf)
No Heaven.mp3 #teens #java #AllNiteCafe #c++ #linux #linux
|
|