comp.lang.c http://groups-beta.google.com/group/comp.lang.c
Today's most active topics: * qsort - 12 new http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/2329e52e47f51f82 * register variable - 12 new http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/c8ebfc97ce3d1f0d * memcpy as macro legit? - 10 new http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/4af54b08a4d427b2 * call to malloc with size 0 - 9 new http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/ac4d191d274907c6 * Micro-C -- Help monitoring a switch on 8051 - 8 new http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/b1bc31cea3a6482d Active Topics ============= i need help with this card game! - 4 new ---------------------------------- ... Specifically since Knuth states that the MSB should be used lest the LSB may suffer from (unwanted) regularities. Knuth TAoCP, vol II. ... - Fri, Nov 19 2004 1:08 am 4 messages, 4 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/f99746be0e7010af Micro-C -- Help monitoring a switch on 8051 - 8 new ---------------------------------- ... That's completely off-topic here. This group is about the language C, not how to use it for dealing with some micro-controller. But since there's quite a number of C issues with your code I will comment on this. ... Hopefully, this is a standard compliant C compiler, otherwise you won't get help here. Find a group that deals with issues of your compiler if you get problems there. And, if that is possible, make your compiler emit as many warnings as possible, you're probably going to be surprised... ...... - Fri, Nov 19 2004 1:22 am 8 messages, 5 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/b1bc31cea3a6482d Initializing array of structure!! - 6 new ---------------------------------- ... In your posted code, you seem to know the element count (30). ... You're initialization technique works, but you've incorrectly declared your array. See below. Also, make sure to include this: ... Change that to: struct myarray *MYARRAY = malloc(sizeof(MYARRAY) * 30); [snip] ... - Fri, Nov 19 2004 1:23 am 6 messages, 4 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/730fd5676f6a6ba memcpy as macro legit? - 10 new ---------------------------------- I just noticed that doing something like the following may fail because it can overwrite u->size before it's evaluated. memcpy(u, buf, u->size); Is it legit that this is a macro as opposed to a function that would not clobber the parameter? Just surprised me a little is all. Mike ... - Fri, Nov 19 2004 1:27 am 10 messages, 7 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/4af54b08a4d427b2 Tool for buffer overflow prevention - 2 new ---------------------------------- ... The answer would depend on the implementation that you are using. If you are using GNU C/C++ mtrace utility can really help you to prevent buffer overflow. There is ElectricFence that can help you identify on most GNU systems as well. ... - Fri, Nov 19 2004 1:30 am 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/da2a6fd70c107112 Question about setjmp on Itanium HPUX. - 3 new ---------------------------------- ... No such header in ISO C. Use instead. ... This is correct. ... * Kablooie!* Yes, that was the sound of the alignment of your struct being blown to bits. You do not know that a jmp_buf needs to be aligned on 8 bytes or a whole fraction of 8 bytes. You do know that the pointer returned from malloc() is correctly aligned for all types, including jmp_buf and your struct. Therefore, you do not know that (that pointer+8 bytes) is correctly aligned for either. And _that_ means that... ... ...passing this quite probably incorrectly... - Fri, Nov 19 2004 2:27 am 3 messages, 3 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/d2ba06fe57d25c4e qsort - 12 new ---------------------------------- ... ... ... OK, it is required in C99. Very strange though, it potentially reduces the efficiency of the implementation for no obvious benefit. Lawrence ... - Fri, Nov 19 2004 2:48 am 12 messages, 4 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/2329e52e47f51f82 char vs int - 4 new ---------------------------------- ... ... ... Yes int * and int * are different types. You can't assign one to the other and doing so wouldn't make a lot of sense. One can point to objects of type int, the other to objects of type int **. Lawrence ... - Fri, Nov 19 2004 2:56 am 4 messages, 4 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/513350d660d42aa4 How to read data ? - 5 new ---------------------------------- On 18 Nov 2004 20:10:26 -0800, in comp.lang.c , [EMAIL PROTECTED] ... only if the number of commas is correct..... ... No decent /C/ programming book will cast malloc. C++ ones will, because you require the cast in C++ but then thats a different language. ... read and will help you. Thanks to Ben for making his comments so easily available. ... It will be in your helpfile/ manual/manpages. ... you know how many integers you read, so malloc an array of doubles large enough, loop over the first array copying the... - Fri, Nov 19 2004 3:36 am 5 messages, 4 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/a69e10059208d734 C/C++ code beautifier - 2 new ---------------------------------- In message , E. Robert Tisdale trolled ... bool same(std::string a, std:: string b); assert(same("Stroustrup", "Ritchie")); Yeah, right. ... - Fri, Nov 19 2004 3:43 am 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/acd7f8376b921f9 How to best parse a CSV data file and do a lookup in C? - 4 new ---------------------------------- ... ... Here's a program that should do the trick (well, modulo reading a whole line and building an array of product IDs, but that's not what seems to be needed when I go by your Perl code). One restri- ction is that the maximum length of the items you try to read is known in advance (to be adjusted via the MAX_FIELD_WIDTH macro). Second restriction is that it won't work correctly in all cases if the last line doesn't end with a newline. Third restriction is that no additional whitespace is supposed to appear anywhere in... - Fri, Nov 19 2004 4:00 am 4 messages, 4 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/86a3ddf0724d9630 a[3] <===> *(a + 3) ??? - 8 new ---------------------------------- ... Assuming A is not a macro, they should be exactly the same. In addition 3[a] is also the same. ... - Fri, Nov 19 2004 4:27 am 8 messages, 6 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/12202735902b4eac homework problem - 2 new ---------------------------------- Merrill & Michele scribbled the following: ... Merrill & Mitchelle, although this latest attempt is quite good, do you think you could possibly try making even less sense? There's still a chance someone might understand something that you're trying to say. ... - Fri, Nov 19 2004 4:28 am 2 messages, 1 author http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/a6d5cc60dffdcbfd Synopsis, please! - 6 new ---------------------------------- Suggestion to group: Let's have Dan and Keith summarize the month's "going's on" and write a synopsis. I have to work so much more lately, that I can't keep up. Can we just have a "Point - Counterpoint" once a fortnight, to keep me up on "important" issues? Just asking.... ... - Fri, Nov 19 2004 5:38 am 6 messages, 5 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/8d5baf97aa173dda call to malloc with size 0 - 9 new ---------------------------------- ... ... It's the same as with pointers pointing one past the last element of an array. They're "valid" only in the sense that assigning, converting or comparing them for equality works normally, but they cannot be dereferenced. Whether they point to a valid memory location is up to the implementor (have a look at Electric Fence to see how an implementation can create invalid memory locations having valid memory addresses). ... If the standard says that a pointer value cannot be used to access an object, attempting to do so results in... - Fri, Nov 19 2004 5:17 am 9 messages, 5 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/ac4d191d274907c6 how to pass a two-dimension array to a function in C++?? - all new ---------------------------------- ... void gets_passed_2d_array( double x[ ][ COLUMNS ], ... int main( void ) { double a[ ROWS ][ COLUMNS ]; size_t i, j; for ( i = 0; i < ROWS; i++ ) ... gets_passed_2d_array( a, ROWS, COLUMNS ); return EXIT_SUCCESS; ... void gets_passed_2d_array( double x[ ][ COLUMNS ], ... size_t i, j; for ( i = 0; i < nrows; i++ ) ... Or what exactly are you looking for?... - Fri, Nov 19 2004 7:05 am 1 message, 1 author http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/8434fdcf1e1a9064 ANN: xcpp C preprocessor now available - 4 new ---------------------------------- On Sun, 14 Nov 2004 14:48:09 -0800, Ben Pfaff ... It also fails if the other headers declare intmax_t, for instance by pulling in types.h which pulls in stdint.h. I've got round that one (gcc 3.3 under Cygwin, for example) by doing the horrible ... But that is nasty. And just because a compiler is C 99 standard it doesn't mean that the library is (Cygwin, for example, doesn't have strtoimax or the j length format specification). I don't see any way round it except by having the person installing it edit make flags (or... - Fri, Nov 19 2004 6:39 am 4 messages, 2 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/7302d526ed70110a register variable - 12 new ---------------------------------- ... ... It warned you that your code is breaking the restrictions imposed by the C standard. Isn't that good enough for you? ... As a general rule, there is no point in executing C code violating the C standard, unless the effects of the violation are well documented by another standard relevant to your implementation. ... It is entirely pointless to speculate about the behaviour of code requiring a diagnostic: it is not valid C code and the standard doesn't specify its semantics. No sensible compiler would allocate such a ... - Fri, Nov 19 2004 7:10 am 12 messages, 7 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/c8ebfc97ce3d1f0d Typedef with GCC/G++ - 2 new ---------------------------------- ... Engage your brain. If gcc accepted your code, it is quite likely that it is correct C code, right? If g++ rejected your code, it is quite likely that it is incorrect C++ code, right? Since it doesn't make much sense to ask "why is this correct code C code", your question actually amounts to "why is this incorrect C++ code?". But what's the point in asking such a question in a C newsgroup? Dan... - Fri, Nov 19 2004 7:20 am 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/57cceab6ca5afdf0 getting variable type in C - 2 new ---------------------------------- ... True. The GNU C feature for runtime type testing is the function __ builtin_types_compatible_p(type1, type2) and not the typeof operator. It is impossible to implement things like without this kind of tool. And it's quite handy for writing your own type generic macros, but, unfortunately, the C standard doesn't also provide the tools required for implementing its own headers. ... Not true when implementing macros with parameters. ... typeof is a must for any *decent* type generic macro needing temporary... - Fri, Nov 19 2004 8:11 am 2 messages, 1 author http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/3c5bebf4c0625e0b fast array copy - all new ---------------------------------- ... No, arrays are not pointers. This will not work. Even if you change the array to be a pointer to an array to make it work, you will probably find that the allocation/deallocation takes more time than simply copying the array. Is the size of the array constant? Then just keep two of them, and use a pointer to an array to swap between them each time you do an update. DrX ... - Fri, Nov 19 2004 8:22 am 1 message, 1 author http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/e6036b4e733b6e1a Getting time in milliseconds - all new ---------------------------------- ... Richard's not off-topic. He's pointing out that Ranjeet's answer is non- standard and not useful for some conforming C implementations. That's entirely on-topic for comp.lang.c. ... - Fri, Nov 19 2004 8:19 am 1 message, 1 author http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/565dd04823f976b2 COMP3 Packed Decimals - all new ---------------------------------- ... I debated that myself. In the end I chose to go with this ordering because it's parallel to strncpy et al: destination, source, max bytes to copy. But I'm not wedded to it, and if there were more than these three parameters I'd put BufSize next to Packed. ... Yes, an extra set of parentheses wouldn't hurt there. (I haven't seen any reply from the OP. I wonder if he's still reading?) ... - Fri, Nov 19 2004 8:37 am 1 message, 1 author http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/7cc0d788ae29187 Bus Error asprintf. OS X 10.3.6. gcc 3.3 - 7 new ---------------------------------- Hi, I don't seem to be able to get asprintf to work when compiling under OS X. Using the following code: ... int main() { char **w; asprintf(w, "fooo"); printf("%s\n",*w); return 0; ... and compiling using gcc with the -lc and -Wall flags, I get no erros. The program runs spitting out a Bus Error. The same code on a Linux machine gcc 3.2.2 compiles and runs as expected. Any help would be great. Neil ... - Fri, Nov 19 2004 9:18 am 7 messages, 4 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/c3dc7ee1e05d7918 Memory allocation by malloc - all new ---------------------------------- ... That's certainly one possible definition of "pun", but in rhetoric and poetics technical definitions of "pun" rarely restrict the trope ... Puns come in so many different forms that one scholar (Walter Redfern, _Puns_) confesses at the beginning of his book that he gave up trying to identify the separate species. (_A Handlist of Rhetorical Terms_, 2nd ed, 127) Among the examples Lanham cites to illustrate the pun is JFK's infamous "Ich bin ein Berliner", which is a grammatical pun, not one of pronunciation (and an inadvertent one at... - Fri, Nov 19 2004 8:59 am 1 message, 1 author http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/ccf7007aa81f1932 Core + malloc - 2 new ---------------------------------- Hi all...now i'm working in a little society and the first thing i've seen is a lot of file c and pc. But sometime happens....this application load in memory through a list of pointers more information..but now the question....we have modify somtething...and, sbrrrraaaaa...i receive a file core... and so the question....the memory allocated with malloc (used to expand the list), when received a core file who release the memory in particular the system call free() function before terminate the application ?... - Fri, Nov 19 2004 10:44 am 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/2c9fe5b7a1c1a832 Learning C from old books ?? - 2 new ---------------------------------- Wow c64, those are the magic words Jhon. I still fire up my old c64 box now and then, like visiting an old friend. My copy of "Mapping the Commodore 64" still sits undisturbed next to Art Margolis' Troubleshooting & Repairing your C64 with lots of bookmarks sticking out the top. Ah, those were the days, when machine language was the only viable design option. This stuff is ancient, but then so am I. Remember the punch card days and vacuum tube, block-long monsters with 16K of iron core memory? My "Univac Programmer... - Fri, Nov 19 2004 1:12 pm 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/187ec3296ad0ead9 strlen in a for loop with malloc-ed char* - 2 new ---------------------------------- On 17 Nov 2004 22:57:30 GMT ... To the OP (I'm sure Chris knows this), something more meaninful and less likely to clash with other code than my_ would be better. For instance, where I work we have a library where everything (not just alternatives to standard library functions) is prefixed by"ff" which is short for ForFront, the company which originally wrote the stuff. This includes wrapper functions ffmalloc, ffcalloc, ffrealloc, fffree and losts of others. The might conflict with a library be Mr Fred Furnackapan, but... - Fri, Nov 19 2004 4:36 am 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/eb0a87eda9aa95e6 Learning C - all new ---------------------------------- Thank you everyone and AHHHHHHHH!!! btw, there were no compiler warnings. I am using Bloodshed Software Dev-C++ 4 compiler. Also, the only reason I'm using this book is because I found it hanging around in my house. ...... - Fri, Nov 19 2004 1:49 pm 1 message, 1 author http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/7c3b9722743bd9e Please spot out the cause of this bug - 2 new ---------------------------------- I am writing a program that will take a string that has a C source file and it would format all the multi-line comments like these: //Jingle bells, jingle bells, jingles all the way //O what fun it is to ride in a one-horse open sledge //yeah, jingle bells.... into /*Jingle bells, jingle bells, jingles all the way O what fun it is to ride in a one-horse open sledge yeah, jingle bells....*/ or the lines, i=0; //Isn't it nice //today? hehehehe.... into i=0; /*Isn't it nice today? hehehehe...*/ The code can be downloaded from here. ... - Fri, Nov 19 2004 3:25 pm 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/30f63901e0c15a48 Handling text with C? - all new ---------------------------------- Groovy hepcat Tatu Portin was jivin' on Tue, 16 Nov 2004 18:56:09 GMT in comp. lang.c. Handling text with C?'s a cool scene! Dig it! ... If that's all you want to do, then it's very easy. All you have to do is read the file, one line at a time, perhaps using fgets(), output the lines you want and discard those you don't. ... - Fri, Nov 19 2004 4:33 pm 1 message, 1 author http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/fc662b477263b5f6 Definition of NULL - all new ---------------------------------- Groovy hepcat Jason Curl was jivin' on Tue, 16 Nov 2004 18:47:59 +0100 in comp. lang.c. Definition of NULL's a cool scene! Dig it! ... It's really very simple. You're probably confusing three things, which is a very common error. 1) A null pointer is a pointer guaranteed not to point at an object or function. The actual representation of a null pointer is not specified. 2) A null pointer constant is a constant of type int with a value of 0 or such a constant cast to void *. In a pointer context it is converted to a null pointer.... - Fri, Nov 19 2004 4:33 pm 1 message, 1 author http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/6c604861d0d193ac Question about storing a maze board(like 2d array) into Tree. - 2 new ---------------------------------- I need to build the maze board(like 2d array) using a tree. But I find that my buildTree function doesn't work. Could anyone give me some hints on debugging it? Thanks bool BuildTree(TreeNodePtr *T, int x, int y) { if (boardSize == 0) //boardSize is a global variable { return TRUE; ... { if (x > boardSize || y > boardSize) { return FALSE; ... { TreeNodePtr p = (TreeNodePtr)malloc( sizeof(struct TreeNode)); p->left = NULL; p->right = NULL; p->data.x = x; p->data.y = y; p->data.type = GetStepType(itemList, x,... - Fri, Nov 19 2004 6:57 pm 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/3355ffa7be5f95d5 versions - all new ---------------------------------- Hi, There are many versions of C and C++ built by many different companies. So, which version : 1. more easier to learn 2. more easier to remember 3. more easier to debug 4. helps me find errors fast and professionally 5. more portable 6. has the biggest community 7. has more tutorials widely available 8. has its source code all over the internet 9. and so on If C++ is an extension of C then why isnt it called the new version of C instead of having a different name ? And, why isnt it called C+ instead of C++ ?... - Fri, Nov 19 2004 8:08 pm 1 message, 1 author http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/2740c0f0a4b9802f ======================================================================= You received this message because you are subscribed to the Google Groups "comp.lang.c". comp.lang.c http://groups-beta.google.com/group/comp.lang.c Change your subscription type & other preferences: * click http://groups-beta.google.com/group/comp.lang.c/subscribe Report abuse: * send email explaining the problem to [EMAIL PROTECTED] Unsubscribe: * click http://groups-beta.google.com/group/comp.lang.c/subscribe ======================================================================= Google Groups: http://groups-beta.google.com
