| |
| |
| |
|
Page: 1 2 3 4 5
Comments:
<0> Oops, sorry folks, if somebody answered me, I miseed the answer <0> does doing "static const enum myEnum { PEN = 0, EGG }" take any storage at all? <0> ****ing IT guys messing with the connection at work <1> when i try to use this "if (op == +) cout <<num1+num2;" it says expected primary-expression before ')' token...? why is that? how can i fix it? I'm trying to get the user to put in two numbers and then an operator, if the operator is + then it will do num1+num2 and the same for - / and *... <2> maybe you want '+' ? <2> + is an operator, '+' is a character literal, evaluates to char, "+" is a string literal, evaluates to char* <1> yeah i tried that now. are + - / and * cl***ed as characters? <2> :/ <2> they're all operators, but you want to check op against a character <2> since you're parsing strings <2> _think_ for a second. :) <1> i've set char op;. is that right? <2> then you want if (op == '+') <1> yeah. but when i try the calculation it reads "invalid character" on the console... <1> ugh <1> hold on
<1> never mind :| <1> thanks for your help :) <2> np <3> how do I check to make sure that there are still write references to a pipe I have read reference to? <3> or iwll read go to -1 once all write references have been removed and you attempt to read an empty pipe? <3> I write a string of characters to a pipe, works great when its two characters, but when its a string of 8aaaaaaaaaa I only get back 8aa, what gives? pipe not big enough or something? <4> are you only reading 2 or 3 chars at the other end ? <3> 80 <4> dunno then. I don't like pipes, hehe. <4> maybe if you paste the code to pastebin in topic, someone'll take a glance <3> hehe np :) testing out some things quickly... <3> ugh, I'm so tired of these (*&^ing labs... writing compilers, interpreters, semaphores, threadings, pipes, give me a break. <3> like programming, but sheesh. <3> ugh <3> http://cpp.enisoc.com/pastebin/6746 - common.h contains wrappers to generic functions like read write fork etc... should be pretty obvious to interpret, just do some error checking. <3> I write 8aaaaa to a pipe and get back 8aaa when I read. <5> pr0bity: How did you write it? did you check it was fully written? <3> with write... and no :) <5> write has a return value.. <5> perhaps you ought to read the docs for things before you use them :) <3> those docs are soo long... <3> and dry... and boring.... <3> and tedious... <3> *mutters* :) <3> thx <6> Blaspehmy <6> I cant figure out how to profile my code.. any help? <5> gprof/kprof.. all kinds of other things no doubt <7> callgrind from valgrind is also cool <3> http://cpp.enisoc.com/pastebin/6747 - modified writeFile(called that even tho writing to a pipe, lazy...) to check to make sure that it keeps trying to write until the return is not less than the length. <3> not working... maybe I'm thinking about it wrong :| <5> define "not working" <7> teatime <5> your ***ignment from cBuffer to sOutput is invalid. <3> I read from the pipe 1a, 2aa, 3aa, 4aaa at which point it only reads from process c and then hangs, process b never exiting I suppose. <5> cBuffer is iLength long (and your use of hungarian is painful) and could potential contain nul characters - your ***ignment could be cutoff by those characters, or go off the end of cBuffer if it doesn't contain any <5> you should be using iLength in that ***ignment, if at all <5> and I don't know why you'd create sOutput to begin with.. <3> k <5> and then you go and ***ign (illegally, mind you) the result of c_str() back to cBuffer.. <5> WHY?! <5> why create sOutput t all? <3> not used to dealing with c-strings ;) <8> I was dealing with c-cups earlier <8> when that got old, I progressed to the g-string <3> i'm reworking it ;) one sec... <6> Hey guys, can u tel me how polygons are normally define in game programming? <8> RedCore: we already did. this morning <8> [09:28] <6> How are polygons normally defined? <8> [09:46] <7> at least 3 points in space <8> [10:01] <8> distinct points <8> [10:02] <8> RedCore: point + normal only defines a plane <3> vulture, how am I supposed to pull out a character array with any remainder that iErrorCode give back? <3> err substring from the character array <5> int writeFile(int fd, char* buf, int len) { int res = 0; while (res != -1 && res != len) { len -= res; buf += res; res = write(fd, buf, len); } return res; } <5> that'd be a simple enough way to do it.. <3> buf += res deletes the elements before res? <5> Doesn't delete anything - just makes 'buf' (a pointer) point to the character 'res' ahead of the current location pointed to <3> hmm, never knew that. Thanks. <5> you could even template this to deal with an arbitrary iterator pair.. more general n stuff, but unnecessary
<5> it's called pointer arithmetic.. <5> x[n] is just a special case which is equivalent to *(x + n) <3> I'll remember that, I appreciate it. <3> btw, what did you mean by hungarian? <5> pr0bity: the prefixes on your variables to indicate what type they are is a primitive form of Hungarian Notation <3> your preference? <4> Swedish Notation <5> pr0bity: No silly prefixes :) <3> not working yet, trying to test where I'm getting hosed up at... <3> prolly the hungarian *sigh* <3> :P <5> pr0bity: did you examine the solution I offered? <5> are you sure you are doing similar checks on the reading side? <3> yes, no. <3> doing that now, but I modified my code to be almost identical to your solution and I output cbuffer everytime its written. <3> it only ever gets outputted once. <3> so maybe its reading or something... <3> so I'd do the exact same thing as write basically, sept store iLength before I modify it, then at the end do cBuffer -= the orig iLength ? <5> why would you do that? <3> to set the pointer back to the beginning of the string. <5> the pointer is local - it ceases to exist at the end of the functino <3> in read its a reference. <5> in what it's which? <3> let me mod the func the way I see it working and then paste it in bin... <3> http://cpp.enisoc.com/pastebin/6748 <6> Thanks, scalar. :-p <5> I still don't see why you subtract anything from cBuffer.. it's a temporary - it ceases to exist when the function ends <3> but its not, when I call writefile I use the buffer I send to it. <3> its a ref. <5> and I'd be pretty sure read fails when you p*** it -1.. which is why I didn't bother checking it <5> int readFile(int iFileIdent, char * cBuffer, int iLength) <5> cBuffer is a pointer. P***ed by value. No reference there at all. <3> .... <3> I create a char array cBuffer in my main program, call writeFile on it and it populates the cBuffer array, or initializes it or whatever. <5> any modification to cBuffer (the pointer itself, not the thing it points to) will not be reflected in the pointer outside readFile. <3> my main prog and the writeFile func point to the same mem loca? <3> ahhh <3> I see. <5> pointer, p***ed by value. <3> do you charge hourly? ;) Thanks for the help. <5> no worries <5> feel free to make a donation to something.. somewhere.. pay it forward, you know hehe :) <3> I'll keep it in mind ;) <3> so I guess returning i res and using that to determine how many characters were put into cBuffer is pretty stupid idea. I should return iLength... or just ***ume its always iLength... <3> well.... if I res is pos, ***ume all were read in. <5> um.. the loop either exits with the value iLength, or -1 <5> those are the only ways the loop can exit <3> hey what if I try reading when a pipe looses its writers, shouldn't I catch the 0? <5> so you just check for -1 (error) <5> nothing else needs to be checked for <5> loses its writer? loses it how? <5> do you have a test case of your current problem? <3> so the prog creates three proc's, two of which write, one reads. The two close off the write end of the pipe after so many characters... but the read will keep trying to read 80 characters at a time without ever checking for a return of 0 from the read. <3> so I'll just throw in if (iRes == 0 && iTempLen != 0) { return 0; } ? <5> I'm pretty sure write can't return 0 unless you're in non-blocking mode. <3> read <3> read returns 0 if there are no references to the pipe, I think (remember glancing over the man ;) ) <3> write reference to the pipe <5> sure, so just do the same as the writing code, but change the looping code to check for 0 or -1.. *shrugs* <5> then you can check for any length less than the amount asked for (which would indicate closed stream), or -1 (failure, etc).. <3> ugh, pos. <3> still not working, output 4aaa, 5aaa, 6aaa, 8aaa, instead of 8 a's, etc... <3> weird <5> make a test case, pastebin it <3> there isn't any testing in the prog.... it simply runs. <3> ie no input <5> by "test case" I mean the simplest complete program that demonstrates the problem. <3> oh, well I started typing the complete program in pastebin, I can point you to the trouble functions? <3> common.h and PipeRW.cpp <3> and was going to paste the output... <3> http://cpp.enisoc.com/pastebin/6750 & 6751 <3> main basically makes two child processes and the one running the function ProcessB is the problem. <3> (in 6751) <3> I'm supposed to hav eoutput of 1a, 2aa, 3aaa, 10aaaaaaaaa, 11a, etc...
Return to
#c++ or Go to some related
logs:
#india #chat-world #allnitecafe #india #chat-world chat for freeeeeee #worldchat copper chimney india Cricket on u tube kelli_kanyon
|
|