comp.lang.c http://groups-beta.google.com/group/comp.lang.c
Today's most active topics: * Arraym malloc() and free() question - 12 new http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/6c0e0b0f81ee43bf * The C language on Mars - 11 new http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/40888ed3d75514c8 * convert 'C' code to 'Fortran' - 7 new http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/7d307a1eec1f217a * special character to strings and vice versa - 7 new http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/a42ff926b12a9709 * printing a pointer's value - 6 new http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/87aa9d1f6665d1db Active Topics ============= Arraym malloc() and free() question - 12 new ---------------------------------- On Wed, 10 Nov 2004 06:44:45 UTC, [EMAIL PROTECTED] (Martin Andert) wrote: . .. casting the result of an function returning a pointer to void invokes undefined behavior as it hides the possible error that there is no prototype of the function known to the compiler. ... same as above. this produces clearly a memory leak as the reference to the memoty block allocated prior gets lost. ... It gets still lost - but the block itself lefts allocated, producing a memory leak. ... No. ... - Thurs, Nov 11 2004 2:01 am 12 messages, 7 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/6c0e0b0f81ee43bf The C language on Mars - 11 new ---------------------------------- There was a discussion some weeks ago about the C language being "dead", where Mr Tisdale, as far as I know a NASA employee, participated telling us that he is waiting for C programmers to die off. I have recently started to browse through the "MER analyst notebook" ( http://anserver1.eprsl.wustl.edu/ ). MER stands for Mars Exploration Rover, the two spaceships that NASA sent to Mars. In the logs of the activity we find lines like: 232 command 2004-114T16:32: 45.289 136010002.844 2004-115T05:32:15.245 88025... - Thurs, Nov 11 2004 2:49 am 11 messages, 10 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/40888ed3d75514c8 address of a statement in C - all new ---------------------------------- ... "True during every test of the loop condition" is not the same as "true at all times in a loop", right? I hadn't thought of the "true during every test . ..." definition, but it does seem to be consistent with the usual definition ( something that, if true before execution of the loop body, is true still/again after execution of the loop body). ... Seconded, or something. ... - Thurs, Nov 11 2004 3:03 am 1 message, 1 author http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/9c7bf5671accbcf6 why char *p = "can not modiy"; char p[] = "can modify" - 2 new ---------------------------------- On Wed, 10 Nov 2004 22:50:17 UTC, Mark McIntyre ... No it points nowhere as p is not a pointer. p is an array of char in the length of the given string including a null byte. ... No, not really. p[0] is the first byte of an array of char, not a string literal. ... no pointer in sight. A string literal is NOT a pointer - but can be handled as if it were in assignents. An array is NOT a pointer - but can be handled as if it were in assignments. Even as the compiler will decide to handle the name of an array ... - Thurs, Nov 11 2004 3:04 am 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/590bb89a41716dd1 write 2D array to binary file - 2 new ---------------------------------- On Wed, 10 Nov 2004 23:16:52 UTC, [EMAIL PROTECTED] (Betty ... You don't create a 2 dim. array. You creates an array of pointers to arrays of shorts. In that case you should write/read eaxch array of short separately to/from file. to create a 2 dim array you would use short *p = malloc(nrows * ncols * sizeof(*p)). Then you have a real 2 dimensional array that you can address like p[row][col] and handle as whole in read/write operations. ... - Thurs, Nov 11 2004 3:13 am 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/bbf704c50e884de7 Interesting coding idea - all new ---------------------------------- Thad Smith schrieb: ... I suddenly understand that postconditions have a value that goes beyond helping human readers and error detection in the postconditioned module itself. ... I understand that. I think "Design by Contract" ought to help here. ... I believe that's why the assertions get their own section in a function definition in some languages. Mind you, I'm no evangelist, in fact, I've never used a language that had contracts designed into it from the outset (Eiffel comes to mind), but they seem to be naturally suited if you... - Thurs, Nov 11 2004 3:26 am 1 message, 1 author http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/e611d0a5242f22c0 Float point comparison-Newbie - 5 new ---------------------------------- On Thu, 11 Nov 2004 02:30:10 UTC, [EMAIL PROTECTED] (prashna) wrote: .. . There is the problem that an floating point is never prezise enough to hold and coparsion to 0.0 exactly as expected. You should define a delta that is near 0 and test that the variable is inside that delta, meaning it is nearly, but not exactly 0 when it is inside and not 0 when it is outside the delta. To calculate monetary values you should avoid using float/double anyway as this types are too far from to be exact from that in any ... - Thurs, Nov 11 2004 3:30 am 5 messages, 5 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/53ed451b64e71eb5 using volatile ptrs ... - 3 new ---------------------------------- ... As others have indicated this is not valid C, you need an explicit cast to convert an integer to a pointer. The result in this case won't be portable. .. . This is a level of detail that the C language doesn't cover. volatile has a couple of uses in standard C, e.g. in relation to signal handlers and sig_ atomic_t. However it is commonly used in platform-specific extensions to the language (e.g. threading). The basic idea is that it indicates that an object can be accessed asynchronously e.g. from a different... - Thurs, Nov 11 2004 4:32 am 3 messages, 3 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/ee0d0fd6df1c903 convert 'C' code to 'Fortran' - 7 new ---------------------------------- ... I'm skeptical that optimization is a good reason to convert C to Fortran. Leaving pointer issues aside (and I think recent versions of Fortran have something similar to pointers), automatically generated Fortran is likely to be ugly and difficult to optimize. If you want to be able to maintain the Fortran code, the best tool for the job is probably a programmer who knows both C and Fortran and is willing to do it for what you can afford to pay. ... - Thurs, Nov 11 2004 4:54 am 7 messages, 4 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/7d307a1eec1f217a special character to strings and vice versa - 7 new ---------------------------------- ... ... How does it remain in libraries? Do the standards people ever decide that a function should be removed from all implementations to be compliant? ... - Thurs, Nov 11 2004 5:14 am 7 messages, 6 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/a42ff926b12a9709 Crazy stuff - all new ---------------------------------- ... ... ... ... It doesn't. I guess this goes back to the days when C didn't have a void type. Also just reaching the end of the function doesn't invoke undefined behaviour, in the words of C99 6.9.1: "If the } that terminate a function is reached, and the value of the function call is used by the caller, the behavior is undefined." In C90 you can also use return; i.e. with no expression in a function with a non-void return type. C99 makes this a constraint violation but still allows falling off the end of the function.... - Thurs, Nov 11 2004 5:13 am 1 message, 1 author http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/3bdab6e630859d59 Does this invoke undefined behavior? - 2 new ---------------------------------- I had a problem going from gcc 2.96 to gcc 3.2.3 and narrowed it down to the following code. The question is whether the problem is undefined behavior on the code's part or a compiler bug. ... struct frob { char a; int b; ... static struct frob *test; int frobit(void) { const char *move_things = malloc(10*sizeof(struct frob)); struct frob *tmp = realloc(test, 1000* sizeof(struct frob)); move_things = move_things; if (tmp == NULL) { ... test = tmp; return 11; ... int main(void) { int i; test = malloc(10 * sizeof(struct frob));... - Thurs, Nov 11 2004 5:48 am 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/81c78780fab94653 Please review - 2 new ---------------------------------- ... <snip> ... <minor nitpick> Does "struct my_struct_t" not suggest a type, which it isn't? Would naming it "my_struct_s" not be better? </minor nitpick> ... - Thurs, Nov 11 2004 6:57 am 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/c252fbe59cd39db0 printing a pointer's value - 6 new ---------------------------------- ... printf ("value = |%d|\n", *zp); ... - Thurs, Nov 11 2004 7:43 am 6 messages, 6 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/87aa9d1f6665d1db derangement: coding review request - 3 new ---------------------------------- ... That didn't rankle. It was the "annoying, inane white noise" that go my dander up. MPJ ... - Thurs, Nov 11 2004 8:06 am 3 messages, 2 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/63c5271ccb9149a C NEWBIE - 2 new ---------------------------------- ... Your response reminds me of that apocraphyl little story which goes something like :- An experienced pilot and young co-pilot in a helicopter flying across Seattle and suddenly all their navigation goes out. The young co-pilot didn't know what to do; the experienced pilot said fly to that tall building and hover there. He wrote in large letters on a piece of paper " WHERE ARE WE ?" and held it up to onlookers in the building; the people inside rushed to a desk and returned with a piece of paper which said "IN A... - Thurs, Nov 11 2004 8:08 am 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/a7fd82ca6b0797eb Sprase matrix - 5 new ---------------------------------- Hello everybody, I am student who just begin learning about programming I want to know what is Sprase Matrix. And would you please show me how to add the 2 Sprase Matrix in C soursecode. ... - Thurs, Nov 11 2004 8:55 am 5 messages, 5 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/6cb646efd59ed710 Obfuscate C tricks - 6 new ---------------------------------- I have been looking at the winning entries for the International Obfuscated C Contest (Shame I missed it till it had closed, well next time I will get an entry in) and I was wondering if anyone has any good suggestions for tricks that can be used to Obfuscate C code. * Some trick that I like to use include the following. a^=a; instead of a=0; 5[b]; instead of b[5]; and of course a=(!(a^a))?1:0; instead of if (a) { ... * Before people take great delight in flaming me for posting this I would... - Thurs, Nov 11 2004 9:06 am 6 messages, 5 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/20eafe92fac9409c Getting time in milliseconds - all new ---------------------------------- ... "Usenet Best Practices" is open for comment. The IETF commenting process is well documented; see www.ietf.org. Those who care about this sort of thing might wish to investigate it, since that would be the ideal way to affect any RFC that develops from this draft. Personally, I find lines containing only a quote marker (or even multiple levels of quote markers) are adequate as vertical white- space for my reading, which is why UBP's recommendations don't worry me. On the other hand, since I haven't used... - Thurs, Nov 11 2004 11:43 am 1 message, 1 author http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/565dd04823f976b2 nonzero != 1, right? - 5 new ---------------------------------- Could someone please confirm the following A boolean expression, evaluates to true or false. In an integer context, this becomes non-zero or zero, respectively. Therefore the expression x == y ? 0 : 1 CANNOT be abbreviated to x == y Thanks, -trent ... - Thurs, Nov 11 2004 12:49 pm 5 messages, 4 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/26814eeabc379360 strings - 4 new ---------------------------------- i still don't get strings in c entirely suppose FILE *stream; int n; char *s; ( suppose file is open...) fgets (s, 1024, stream) what i don't understand is: i defined a pointer to a char (only the pointer, no memory allocated, i think). when fgets gets called, s will point to the string read. but does that mean fgets allocated memory itself for the string? s is only a pointer to a char, but there is no memory allocated yet by me for all of the string. where does the string end up? all examples i found were like this... - Thurs, Nov 11 2004 3:16 pm 4 messages, 3 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/898216cde1cc4f1b [OT] - all new ---------------------------------- ... You don't like the assignment operator for that? *node = *node->next; ... - Thurs, Nov 11 2004 5:01 pm 1 message, 1 author http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/c900023a84c1a83d Giving the preorder & inorder lists, How can be constructed the corresponding B-TREE ? - 2 new ---------------------------------- Thank you!! C is ok. David. "Dave Vandervies" escribió en el mensaje news: [EMAIL PROTECTED] ... - Outgoing mail is certified Virus Free. Checked by AVG anti-virus system ( http://www.grisoft.com ). Version: 6. 0.782 / Virus Database: 528 - Release Date: 2004-10-22... - Thurs, Nov 11 2004 5:03 pm 2 messages, 1 author http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/68744af9e196542d EOF character - 5 new ---------------------------------- Hi, my text file contains many lines of text, some of the text contains EOF character appended at the end of the text. if I use: while (fgets(buffstr, sizeof(buffstr), in_ptr)!=NULL), it will only reach the first text that contains the EOF character, not to the end of the file. How can run through the whole file to the end instead, in order to do some own filtering process? Thanks. ... - Thurs, Nov 11 2004 5:54 pm 5 messages, 3 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/4e284fe26bfa7fbd DOS to Windows - 2 new ---------------------------------- ... FWIW, that is not a DOS box or DOS prompt. DOS has nothing to do with it; it's a win32 console window. Also FWIW, most Windows users are perectly capable of screwing up their systems with or without the help of the command prompt in a console window. Allin Cottrell ... - Thurs, Nov 11 2004 7:20 pm 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/4ca2aabf9d2c03ad ======================================================================= 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
