|
Erwin posted:Horrible newbie question: How do I know? 9009 = 0x2331 8960 = 0x2300 So the least significant byte of Greatest has been stomped on. Which then tells me you're running on a little endian machine, and that ProdChar and Greatest have been declared right next to each other.
|
# ¿ Mar 20, 2008 13:12 |
|
|
# ¿ May 4, 2024 03:21 |
|
Plastic Jesus posted:I came across this a year or two ago: code:
The reason why header files often get unruly is that people often #include when a simple forward declaration would be enough, there's not enough seperation of concepts in the source code structure, and people all too often get lazy with includes and form a single "IncludeFeckingEverything.h" header.
|
# ¿ Mar 27, 2008 12:38 |
|
Plastic Jesus posted:Yes, Rob Pike is an idiot. It doesn't matter how smart someone is, there is always some topic or opinion about which that person is an idiot. Of course, people often don't realise that they're an idiot about that particular thing. If they did, then by definition they would not be an idiot about it. The smartest people are the ones who realise that there are things about which they are an idiot (see also: Socrates )
|
# ¿ Mar 27, 2008 18:09 |
|
Adiabatic posted:Hi all, I'm currently taking an entry-level C++ programming class and can't for the life of me think of where to begin on this one. quote:Students: don't ask or discuss how to get around your school's network security, and don't ask for help with your homework. If you really must ask the internet for help with an assignment, try the Science, Philosophy, and Education subforum. Read your notes and ask your TA. Feel free to come back and ask specific language related problems when you get stuck, but don't expect to be spoon-fed.
|
# ¿ Apr 23, 2008 17:22 |
|
Citizen Erased posted:Does anyone know of a faster alternative to the standard library vector container? A year or so ago I made a 3D application which relied very heavily on the stl vector and since, a friend has told me how slow vectors are. I'd like to re-work some of the old code and replace the vectors with something similar but more efficient if it means I can eek a few more frames per second out of it. Is there anything faster and more suited for real time 3D applications? It's more likely that any performance problems are down to your use of allocations rather than choice of an STL container. Also, I'd avoid listening to your friend on matters of performance in future. EDIT: Check out Meyers' Effective STL if they've got a copy in a library near you.
|
# ¿ Apr 24, 2008 22:10 |
|
Vanadium posted:It says
|
# ¿ May 1, 2008 15:38 |
|
elevatordeadline posted:I don't get it, though. The new codepad output is still correct, but mine is still nonsense.
|
# ¿ May 2, 2008 21:17 |
|
vanjalolz posted:Another book is needed, one which teaches C and programming at the same time.
|
# ¿ May 14, 2008 13:57 |
|
Viper2026 posted:
|
# ¿ May 21, 2008 17:33 |
|
6174 posted:Now this does mean that the program didn't correctly function earlier since the constant would need to be \033, not \33, I've started looking at '\0' in a whole new light since I found out it's a second-class octal zero and not a good and proper decimal zero.
|
# ¿ May 28, 2008 09:22 |
|
Staggy posted:If I build in Debug I get that error, but if I switch to Release to build I get
|
# ¿ May 30, 2008 09:15 |
|
For reference, it's commonly called the 'pimpl idiom' in C++, and more generally known as an 'opaque pointer': http://en.wikipedia.org/wiki/Opaque_pointer
|
# ¿ Jun 12, 2008 08:26 |
|
chutwig posted:The problem that I'm having seems to be a problem with allocating memory. sizeof(active_query_t) returns 80, which seems too small, since this is the definition of the struct: I'd recommend reading chapter 5 of K&R for starters. EDIT: Your current crash is because bs_tm is an uninitialsed pointer to a random bit of memory that you're then trying to write to, but if you don't understand pointers then you're going to run into yet more problems real soon. TSDK fucked around with this message at 17:35 on Jun 12, 2008 |
# ¿ Jun 12, 2008 17:31 |
|
chutwig posted:Just telling somebody to read K&R again doesn't help much when dealing with something like pointers that is very complex.
|
# ¿ Jun 13, 2008 09:56 |
|
Zombywuf posted:Yeah, I do wonder how many problems could be solved with:
|
# ¿ Jun 13, 2008 14:09 |
|
The compiler doesn't know whether you want to implicitly convert 2 to a cFp, or f to an int. Get rid of those user defined cast operators in cFp and replace them with: code:
|
# ¿ Jun 13, 2008 15:49 |
|
Here's a dirt-simple process wrapper app I did a while ago. We used it to launch windowed apps from a batch file (as part of an automated asset building process) so that the batch file would wait until the app had closed down before carrying on.code:
|
# ¿ Jun 24, 2008 11:26 |
|
tyrelhill posted:I'm trying to const_cast a class * const to a class * and getting an access violation exception. I'm guessing there's some assembly optimizations with pointer consts that I dont know?
|
# ¿ Jun 26, 2008 14:17 |
|
Hammerite posted:I didn't follow your advice on changing to using std::string, because I couldn't work out how to make that work; code:
|
# ¿ Jul 2, 2008 14:25 |
|
ZorbaTHut posted:For example: To me, that just looks like a bug caused by someone mixing and matching C style string handling code with C++ string types. That class of bug is quite hard to introduce when using iterators as designed.
|
# ¿ Jul 2, 2008 16:52 |
|
more falafel please posted:You have absolutely no understanding of what you're talking about. If the 'real world' distribution of numbers that your application is handling follows a power law distribution: http://en.wikipedia.org/wiki/Power_law Then let's suppose out of 100,000 cases your variable foo will be asked to handle values in the range 0-2147483647 in 96,000 of those cases. There will then only be something like 3,000 cases where it'll be asked to handle values in the range 2147483648-4294967296. When talking about failures caused specifically by unchecked integer overflow, using an unsigned int instead of an int doesn't actually improve all that much on your rate of failure in general. You then have to weight up the relatively small gain in failure rate versus the likelihood that unsigned ints could cause a problem. In my opinion, the likelihood that an unsigned int would cause a problem relative to a signed int is very very small indeed, so I'll take that failure rate improvement happily and go on my merry unsigned way. In a related anecdote, I've been bitten before by using video encoder software that just gave up after the first 2Gb of a 3Gb file and blanked the image (but not the sound) for the last 3rd of the movie clip. Clearly someone with an always-int mentality had written the file loader for the image compression part, and someone with an unsigned-int-mentality had written the file loader for the sound compression part
|
# ¿ Jul 2, 2008 18:28 |
|
It sounds a bit like you've just not declared the OnInit function in your base state class as virtual. You'll need to post more code to help pinpoint what's going wrong. Have you tried putting a breakpoint in the stateManager::ChangeState function and tracing into the OnInit function call to see where it ends up? Finally, I'm not 100% sure what you're trying to do with the logic in the changeState function, but it's almost certainly much more complicated than it needs to be. Split it into three functions: SetState, PushState and PopState.
|
# ¿ Jul 11, 2008 14:54 |
|
Staggy posted:I figured that this way, all you had to do was shove in the address of the state, and the function would work out the rest. Is this a bad way of going about things? So if you have a PushState function, then it's always going to do exactly what you expect it to do: push a state on the stack - nothing more, nothing less.
|
# ¿ Jul 11, 2008 17:22 |
|
Entheogen posted:does it copy in the example I had? code:
|
# ¿ Jul 21, 2008 15:21 |
|
Avenging Dentist posted:Yes. http://msdn.microsoft.com/en-us/library/ms364057(VS.80).aspx
|
# ¿ Jul 22, 2008 09:48 |
|
Big Mark posted:What, precisely, is the difference between a reference to a variable and a pointer to it? I've always thought of a reference as being a pointer with nicer syntax but apparently this is very very wrong. code:
code:
|
# ¿ Jul 22, 2008 15:52 |
|
JoeNotCharles posted:Isn't "well-formed" a compile-time concept? So how can it depend on the runtime value of p?
|
# ¿ Jul 22, 2008 20:12 |
|
I prefer the following syntax for the flag declarations:code:
Importantly, don't forget to cast the flags to integer types within the operator| and operator& definitions, otherwise you'll end up with an infinite recursive function.
|
# ¿ Jul 23, 2008 00:06 |
|
my stepdads beer posted:I wrote a simple little c program that forks and the child execs another little program. Before the fork, I set up an alarm and signal handler. Now, I thought the child was entirely replaced (in memory) by whatever program it execs, yet the child still seems to be terminated by the alarm I set before the fork. http://www.opengroup.org/onlinepubs/000095399/functions/fork.html Are you sure you haven't got the parent/child processes mixed up?
|
# ¿ Aug 21, 2008 09:49 |
|
my stepdads beer posted:Well they both terminate at the same time (both are writing to stdout continuously). I can't find the child process running after either. Have I written a zombie?
|
# ¿ Aug 21, 2008 11:41 |
|
tyrelhill posted:Does it actually compile differently or? I've worked with people who prefer the '== false' on negative conditions, but omit the '== true' for positive conditions, on the grounds that it's harder to misread compared to the possibility of not spotting a small '!' tacked on to the front.
|
# ¿ Sep 3, 2008 17:40 |
|
Ledneh posted:drat, I've managed to confuse myself completely this time. In C++, how do I write a typedef for a function pointer where the function would have a templated parameter? code:
|
# ¿ Sep 23, 2008 17:38 |
|
What's the prize? 50 EDIT: Bonus nerd points - your program is ill formed because main should be declared to return an int.
|
# ¿ Oct 3, 2008 16:01 |
|
TheSleeper posted:Uh, exactly how can a bias be evenly distributed? Isn't that the opposite of bias?
|
# ¿ Oct 17, 2008 14:04 |
|
Lexical Unit posted:In general you should probably try and clean up whenever you don't need to hold on to the memory anymore, it's just a good habit to get into.
|
# ¿ Oct 23, 2008 09:34 |
|
Avenging Dentist posted:C++ templates are Turing-complete, assertion destroyed. code:
|
# ¿ Oct 27, 2008 10:59 |
|
Gary2863 posted:I have no idea how to do this. EDIT: Now that you've been given a massive hint, I'll leave the fine details as a good learning exercise for you to do
|
# ¿ Oct 30, 2008 20:18 |
|
Avenging Dentist posted:All you really need is K&R. C is a very simple language.
|
# ¿ Nov 14, 2008 12:54 |
|
Jimmeeee posted:is there any way someone can write me a program in C that can edit text files in linux. I'd need just the source code. http://svn.savannah.gnu.org/viewvc/trunk/nano/src/?root=nano Or alternatively, you could grab yourself a copy of Kelley & Pohl's A Book on C to help you out with your course.
|
# ¿ Nov 19, 2008 21:50 |
|
|
# ¿ May 4, 2024 03:21 |
|
Bitruder posted:I am using g++ 4.3.2 on a 64-bit Linux Machine. pElem and pElemParam are already declared, so those statements do nothing. You could either move the initialisation: code:
code:
|
# ¿ Nov 25, 2008 14:29 |