comp.lang.c http://groups-beta.google.com/group/comp.lang.c
Today's most active topics: * DOS to Windows - 13 new http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/4ca2aabf9d2c03ad * Quiting a program using pure C - 11 new http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/64c944589e3ebd58 * simple c-code - 10 new http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/aadecab38e4324ed * c string - 10 new http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/66a16943b9cacc4 * address of a statement in C - 9 new http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/9c7bf5671accbcf6 Active Topics ============= Mutex entirely in ANSI-C possible, without I/O routines? - 5 new ---------------------------------- I was thinking about it for a while, a mutex written in C and without disabling any interrupts. Is it possible? typdef struct mutex { unsigned int owner1; unsigend int owner2; ... void mutex_init(mutex *m) { m-> owner1 = 0; m->owner2 = 0; ... void mutex_lock(mutex *m) { int *owner1; int *owner2; int currentThread; currentThread = getThreadIdOfCurrentThread(); owner1 = &(m->owner1); owner2 = &(m-> owner2); while ( (*owner1 += currentThread) != currentThread & /* Note the &, not &&, that is important... - Mon, Nov 8 2004 1:10 am 5 messages, 5 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/adf980f6bdfe2b42 address of a statement in C - 9 new ---------------------------------- ... Then don't do that. Breaks are good for switch-statement. Returns belong at the end of your function, at the top for error returns but not in the middle of a loop. ... And one breaking the loop invariant. Hence... Don't do that. ... Ditto. That practice, legal as it my be according to The Standard, it usually results in "bad" code, which derives it unreadability from the profusion of possible execution paths trough the code. ... Ok. You provided a few good examples of what *not* to do, of (in my book) improper use of "break" and "return".... - Mon, Nov 8 2004 1:18 am 9 messages, 5 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/9c7bf5671accbcf6 simple c-code - 10 new ---------------------------------- ... This is off-topic, but theoretically, how would a hacker be able to take control of a system by exploiting buffer overflow? On a typical Windows system, the executable would be running with its own stack space. The worst I can see happening is the program crashing due to an invalid memory read/write. I doubt OS code/data would be anywhere in or near the program's address space. ... - Mon, Nov 8 2004 1:31 am 10 messages, 6 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/aadecab38e4324ed Jobs using C - 9 new ---------------------------------- ... The C language is still heavily used in the embedded world, and for driver and OS kernel development. Even in fields where C has been surpassed by other languages, there are uncountable legacy applications. But as Mike pointed out, programming C is not a job in itself. At the very least, most C coding jobs will also be doing assembly or C++ development, and/or other type of scripting. .. Cheers Ivan... - Mon, Nov 8 2004 1:36 am 9 messages, 6 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/df1e378aad3bcd C multi-dimensional arrays and pointers - all new ---------------------------------- On Mon, 01 Nov 2004 23:02:21 GMT, Robert Harris ... works out (effectively) to row-major consecutive memory. But this is not different from Pascal, which like most HLLs has multidim arrays in the obvious fashion -- although it tries harder than C or at least typical C implementations to prevent out-of-bounds subscripting (or equivalently in C only pointer arithmetic) which is the only way a program can actually see this. Aside from C's predecessors B and BCPL, now almost entirely vanished, the only language I know of that requires... - Mon, Nov 8 2004 1:39 am 1 message, 1 author http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/87f8dda33c6a409d Count the frequency - 6 new ---------------------------------- ... ... Ok. I don't really care *who* calls me an idiot, (s)he get's plonked. Outside the soc.culture.* hierarchy that is. ... - Mon, Nov 8 2004 1:42 am 6 messages, 4 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/a3d98ffcb4e4d1ba c string - 10 new ---------------------------------- if i do this char *mystring="mystring"; later i reassign to mystring like this mystring="replacewithnewstring"; i'm not a c expert, but i suppose i need to get rid of the dynamically assigned "mystring"? what should be done according to best practices ? free(mystring) ? tx ... - Mon, Nov 8 2004 1:53 am 10 messages, 6 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/66a16943b9cacc4 Quiting a program using pure C - 11 new ---------------------------------- Is there anymore methods in exiting your program using pure C language other than return 0? ... - Mon, Nov 8 2004 2:06 am 11 messages, 10 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/64c944589e3ebd58 Stupid Americans! -- Stupid... Stupid... STUPID!!! _____________---_ adamz - all new ---------------------------------- ... I think he is a victim of American Stupidity in a different way than he tries to convey. ... - Mon, Nov 8 2004 2:15 am 1 message, 1 author http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/ceb3a1744c832427 static cons and static - all new ---------------------------------- j wrote: ... True, I read those parenthesises as curly brackets... Might just be a type turned copy and paste error though, and then my comment stands on it's own feet. Perhaps... Uncompilable fragments are a bad idea anyway. That is my excuse. ... - Mon, Nov 8 2004 2:18 am 1 message, 1 author http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/36a6bf6e5b6afa3b Newbie: Output to a file - 3 new ---------------------------------- ... I got no warnings using "gcc -o xport xport.c" to compile it... Stefan ... - Mon, Nov 8 2004 2:26 am 3 messages, 2 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/cafbf0aedb5969fa Functions as function parameter - 4 new ---------------------------------- Hi, I want to pass a C-function as a function parameter but I don't know how to that correctly. In the example below how would I have to declare the function argument in the my_sort function definition? Thank you in advance for any help. Regards Rolf int comp_func1(double * a1, double * a2) { ... ... void my_qsort(double * a, int n, (* comp_func)) { ? ?????? ... comp_func(&a[i], &a[j]); ... ... int main() { ... my_qsort(a, n,comp_func1); ... ... - Mon, Nov 8 2004 3:13 am 4 messages, 3 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/f8b840ac2761f8f8 cancel <[EMAIL PROTECTED]> - all new ---------------------------------- This message was cancelled from within Mozilla. ... - Mon, Nov 8 2004 3: 55 am 1 message, 1 author http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/a85b5e5e86b7fe1b CPP predicates for compiler extensions - 2 new ---------------------------------- I'm trying to find CPP predicates that allow conditional compilation based on the compiler's standard / features / extensions. So far I have determined that, for GCC, - __STRICT_ANSI__ implies -ansi. - ! __STDC_VERSION__ implies -std=c89 or -std=gnu89. - 199409 == __STDC_VERSION__ implies -stdc= iso9899:199409. - 199901 == __STDC_VERSION__ implies -std=c99 or -std=gnu99. I'd like to be able to - distinguish between cXX and gnuXX (i.e. are there extensions?). - check support for variadic macros.... - Mon, Nov 8 2004 3:58 am 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/a5d98bd972ff84d2 Doubts:Steve Summit's page/Chapter 22 - 7 new ---------------------------------- ... Ignorance, sheer ignorance on my part.I was really thinking of something on the lines of : int int; which of course is not legal. ... This part(you were correct as to what `list' is doing) is ok. One more thing, possibly OT, given the address of a particular node in a singly linked list, is it possible to delete that element from the list without traversing the list? Not exactly homework but was put across in an interview.The interviewer is supposed to have said something regarding memory copying required to... - Mon, Nov 8 2004 4:05 am 7 messages, 4 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/c900023a84c1a83d listing all files in a directory - 4 new ---------------------------------- I am trying to get a list of all files of a certain extension type on disk to do some processing in a loop. The code needs to be portable to UNIX, so I need to use plain c functionality. Does anyone know of a way to do this ? Any URLs, code snippets, etc ? ... - Mon, Nov 8 2004 4:35 am 4 messages, 4 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/dad9018a97cf0910 bitness of machine using C language - all new ---------------------------------- Shri wrote: ... On the same machine: when I run Turbo C 2.0, sizeof(int) is 2. when I run MSVC++ 5.0, sizeof(int) is 4. ... - Mon, Nov 8 2004 5:20 am 1 message, 1 author http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/48afc7bc5e0675a6 sizeof dynamic array - 5 new ---------------------------------- ... As others have mentioned, keep track of the size when you allocate the array. I suppose one possible exception is a null-terminated char array where you can call 'strlen' to get the length of the array. ... - Mon, Nov 8 2004 6:06 am 5 messages, 3 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/34e81ca8b269e1c3 DOS to Windows - 13 new ---------------------------------- I have a program writeen in Microsoft QC 2.5 for DOS which has a very simple interface of using printf and sscanf also gets and puts. Is there an easy way to convert this to Window? Thanks Stan ... - Mon, Nov 8 2004 6:21 am 13 messages, 9 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/4ca2aabf9d2c03ad hashlib package - 2 new ---------------------------------- ... From the posting that started this thread: ... The function is defined without an explicit return type, which means "implicit int" under C89 rules and "diagnostic required" under C99. ... The existence of a ( putatively) correct program at the other end of a link is not the issue: The problem is that the illustrative code shown in the manual is faulty. Here it is, again from the thread-originating post: ... Note the unbalanced parentheses in the `if' statement and the four uses of `.' where `->' was intended.... - Mon, Nov 8 2004 6:46 am 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/e5f87805e1fd8c3f EVIL FBI SADISTS should be KIDNAPPED and TORTURED for 3 YRS - all new ---------------------------------- Reading this stuff is almost as much fun as watching cops! It reminds me that, no matter how bad things might get, I can always say "Hey, at least I'm not THAT guy!" :-D -Anonymous (P.S., what do you mean, I'm *not* anonymous??? Did I have to put that in caps or something?) ... - Mon, Nov 8 2004 8:44 am 1 message, 1 author http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/4c059e652a7438 role of preprocessor - 7 new ---------------------------------- I know that for my own programs, the things that precede the main call are either remarks or begin with a hash. What else can you put up there? MPJ .. . - Mon, Nov 8 2004 10:21 am 7 messages, 4 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/6dc5c919c0692702 Crazy stuff - 4 new ---------------------------------- ... This is because doing the declaration as char *str = "dot.delimited. str"; embeds a CONSTANT string somewhere, and then sets the pointer to point to it. You can not WRITE to constant strings. (Well, you shouldn't and shouldn't be able to, but some old C implementations allowed this). Doing it as char str[]="dot.delimited.str"; creates a character array on the stack, of exactly the right length, and initialises it with the given string (by something similar to strcpy()). There are thus TWO copies of "dot.delimited. str":... - Mon, Nov 8 2004 11:47 am 4 messages, 4 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/3bdab6e630859d59 Character arrays - all new ---------------------------------- ... The array only "holds strings of any length" by accident. I don't know how an array of zero elements is supposed to behave and I don't know how it actually does behave on your system. The behavior that you experience is almost certainly due to your overwriting variables that follow it. ... These arrays do not grow at all. Unless you do dynamic allocation, their size is fixed for as long as the array's lifetime. You should not be writing outside the array's bounds at all. Richard [in PE12] ... - Mon, Nov 8 2004 11: 56 am 1 message, 1 author http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/d7360ceb0613160 install source code to a drive other than "C:\" ? - 3 new ---------------------------------- ... But installing something onto drive C and then switching to drive D lokks like "C++"?! ... - Mon, Nov 8 2004 1:02 pm 3 messages, 3 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/634b8bae451a91be Getting time in milliseconds - 9 new ---------------------------------- Hi: is there a way to get current system time in milliseconds... which functions and headers?? thanks pravesh ... - Mon, Nov 8 2004 3:32 pm 9 messages, 7 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/565dd04823f976b2 why char *p = "can not modiy"; char p[] = "can modify" - 5 new ---------------------------------- when define char *p = " can not modify"; p[0] ='b' ;is not allowed, but if you declare p as char p[] = "can modify"; p[0] = 'b'; is ok? why? what's difference between the two declaration + definition? ... - Mon, Nov 8 2004 4:02 pm 5 messages, 5 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/590bb89a41716dd1 Giving the preorder & inorder lists, How can be constructed the - all new ---------------------------------- inorder/preorder list's: 2 List Data Structures where the nodes are connected with a Binary Tree values in inorder and preorder respectively. thank you. "hari4063" escribió en el mensaje news:76c6633d7b45522bfffe112720c95442@ localhost.talkaboutprogramming.com... ... - 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 ... - Sun, Nov 7 2004 7:05 pm 1 message, 1 author http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/68744af9e196542d Can someone teach me? Thx!!! - 7 new ---------------------------------- I'm the beginner of C programming. And my teacher give a question I don't know how to do. Can someone teach me? Thx!! The Question is: To print out four *, and skip one line. The print out like: * ... If someone can help me? ... - Mon, Nov 8 2004 5:19 pm 7 messages, 4 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/9e8513bd333c859b Argument Processing - all new ---------------------------------- In article <[EMAIL PROTECTED]>, i0n1v2a3l4i5d6 [EMAIL PROTECTED] says... ... What's wrong with this picture? ... - Mon, Nov 8 2004 6:53 pm 1 message, 1 author http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/deee1550c7aee70 Confused about functions - 3 new ---------------------------------- Hi. Our assignment was to creat a program that can find the average, median & mode of a #of integers. Here's my program: ... int main() { int item[100]; int a, b, t, mode; int median_index; float median, avg; int count; printf("How Many numbers do you want to enter? "); scanf("%d", &count); for( a=0; a<count; a++){ scanf("%d", &item[a]); ... for(b=count-1; b>=a; --b){ if(item[b-1] > item[b]){ t=item[b-1]; item[b-1] = item[b]; item[b]= t; ... median = count/2; if(count%2 ==1){ printf("There are odd sets of numbers.\n");... - Mon, Nov 8 2004 8:38 pm 3 messages, 3 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/e5ef06e0b57dfb4 allocate space for typedef data type - 3 new ---------------------------------- Always get segmentation fault for the following code. If the data is primitive type instead, it will be fine. What is the problem? Thanx main(){ typedef int pid_t; pid_t pid=12; pid_t* ary; int count=0; ary=(pid_t*)realloc(ary,(count+1) *sizeof(pid_t)); *(ary+count)=pid; ... ... - Mon, Nov 8 2004 10:23 pm 3 messages, 3 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/b0dc1e7314d9cc43 cancel of <[EMAIL PROTECTED]> - all new ---------------------------------- cancel by original author ... - Mon, Nov 8 2004 11:34 pm 1 message, 1 author http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/f0349614ec3b1842 ======================================================================= 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
