comp.lang.c http://groups-beta.google.com/group/comp.lang.c
Today's most active topics: * C 99 compiler access - 23 new http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/6ab6fa86dd3e2204 * Pointer arithmetic involving NULL pointers - 13 new http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/ef9a1260c87b6bfc * is this code safe? - 12 new http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/c8e79374e6e5f877 * Reading Simple Flatfiles with a COBOL Mindset - 9 new http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/a5dab07a9f3912dc * Link compatibility among C compilers? - 9 new http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/ab0aed3fc58b6cd9 Active Topics ============= turbo assembler - 3 new ---------------------------------- When i compile my code using masm i get the error "can not open the dos.h in the turboc3. What should i do to remove this error? ... - Fri, Sep 10 2004 2:24 am 3 messages, 3 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/be75550c031ac7e1 static link a library - 3 new ---------------------------------- I am quite a beginner in C. I am writting an application on my debian linux computer that uses some imagemagick library functions. I can link them and compile (with cc) in my computer but when I move the binary to another computer it says: error while loading shared library: libWand.so.6: cannot open shared object file: No such file or directory. I would like to avoid this and (if possible ) have everything compiled into my binary. I think I have to link a static version of imagemagick library but I don't know how to do this. I... - Fri, Sep 10 2004 2:39 am 3 messages, 3 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/a4418dcf6c66b2ef C 99 compiler access - 23 new ---------------------------------- ... You mean unlike the high-quality products of professionals like Microsoft? Nobody "let" anyone design and construct either Unix or Windows stuff. Neither were developed in dictatorships with mandatory quality control and laws prohibiting both sale and purchase of products without an official stamp of quality. ... - Fri, Sep 10 2004 2:51 am 23 messages, 14 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/6ab6fa86dd3e2204 Reading Simple Flatfiles with a COBOL Mindset - 9 new ---------------------------------- ... Heh. C was designed by people who were damned glad they /weren't/ using punch cards. It was created at the same time (and by some of the same people) who were inventing the Unix operating system, a system that has never supported the punch card the way IBM OSes from (roughly) the same era did. ( Unix, and C, like teletypes and other character-oriented interactive input/ output methods.) Of course, C has grown up and left its single-OS roots behind, but it still makes certain assumptions about how programmers want to see the... - Fri, Sep 10 2004 3:12 am 9 messages, 8 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/a5dab07a9f3912dc is this code safe? - 12 new ---------------------------------- ... Probably not, but I dare say that if he does not fall in the category "undisciplined amateur", then he probably belongs to "not yet disciplined student taught by an undisciplined amateur or idiot". Richard ... - Fri, Sep 10 2004 3:57 am 12 messages, 9 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/c8e79374e6e5f877 define a data type of 1 bit size - 5 new ---------------------------------- if u really want to be economic with process's memory u can use for example a char (or int) and store in it up to 8 (or 32) one bit values ;) ... - Fri, Sep 10 2004 6:05 am 5 messages, 4 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/586b37c8227a9ded A way to maintain a global set in many files by using preprocessing directives . Could we find a better method? - 2 new ---------------------------------- Hi, all. Recently, I find there is a way in our project to maintain a global set in many files by using preprocessing directives. I'm wondering if we could find a better method for this. Many colors are referred in different subsystems in our projects. They are defined as enumeration constants and a single color must be the same value all across our projects. ... { yellow = 0; red = 1; green = 2; blue = 3; pink = 4; white = 5; black = 6; brown = 7; cyan = 8; purple = 9; gray = 10;... - Fri, Sep 10 2004 4:02 am 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/1fee113db5ffb3cd Accessing result of assignment - 6 new ---------------------------------- ... How about this: int c; memset(x, c = 0, sizeof x); ... - Fri, Sep 10 2004 4:26 am 6 messages, 5 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/78ecd2d1af0b023e Coding statements before declaration-a doubt on standard!!! - all new ---------------------------------- [snips] ... Actually, I really like this feature. While it does mean variable definitions are scattered about, it also means that they tend to be ( or at least, _should_ tend to be) more closely linked to the code that uses them: void func(void) { int i; /* 20 lines of code */ i = init(); use( i); ... vs void func(void) { /* 20 lines of code */ int i = init(); use(i); ... Matter of preference, perhaps, and you can "fake it" using block scoping, but I find this approach, on the whole, cleaner than the traditional C... - Fri, Sep 10 2004 4:28 am 1 message, 1 author http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/1c6d82a9018a8db Please find out what is wrong - 2 new ---------------------------------- ... int array[] = {23,34,12,17,204,99,16}; int main(void) { int d; for(d = 0; d != TOTAL_ELEMENTS; d++) { ...... - Fri, Sep 10 2004 4:38 am 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/154185c3ce757cfa Postfix / Prefix Operators on array / pointer, search key word wanted [OT] - 4 new ---------------------------------- ... You can apply the sizeof operator, the address operator, and in the case of initialization, the assignment operator. ... - Fri, Sep 10 2004 4:47 am 4 messages, 3 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/ec29e483cf1f1ce9 two dimensional arrays passed to functions - all new ---------------------------------- ... Do you have a fixed array or do you have dynamic allocations? I tend to enclose the array and the number of elements in a struct and dynamically insert strings into the array. You can allocate 1d with the char buffer being fixed, i.e. 256, or you can allocate 2d. The 1d struct: struct STRINGARR { char (*String)[256]; size_t numelements; ... The 2d struct: struct STRINGARR { char **String; size_t numelements; ... The prototype for the insert function would be: char *insert(struct STRINGARR *array, const... - Fri, Sep 10 2004 5:01 am 1 message, 1 author http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/76c88cb0e98ad73f parsing time string, getting timezone - all new ---------------------------------- ... <snip code> ... first of all, thanks for your answer! tm_gmtoff is a BSD & GNU extension, so definetly not ISO or POSIX C. Anyway. I've tried to use your recommendations for changing the function, but I cannot see how I should do it. Can you shed some light on how I should change this function to return a string with the right timezone? Using tm_isdst I can see whether it's daylight savings time or not, but I wouldn't know how to use that information in the string.. I know, I should be able to figure this out... - Fri, Sep 10 2004 5:24 am 1 message, 1 author http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/68e3ee36eecae755 Does realloc "move" a block it shortens? - 6 new ---------------------------------- ... Yes, for various reasons. ... So what, when correction is simple. ... char *ShortenStr(char *p) ... char *t; ... if (t = realloc(p, n+1)) t[n] = '\0'; return t; ... if (p = ShortenStr(p)) { ... ... However they are dangerous routines in that all strings handled must reside in malloced memory. ... - Fri, Sep 10 2004 5:43 am 6 messages, 6 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/d20134ca0362e5fc malloc and free - 5 new ---------------------------------- I have something near to this: unsigned *p, *a; p = malloc(80*sizeof( unsigned)); a=p; if(p==0) exit(1); <code snip> /******************/ free(p); / ******************/ Is it possible there is segmentation fault where there is free(p);? Where is the error if 'p' is the same of 'a' (p==a) and never I had free (or realloc) p? How detect *where* I wrote the malloc's memory not in my space allocated? Thank you ... - Fri, Sep 10 2004 6:34 am 5 messages, 3 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/9dc6bf671c014afb Difference between Structure & Union - 4 new ---------------------------------- Hi All, Can you give me the example code which explains difference between Structures and Union. As a newbie please do the needful. Thanks, csudha. ... - Fri, Sep 10 2004 7:02 am 4 messages, 4 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/81a25756b583d370 Cracking C structure - all new ---------------------------------- ... Not possible for what mechanism? You can't do it from "inside" a conventional C program. You *can* do it if you can process C programs like data. If you have what amounts to a compiler front end, you *can* loop thru struct contents; the deduction is trivial, the compiler stores the types of the data in its symbol table. The DMS Software Reengineering Toolkit offers a full C parser front end with symbol table, and it could be use to "loop thru the structure" pretty easily. What is harder is that there is often an... - Fri, Sep 10 2004 7:34 am 1 message, 1 author http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/5eb96610175cb6ee Church's lambda calculus - 8 new ---------------------------------- Q1) Has anyone seen a treatment of Dr. Church's lambda calculus that uses C instead of an obscure language designed for logic? Q2) How does access the forum archives? MPJ ... - Fri, Sep 10 2004 8:38 am 8 messages, 6 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/210b76dfb4421714 Two Questions about "strlen", "strcat" and "strcpy" - 4 new ---------------------------------- ... Well, that's your opinion and that's fine and all. I just don't see that it's really that big of a deal. What really happens in your example is a confusion based on the fact that the first argument passed to printf() is a pointer to an entity that is changed via side-effect in another argument. That would happen with your strlcpy as well. The usual usage of the nested str* calls is something like this: size t len; char buff[40] = "Hello"; len = strlen(strcat(buff, " World!"); Brian Rodenborn ... - Fri, Sep 10 2004 10:43 am 4 messages, 3 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/e9ba0a3a9129c3ba volatile expression - all new ---------------------------------- ... Yes, it does. Section 6.4.6 is about "punctuators". The "other forms" clause refers to operators that don't have the form of a single punctuator, such as the sizeof, cast, and array indexing operators. You're right, the definition of "operator" in C99 6.4.6p2 is explicitly not exhaustive. That just means that there are other things that the standard explicitly refers to as operators. ... In "return v;", yes, v is an expression (or else the statement is illegal). It's obviously the intent of the standard that v, by... - Fri, Sep 10 2004 11:50 am 1 message, 1 author http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/36953aa1b62af842 Pointer arithmetic involving NULL pointers - 13 new ---------------------------------- Is adding 0 to a pointer to non-void that is equal to NULL legal? int *p=NULL; p+=0; ... - Fri, Sep 10 2004 12:13 pm 13 messages, 8 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/ef9a1260c87b6bfc parsing in C - 2 new ---------------------------------- there is a good variety of links across the web that talk about the subject. for exeample the famous master peace of Jack Crenshaw "Let's build a compiler is good one that every beginner should go through to have a good basic on expression evaluation (it talk in general about compiler writing). well in a nutshell to parse an algebrian expression there is at most two famous ways to proceed with : polish notation (know also as Infix notation) and its variant reverse polish notation (postifix) recursive descent.... - Fri, Sep 10 2004 2:12 pm 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/e604398031a98a42 integer array - all new ---------------------------------- ... Not since I've learned how to avoid alignment problems with arrays. If you have char array[sizeof(int)]; then *(int *)array = 0; might give you an alignment problem. In terms of portable code, it's a definite alignment problem. But, if you have int array_2[1]; then array_2[0] = 0; is fine. There is no padding between elements in an array. All of the elements in an array are the same size. All of the elements in an array are contiguous. ( sizeof array / sizeof *array) equals the number of elements in array.... - Wed, Sep 8 2004 1:55 pm 1 message, 1 author http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/cdb9ee27610c48f5 simple word wrap problem not wrapping - all new ---------------------------------- ... working on this. I saw your point though. ... except in cases that I test where I pipe the contents of a file to the program to avoid this translation. But you are right in that I'm not sure how to handle those tabs in this instance. ... Hadn't thought of that one. Thanks. ... correct me if I'm wrong and I probably am, but this statement is basically the same as buffer[i]='\n'; i=i+1; if it were buffer[i++]='\n'; I would see your point on this. Just what little reading I have done states that it evaluates right to left... - Wed, Sep 8 2004 3:03 pm 1 message, 1 author http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/b27caad5393ba1ea +++i - 6 new ---------------------------------- ... Ah. ... - Wed, Sep 8 2004 3:05 pm 6 messages, 4 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/3d42b0520ce505c0 Newbie Question about #ifdef - all new ---------------------------------- ... lseek and read are not part of the standard C library. They are provided as part of the Cygwin environment. What the code above is doing is checking to see if the symbol CYGWIN has been defined; if so, the text between the # ifdef/#endif is compiled, otherwise it is omitted. IOW, if we're compiling for the Cygwin environment, the function pread() is defined as above. ... Java should already have equivalent functionality for lseek and read as part of its standard class library, IINM. Unfortunately all my... - Wed, Sep 8 2004 3:30 pm 1 message, 1 author http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/590a95e41276f91c C program to flowchart - all new ---------------------------------- VJ wrote: ... Search freshmeat.net for CodeViz. If you don't have linux it's possible to set up a linux box, take the source there, generate the charts and go view them on windows. Gerald ... - Thurs, Sep 9 2004 1:40 am 1 message, 1 author http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/8b4b719abb6b581b creating a 2-d array using dynamic memory allocation - all new ---------------------------------- ... Increased performance, reduced portability ... Casting malloc's return value is almost always silly (read the FAQ). ... You mean (int *)(int_matrix + width), ie. (int *)&int_matrix[width]. Your version would only work if sizeof(int *) == sizeof(int). For example, systems with 32-bit int and 64-bit (int *) are not uncommon. ... If int is 64-bit with 64-bit alignment, and int* is 32-bit, and width is odd, then you get undefined behaviour. I'd suggest at least using 2 mallocs: one for the int * array and one for the ints.... - Wed, Sep 8 2004 5:16 pm 1 message, 1 author http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/d8d5e8af9d1e9cc6 Creating a va_list - 2 new ---------------------------------- void function( char *ptr, ... ) { va_list args; char format[81]; va_start( args, ptr ); vssprintf( format, ptr, args ); va_end( args ); ... the moral of the story is that ptr must be in a format for sprintf for example: "%d%c%s" etc. and format must be the length of the string that you expect. Marc Smith.. ...Moonie -- Moonie ... ... - Wed, Sep 8 2004 5:26 pm 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/8263f3a375489de2 [OT]Re: Different outputs in different environments. - 3 new ---------------------------------- ... Waiter, what's this fly doing in my soup? ... - Thurs, Sep 9 2004 12: 08 pm 3 messages, 3 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/6787ac680d5a6f90 Link compatibility among C compilers? - 9 new ---------------------------------- As I understand it there is a good amount of link compatibility among C compilers. For example, I can compile main.c with GCC and func.c with Sun One and link the objects using either linker (GNU or Sun). What I'm curious about is why this compatibility exists in the absence of a standard C ABI? What encourages C compiler vendors to agree on implementation issues such as alignment, packing, etc., such that their object files are compatible? I've heard it said that compiler vendors who don't want to re- implement the whole standard C library have... - Thurs, Sep 9 2004 12:15 pm 9 messages, 7 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/ab0aed3fc58b6cd9 removing Spaces - all new ---------------------------------- On Thu, 9 Sep 2004 16:15:03 +0100 ... Yes, that's better.... - Thurs, Sep 9 2004 2:09 pm 1 message, 1 author http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/166d28f6a22645d0 C Preprocessor - Cascaded Macros - 2 new ---------------------------------- I've been looking into cascaded macros and I can't seem to find if what I'm doing is portable. I want to do something like: ... so that the statement: { JOIN_LISTS(THREE_ONES,ONE_TWO_THREE) }, will expand (one the first preprocessor pass) to: { JOIN_LISTS_PROCESSED(1,1,1,1,2,3) }, then expand on the second pass to: { 1+1, 1+2, 1+3 }, On my compiler (DJGPP) it works just fine - but is it portable? Do all preprocessors use a similar replacement order? ... - Thurs, Sep 9 2004 4:08 pm 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/5e9f7af252f37f35 Book Recommendations? - all new ---------------------------------- ... I didn't say it could never be appropriate, I simply said I didn't see any scenarios where it would be. I always develop for hosted platforms, not embedded, and I do not fully understand all of the implications of developing for embedded platforms. I realize my ignorance, and I wouldn't presume to make such a baldfaced statement. ... And I was saying that I could not imagine being without malloc on any of the systems I design for. ... - Thurs, Sep 9 2004 6:54 pm 1 message, 1 author http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/aabbf175e3e0d3a1 [OT} Function Call Tree Command in UNIX. - all new ---------------------------------- ... Thanks a lot!!! - Vinay. ... - Fri, Sep 10 2004 9:07 pm 1 message, 1 author http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/e21d828db9f0efe0 Performance Programming - all new ---------------------------------- Hi all, I am switching from Java to C solely for performance, but I wonder are there any coding techniques that can boost performance in C? I am asking such an open-ended question to elicit response for me such as links and discussion. By the way, I am also pretty headache with ArrayIndexOutOfBound exception, in which C or C++ never warn about anything reading uninitialized memory, can I make a trap at all memory dereferencing point, so that I can check if the piece of memory is valid, such as array indexing, or picking... - Fri, Sep 10 2004 9:32 pm 1 message, 1 author http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/bccd33b9dff2397f Wide string initializer syntax - all new ---------------------------------- Looking through the C90 standard, it occurred to me that the possible syntaxes for initializers, particularly of wchar_t arrays, are really bizarre. Consider the following: ... That's four different types initialized with exactly the same initializer syntax, but it means four different things. In the first case, a mutable buffer is being initialized, and the standard lets you wrap the string intializing the buffer in braces for no apparent reason. In the second case, an array containing one pointer to a literal string ... - Fri, Sep 10 2004 10:11 pm 1 message, 1 author http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/2cdb63f40db2686f Need help for optimising nested ifs-help me plz panic situation!!! - all new ---------------------------------- Dear all, Whats the common practice followed generally in the industry to avoid large number of "nested ifs" in a C code?I am currently working with a code which has a tremendous nests (in the order of around 25 or more!)and feeling really tough to maintain it.Also the code is for a application which has lots of dependecies. My application demands that the current output is dependent on previous output.Like this in my application I have now reached 25 dependencies in nests. Need valuable suggestions to overcome this... - Sat, Sep 11 2004 12:22 am 1 message, 1 author http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/2e202f66bac06055 ======================================================================= 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 ------------------------ Yahoo! Groups Sponsor --------------------~--> $9.95 domain names from Yahoo!. Register anything. http://us.click.yahoo.com/J8kdrA/y20IAA/yQLSAA/BCfwlB/TM --------------------------------------------------------------------~-> <a href=http://English-12948197573.SpamPoison.com>Fight Spam! Click Here!</a> Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/kumpulan/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/
