|
ShoulderDaemon posted:No, it's just habit from other languages which require it.
|
# ¿ Jan 8, 2009 21:29 |
|
|
# ¿ May 17, 2024 16:29 |
|
TheSleeper posted:Uh, C++ follows the proper order of operations. If somebody told you x = 3 * 2 + 1 + 2, would you say that x is 9 or 15? Obviously 9. Why would C++ do it any other way?
|
# ¿ Jan 8, 2009 23:04 |
|
floWenoL posted:Are you sure?
|
# ¿ Jan 10, 2009 03:22 |
|
hexadecimal posted:Oh... lol you got me there. %2 would do what i meant to do.
|
# ¿ Jan 10, 2009 03:29 |
|
hexadecimal posted:Can you show me how to do this? code:
Dijkstracula fucked around with this message at 03:40 on Jan 10, 2009 |
# ¿ Jan 10, 2009 03:35 |
|
Ugg boots posted:Ugh, this still isn't a properly shuffled array. vvv Kluth Shuffle is linear, so I don't think that's it. Dijkstracula fucked around with this message at 03:49 on Jan 10, 2009 |
# ¿ Jan 10, 2009 03:45 |
|
Victor posted:Genius! I suppose this is a standard way of reasoning if you have formal CS or maths training, but i don't. I had seen this idea before, but I think you just locked it in my slow brain. edit: yep, I'm still embarassed. Dijkstracula fucked around with this message at 03:56 on Jan 10, 2009 |
# ¿ Jan 10, 2009 03:53 |
|
honeymustard posted:Hmm, I think I understand that. What I originally wanted was one line within the loop, like:
|
# ¿ Jan 11, 2009 21:11 |
|
Mustach posted:
Also, this directive strikes me as dangerous.
|
# ¿ Jan 12, 2009 20:28 |
|
ShoulderDaemon posted:...yes? Mustach passed a[0], an expression, as the parameter to sizeof.
|
# ¿ Jan 12, 2009 20:50 |
|
Good lord, can people not write out "I don't know" anymore?
|
# ¿ Jan 20, 2009 04:24 |
|
Ugg boots posted:What if you use the C shell (csh)?
|
# ¿ Jan 30, 2009 16:09 |
|
shrughes posted:That would be a std::map<std::string, T>.
|
# ¿ Feb 16, 2009 19:48 |
|
Ledneh posted:Brief googling says C, and that's what I suspect as well, but I just want to confirm. Wow, that's certainly an overlooked compiler warning.
|
# ¿ Feb 20, 2009 23:40 |
|
Speaking of string functions, I'm porting a side project that I started working on in OSX to Linux and I see that the strlcpy/strlcat functions don't appear to be in Interpid's glibc...any idea why this might be the case? Is this just an Ubuntu thing, or is it not to be found anywhere in Linuxdom? At school we had "STRLFOO(), NOT STRNFOO(), AND CERTAINLY NOT PLAIN OLD STRFOO(), YOU IDIOTS" beaten into us, and those machines were all running Linux, so maybe the functions were added in after the fact...? I'd make a disparaging comment about Linux, but I think I'll save that for YOSPOS.
|
# ¿ Feb 21, 2009 06:36 |
|
edit: Bah, missed the pagebreak; functional has said it all already.Vanadium posted:Check the declaration of x, then. What are you trying to do? It sounds like your design is rather awkward. edit: Now, are you trying to do something like: code:
Dijkstracula fucked around with this message at 17:19 on Feb 23, 2009 |
# ¿ Feb 23, 2009 17:14 |
|
I feel kind of bad for Manner Please; my compilers class was taught by a crunchy old Unix greybeard so we had no choice but to use lex and yacc and good old C, with none of this OO design pattern stuff. Is it typical for compiler classes to involve writing a lexer and parser instead of using preexisting tools? Why re-invent the wheel?
|
# ¿ Mar 17, 2009 17:58 |
|
code:
edit: If you make the correction, you'll see that diceRolls[35] is in fact 0. Also, using the debugger is better than sprinkling printfs around your code. Dijkstracula fucked around with this message at 18:13 on Mar 29, 2009 |
# ¿ Mar 29, 2009 18:06 |
|
If you're serious about wanting to learn the language, you should buy a book instead of relying on lovely and outdated web tutorials. See the first post for recommendations.
|
# ¿ Apr 13, 2009 19:09 |
|
Avenging Dentist posted:Also if you're actually going to try to determine where something segfaults, you should be using cerr instead of cout.
|
# ¿ Apr 19, 2009 23:15 |
|
Fehler posted:Yeah, but isn't that pretty limited in its functionality and/or has some weird license restrictions? (also, this is where I tell you that Win32 C++ development is infuriating and you really want to use C# instead )
|
# ¿ May 10, 2009 19:01 |
|
androo posted:I love working with arrays because they're so drat simple (and in terms of tiled 3D space, they're perfect for a beginner like me) but if you can tell me what you started picking up afterwords that would be sweet. quote:Or 4-dimensional, if I wanted to store a bunch of data for each cell? code:
What you want is closer to this: code:
|
# ¿ May 16, 2009 16:49 |
|
Avenging Dentist posted:Let's not forget system("pause");
|
# ¿ May 20, 2009 16:48 |
|
code:
|
# ¿ Jun 1, 2009 00:11 |
|
Yikes.Ledneh posted:(since you can't put std::strings in a union I guess)
|
# ¿ Jun 17, 2009 15:55 |
|
slovach, can you post some code? Give an example of a value that you assign, and the garbage that get written in, and the code that does it? There's not much to work with here.
|
# ¿ Jun 20, 2009 23:29 |
|
Adahn the nameless posted:I'm trying to write a program that reads an ASCII file and writes the same data to a binary file. Every time I run the program I'm getting a segmentation error, which I understand occurs when a pointer goes out of scope. What is source? What is designation? Are they opened correctly? Are you doing proper error checking when you open the streams/file descriptors? Have you run this through a debugger to pinpoint the line where it's crashing? edit: ah, didn't catch the missing addressof operator. Dijkstracula fucked around with this message at 21:51 on Jun 24, 2009 |
# ¿ Jun 24, 2009 21:46 |
|
The last time I looked at C++/CLI it was kind of a clusterfuck. If you're set on using .NET for the rest of the application, using a proper .NET language like C# with P/Invoke is the way I would go.
|
# ¿ Jul 2, 2009 20:55 |
|
Adhemar posted:A while loop you say? I never would have guessed. (I've seen this in code more times than I really should)
|
# ¿ Jul 4, 2009 04:04 |
|
Avenging Dentist posted:Just FYI, I work on a C++ compiler in my spare time, and I have read precisely one "book" on C++: the ISO standard. All of those other books are completely unnecessary in my opinion. I learned everything by writing code and looking at other people's code. A code reading thread with suggestions could actaully be interesting and enlightening.
|
# ¿ Jul 23, 2009 19:27 |
|
Avenging Dentist posted:What's the point? If you (the reader) can't tell when code is good, you're not going to gain anything by someone showing you code that they believe is good, unless you're seriously arguing that you should write code using the monkey-see-monkey-do pattern.
|
# ¿ Jul 23, 2009 20:35 |
|
The Good Professor posted:Hello, I hope you guys can help me. I'm learning C# as my first programming language (I have a friend who is helping me a bit, thus my choice) and I'm looking for a good book to get to help me learn it from scratch, especially regarding game programming, as I feel I've about reached the bounds of what I can teach myself without direction.
|
# ¿ Jul 29, 2009 14:45 |
|
does it throw the bus error immediately (ie. the first time through the loop) or does it get part way through the traversal before it crashes? Either way, it sounds like your routine for building your list is maybe stomping on memory somewhere, or something's misalligned, or something like that. (I would venture it's an x86 vs sparc issure as opposed to a Linux vs Solaris one.) edit: Do me a favour and set a breakpoint and inspect what listptr points to. If it's an invalid region of memory, it should say. Dijkstracula fucked around with this message at 03:47 on Aug 19, 2009 |
# ¿ Aug 19, 2009 03:44 |
|
In general, it's not a reasonable expectation, but in your case, it should be okay. On certain architectures, alignment requirements would pad out the array if sizeof(yourtype) wasn't a multiple of the alignment stride. However, since all those datatypes will be naturally 4-byte aligned (which is the only alignment that I've seen in use these days), that shouldn't pose a problem for you. If you know something about the compiler that will be used, you can use a directive like __attribute__ ((__packed__)) on a union, but I've never actually needed this, so I can't tell you how the behaviour would play on different architectures. Also scientific code
|
# ¿ Aug 19, 2009 21:03 |
|
BigRedDot posted:OH you don't even know. I mean, unless you do.
|
# ¿ Aug 19, 2009 21:26 |
|
6174 posted:Yeah, certainly alignment in general can't be assumed, but for the types in this particular union it seemed like a reasonable expectation. Honestly, if you test this with, say, gcc and icc, in 32-bit x86 and amd64/x86_64 envionments, I would say it's highly likely that it will work for the forseeable future.
|
# ¿ Aug 19, 2009 22:23 |
|
BigRedDot posted:LOL that's awesome, I hope that was 10 years ago.
|
# ¿ Aug 19, 2009 23:40 |
|
Vanadium posted:%s is for strings, not for int arrays. I am pretty sure there is no format specifier that lets you read multiple integers at once. code:
code:
|
# ¿ Aug 23, 2009 00:35 |
|
schnarf posted:You can read in a single integer, say, 12345, and use the modulus and integer division operators to read out digits. code:
code:
Dijkstracula fucked around with this message at 01:42 on Aug 23, 2009 |
# ¿ Aug 23, 2009 01:40 |
|
|
# ¿ May 17, 2024 16:29 |
|
HondaCivet posted:Is there a way to take in input without causing the program to hang? I'd like the program to check for input each time it runs through a loop but, of course, it waits for input instead of continuing through the loop. I'm using plain old cin (C++ here with Boost). What else could I do? 1) fork() a process to handle the network connection, using signals handlers to inform the child network process to terminate and clean up 2) use a threading library like pthreads or whatever Boost gives you, where you call [fixed]pthread_exit[/fixed} or whatever. (and the third, comedy option: 3) whatever crazy Boost poo poo there is (Is boost::asio still around? I still have nightmares from it; that poo poo was seriously my Vietnam.) ) I assume the problem you're trying to solve is "I'd like to include a little I/O on this thing so that transfer can be shut off with a text command." Any of those three solutions will work; beej has a pretty good Unix IPC guide if you want to go with 1). Dijkstracula fucked around with this message at 23:14 on Aug 26, 2009 |
# ¿ Aug 26, 2009 23:12 |