|
fret logic posted:Only returns the first character you enter. I thought that with the while loop, it does the first statement, you hit enter, then it does "putchar(c)", but I don't understand why it's holding the entire string of characters. Sorry if this is incredibly obvious Use Control-D to send an EOF character. (In Linux, at least) The reason it looks like it's holding the entire string in memory is because stdin is line-based -- nothing is sent to the program until you press Enter. You type in the line of text, and the program then processes that line, one character at a time. Scaevolus fucked around with this message at 06:24 on Feb 28, 2008 |
# ¿ Feb 28, 2008 06:20 |
|
|
# ¿ May 3, 2024 22:15 |
|
fret logic posted:How is this different from the one without the loop? It'll let you type in an entire string, but only returns the first character. Are you saying that once you hit enter, it repeats the loop for each character in the line? I guess I'm not understanding how the loop affects the process. Here's how it works: You: Start program Program: Initialize, getchar() [Now the program is waiting for input, and is idle] You: Input text, [enter] [Now a line of input has been entered, and the program's getchar() finally returns a value] Loop version: --Program: Print character, getchar() Without loop: --Program: Print character, exit
|
# ¿ Feb 28, 2008 06:37 |
|
illamint posted:the regular expression "^([A-Za-z0-9]+),([A-Za-z0-9]*),([A-Za-z0-9]*),(s?f?|f?s?);$"), Do all the lines in the file match this? If so, a regex is overkill. vv also overkill. Writing a DFA for this would be very easy. Scaevolus fucked around with this message at 02:19 on Mar 7, 2008 |
# ¿ Mar 6, 2008 23:43 |
|
Thug Bonnet posted:No, that's what I'm asking! I'm just kind of curious, honestly. But how would the program know "where it is" in memory, how large it is, etc. Also, I assume it's not necessarily contiguous.. It depends on the OS. On Linux, /proc/<pid>/ contains a lot of this information, with the files maps and smaps being particularly interesting.
|
# ¿ Mar 10, 2008 22:51 |
|
Thug Bonnet posted:No, that's what I'm asking! I'm just kind of curious, honestly. But how would the program know "where it is" in memory, how large it is, etc. Also, I assume it's not necessarily contiguous.. It depends on the OS. On Linux, /proc/<pid>/ contains a lot of this information, with the files maps and smaps being particularly interesting. Example /proc/.../maps file: code:
Scaevolus fucked around with this message at 23:10 on Mar 10, 2008 |
# ¿ Mar 10, 2008 22:55 |
|
floWenoL posted:What is this "typing-time"? typing-time: code:
code:
|
# ¿ Mar 16, 2008 06:32 |
|
elevatordeadline posted:Teach me about 64-bit integers in C. #include <stdint.h> This gives typedefs that include number of bits, like uint8_t for unsigned 8-bit integers, and int32_t for signed 32-bit integers. Only up to 32 bits are required, but your implementation might have int64_t and uint64_t.
|
# ¿ Mar 20, 2008 22:08 |
|
elevatordeadline posted:Those numbers are not the same numbers at all. Works for me on x86_64 ( native 64-bit integers), gcc version 4.2.3 code:
|
# ¿ Mar 20, 2008 23:12 |
|
fret logic posted:Yeah I know that much, I just haven't found the basic idea behind the graphics in that game, graphics that for some odd reason I really enjoy. If you want to examine a simpler game using ncurses, read the source code for bombardier. If you want something shinier, SDL is probably a better choice than GLUT.
|
# ¿ Apr 1, 2008 03:20 |
|
TurtleBoy posted:this sounds like what I am looking for. Scaevolus fucked around with this message at 05:07 on Apr 2, 2008 |
# ¿ Apr 2, 2008 02:34 |
|
Morgen posted:attributes.txt code:
&L[2] is the same thing as L+2, but I think the first is clearer. Scaevolus fucked around with this message at 19:23 on Apr 6, 2008 |
# ¿ Apr 6, 2008 19:16 |
|
Morgen posted:I can't seem to make it work, it gives me a runtime error. Am I missing something important? Well, I did omit "#include <stdio.h>" from the first line.
|
# ¿ Apr 7, 2008 01:06 |
|
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... If so, it's trivial to implement your own vector class that has three elements. Liberal use of "const" in function prototypes for it will help your compiler optimize it.
|
# ¿ Apr 24, 2008 22:43 |
|
ruden posted:As to how I'm drawing it, basically it's nested for loops with graphics.DrawLine() functions. I'm not sure how C++ interprets that exactly, but I'm not drawing pixel for pixel. I'm only using black and white, so color is a minimum too. And is it impossible for this to be done in sections because parts of the image reference other parts? (Which fractal are you drawing?) crazypenguin posted:I *think* gimp handles large files pretty well... No, it doesn't. Try creating a 20,000x20,000 image if you don't believe me. Scaevolus fucked around with this message at 18:21 on Apr 28, 2008 |
# ¿ Apr 28, 2008 18:14 |
|
ruden posted:Ok, I made the PS file of the image. This is the situation as it stands: Look up line-drawing algorithms. You could initialize a 12GB raw image file with zeros, then draw lines by doing file seeks and writes. It wouldn't be pretty, and it might take a very long time, but with good filesystem caching it might be manageable.
|
# ¿ Apr 29, 2008 04:53 |
|
Assuming each single byte write takes 1/10,000 of a second, and other processing time is negligible, it would only take a week, if 50% of the pixels are filled. This is the sacrifice one must make for 1400 DPI.
|
# ¿ Apr 29, 2008 05:14 |
|
Sarah Sherman posted:Birthday Paradox
|
# ¿ May 12, 2008 04:08 |
|
Avenging Dentist posted:
code:
Macros are annoying.
|
# ¿ Jul 7, 2008 23:36 |
|
Evil Robot posted:Although anyone who argues against this style of function definition or loop formatting can go straight to hell, the fuckers:
|
# ¿ Jul 14, 2008 08:44 |
|
litghost posted:Software I worked on knows if endian-ness is swapped by checking known fields. Example, the month as a 32-bit integer. It should never be 0, and will not be greater than 12. If you read it as 213134142 or something, swapped endian-ness. This will only work if you can find a piece of data like this. We just fixed a bug where the date was set to 0/0/0 and it broke the endian swap code, so this is fragile. However, it is better than nothing. Why not just include a flag in the binary data that defines endianness? edit: maybe I should refresh before posting
|
# ¿ Aug 1, 2008 04:29 |
|
ehnus posted:I'd be willing to bet that due to member padding within data types that the savings you see by narrowing those types won't actually be realized If your "optimization" causes a bunch of warnings, saves less than 1KB of RAM, and is probably slower, it's not worth it.
|
# ¿ Aug 18, 2008 02:08 |
|
Avenging Dentist posted:I was messing around today and I realized that you can make template unions. C++: "I can't think of a use case right now, but maybe it will be helpful later. Put it in the standard."
|
# ¿ Aug 26, 2008 02:33 |
|
ShinAli posted:Got a quick question about pointers in C.
|
# ¿ Oct 9, 2008 04:35 |
|
pintle posted:At about iSize at 700, it started to crash. When I debugged, it gave me an "Out of Memory" on the 4th call of that function. I am, however, calling and passing these structs around. Could it be something about the STACK size? This probably won't fix your problem, but are you remembering to free the arrays before allocating new ones?
|
# ¿ Nov 15, 2008 19:35 |
|
Avenging Dentist posted:Especially since He probably got confused by the warnings compilers emit when there's a non-void function without a return statement.
|
# ¿ Feb 2, 2009 06:41 |
|
Probably to thwart EVIL THIRD-PARTY COMMERCIAL TOOLS.
|
# ¿ Sep 3, 2009 00:07 |
|
Kreez posted:
|
# ¿ Sep 20, 2009 01:46 |
|
Kreez posted:Cool, %lf works great, thanks.
|
# ¿ Sep 20, 2009 02:31 |
|
You need to implement the assignment operator.
|
# ¿ Dec 5, 2010 08:48 |
|
Safe and Secure! posted:Is anyone here familiar with all of these books? C++PP just seems like such a huge book compared to The C Programming Language, but The C++ Programming Language isn't any better in that regard. Is C++ just an incredibly "large" language or what? Accelerated C++ is another commonly suggested introductory book, followed by Effective C++.
|
# ¿ Dec 8, 2010 09:17 |
|
CapnBry posted:Here is something to test your pedantic C knowledge:
|
# ¿ Jan 25, 2011 19:53 |
|
Paniolo posted:I would guess because their use case for protocol buffers involves data transfer via HTTP or other text-based network protocols where the data needs to be encoded in a way that allows it to be represented as a string (i.e. no null bytes.) http://stackoverflow.com/questions/2037155/stdstring-as-c-byte-array posted:Google's Protocol buffer uses the C++ standard string class std::string as variable size byte array (see here) similar to Python where the string class is also used as byte array (at least until Python 3.0). Scaevolus fucked around with this message at 19:12 on Feb 6, 2011 |
# ¿ Feb 6, 2011 19:09 |
|
shrughes posted:Since 2016 doesn't fit in a byte, this takes a longer instruction, and probably a more expensive instruction, than one that writes to %rax+32. It's certainly a different instruction. Wouldn't they probably be the same size when converted to uOps?
|
# ¿ Feb 15, 2011 04:36 |
|
Speculating about a test like this without actually reading the assembly is pointless.
|
# ¿ Feb 15, 2011 05:10 |
|
Otto Skorzeny posted:So you learned your lesson from the minecraft project I was running tests, and reading the assembly.
|
# ¿ Feb 15, 2011 07:17 |
|
roomforthetuna posted:The idea is that a single instruction is functionally treated the same as a squiggly-brackets-enclosed block containing a single instruction. An "if" is basically a single instruction to conditionally execute another block. Why did I not realize this before?
|
# ¿ Feb 23, 2011 00:17 |
|
Unless you're reading/writing the matrix to the disk (a lot), you probably don't want to use mmap. Quadtrees might be useful for implementing sparse grids.
|
# ¿ Feb 26, 2011 11:04 |
|
OpenGL contexts can only be used in the thread where they were created. If that destructor is doing something like freeing texture bindings from a thread other than where they were initialized, you might be seeing errors.
|
# ¿ Jan 22, 2012 17:24 |
|
shodanjr_gr posted:I'm involved in a project that requires targeting Android and x86 Windows. The application would need OpenGL support with shaders and multitouch functionality. Other niceties (like GUI widgets) would also be nice. MoSync seems to at least be an attempt at what you're describing.
|
# ¿ Feb 4, 2013 10:43 |
|
|
# ¿ May 3, 2024 22:15 |
|
pseudorandom name posted:Nope. volatile is for memory mapped IO, it isn't sufficient for inter-thread communication. Scaevolus fucked around with this message at 11:31 on Feb 15, 2013 |
# ¿ Feb 15, 2013 11:28 |