comp.lang.c http://groups-beta.google.com/group/comp.lang.c
Today's most active topics: * union access - 22 new http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/ae5339a09d904e21 * Newbie-question: scanf alternatives? - 13 new http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/7a737a53f44215a6 * elementary construction - 9 new http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/eddddaac4ec842ce * Malloc/Free - freeing memory allocated by malloc - 6 new http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/c1d9f42a01aa0d5d * Pop's Device, was Re: Some Newb Problem with "int", please help. - 4 new http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/68cb42fb87cea0db Active Topics ============= union access - 22 new ---------------------------------- ... No. Duh. I have never seen a union used to save memory. The main reason to use unions is to take in chunk of data in binary form and break it down into meaningful data. Things like packets that come in as X number of bits, and pulling out the real data as flags and bytes. We do this all the time when communicating with the mainframe. Structs and unions have a similar definition, so the Standards Whores think they are the same, but in fact if they were that similar you could, for instance make a union array. That... - Wed, Sep 22 2004 12:59 am 22 messages, 11 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/ae5339a09d904e21 Dynamically assigning data type - all new ---------------------------------- Yeah... I guess I might have to do it that way by using unsigned short in my code and then cast it to chars as I need to. Thanks for the help. Cheers! . ..... - Wed, Sep 22 2004 1:32 am 1 message, 1 author http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/da2437735a66a1de memory - 2 new ---------------------------------- why not to build a malloc_m() and a free_m() that *check* (if memory_debug=1) if 1) there are some errors in bounds of *all* allocated arrays from them ( and trace-print the path of code that make the error and exit) just when malloc_m and free_m start. (I use a 1100 static array for write the path ( like a queue) of called function, operator, etc and write using '+' where is find the memory error) 2) if the pointer to free is alredy allocated from malloc_m 3) if there are memory leak at end... - Wed, Sep 22 2004 1: 39 am 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/39e68316868ed3f4 Out-of-bounds access and UB - 2 new ---------------------------------- On Mon, 20 Sep 2004 14:08:35 +0100, Flash Gordon ... programming == to deal with arrays(and *bounds* of arrays)and loops or programming == to deal with call functions writed from others ? ... - Wed, Sep 22 2004 1:40 am 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/aa60e124041ec9c9 C Program Portability - 3 new ---------------------------------- On Tue, 21 Sep 2004 20:35:52 -0400 (EDT) ... Bad. What if CHAR_BIT!=8 ? ... Very bad, what if sizeof int <= 2 ? ... <snip> OK, so on most hosted systems that the OP is likely to use CHAR_BIT==8 (I know some real systems have other values, but those are rather less common) but for portable binary formats you do have to be very careful and allow for what mechanism will be used for transferring the data and if CHAR_BIT>8 how this will affect the layout of the bits in a shared resource such as a binary file. Text formats... - Wed, Sep 22 2004 1:40 am 3 messages, 3 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/d51ca9bdab86106c Viewing the *.I file of my C source code in MS Visual C++ 6.0 - 2 new ---------------------------------- With the Turbo C 3.0 compiler, if I want to read my C source code before compilation but after the pre-processing, (i.e. the *.I file), I usually do a: cpp MyFileName.c at the command prompt, and that puts my preprocessed code file into the bin directory under C:\TC\bin. How can I view the *.I file in Microsoft Visual C++ 6.0? ... - Wed, Sep 22 2004 2:28 am 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/4750d5f64a088848 context switching with setjmp - all new ---------------------------------- ... The stack frame saved in setjmp has to be still on the stack when you do the longjmp. When you do a setjmp in a function and then return from that function, the jmpbuf becomes undefined and the results of longjmp to it are undefined. Mucking around with the internals of a jmpbuf value is even more undefined. Perhaps what you really want to do is use function pointers. f() { ...} g() {...} typedef int (*function)(); function switcheroo[2] = {f,g}; static toggle = 0; void dispatch(int sig) { puts("in dispatch");... - Wed, Sep 22 2004 2:36 am 1 message, 1 author http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/faee53b61553cc3b Screen Handling - 3 new ---------------------------------- I was looking at methods of clearing the screen. I remember using clrscr() in C on a Unix machine when I was at the institute learning software development. I tried using it on MS VC++ 6.0. It didn't work. I looked up the documentation. The documentation said this is a non-standard function and is included in conio.h. I had included conio.h already, and yet it couldn't link. I guess clrscr is a unix thing then? I also found this code in a book as well as on the Net about clearing the screen: THIS CAME FROM A DOWNLOADED SAMPLE... - Wed, Sep 22 2004 3:27 am 3 messages, 3 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/c19742be19369d91 c-book - 3 new ---------------------------------- Hi, there's a book from P. van der Linden. Is it good? o-o Thomas ... - Wed, Sep 22 2004 3:36 am 3 messages, 3 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/fd1e4c3319421eee Error ifndef _REENTRANT? - all new ---------------------------------- ... Standard library functions really aren't reentrant. N869 7.1.4 Use of library functions... - Wed, Sep 22 2004 3:43 am 1 message, 1 author http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/63620de600b89373 Malloc/Free - freeing memory allocated by malloc - 6 new ---------------------------------- ... I have a question about this particular line, printing the value of 'x'. Why is this wrong? The memory allocated by x is on the function stack, and I didn't believe you are accessing any invalid memory region? Sure, I don't really see a point in accessing x, unless you have a complex datastructure and you wish to free the memory, and then set everything that was assigned to 'x' to NULL (even that can be avoided, I only wanted to provide an example). For example, I can see a malloc library for debugging (e.g. ... - Wed, Sep 22 2004 3:12 am 6 messages, 6 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/c1d9f42a01aa0d5d Exception handling - 2 new ---------------------------------- ... Thank you very much for your help,can you please tell me a way to resume the function that caused the exception at the machine language instruction right after the one that generated? ... - Wed, Sep 22 2004 3:53 am 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/6c92e413959f500c Newbie-question: scanf alternatives? - 13 new ---------------------------------- ... The input stream is unchanged because, at EOF, there is no input to change. I suppose another getc(stream) would return EOF again. The casual observer wouldn't know it didn't work.... - Wed, Sep 22 2004 4:04 am 13 messages, 7 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/7a737a53f44215a6 Passing and returning arrays to and from functions - all new ---------------------------------- On Wed, 22 Sep 2004 06:19:01 +0100, "Malcolm" ... I'm sorry. In my original response I made the point that unlike gets(), fgets() saves the newline (if present) to the target buffer, and demonstrated one method for removing it. It was not meant to be a comprehensive tutorial on how to use fgets() to handle all situations. I believe I said something about dealing with characters remaining in standard input, and how that was a separate issue. You took three lines out of context and started yammering about... - Wed, Sep 22 2004 4:42 am 1 message, 1 author http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/50e357c1706e0d40 Pop's Device, was Re: Some Newb Problem with "int", please help. - 4 new ---------------------------------- ... ... You're invoking undefined behaviour in this case: you're opening in text mode a file which is not a text file (on the platform opening it). The things are even more obvious if the text file was generated on a VMS system or some typical mainframe OS, because the differences are far more impressive ( each line is a record in the file and has no terminating character(s)). This is why text files must be properly *imported* on the system that has to process them. Once this is done, the code can safely assume that... - Wed, Sep 22 2004 4:36 am 4 messages, 3 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/68cb42fb87cea0db [OT?] What is (a) "plunger"? - 4 new ---------------------------------- ... He said a long 'e', so it must be something like "keh-vin". Dan... - Wed, Sep 22 2004 5:05 am 4 messages, 4 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/a10a1f005c8f5002 Daylight saving - 2 new ---------------------------------- ... Tsk, tsk... there are no legal Pratchett e-books. Richard ... - Wed, Sep 22 2004 5:31 am 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/a8f351326d6538ab How to determine available system calls on a Unix/Linux system - 3 new ---------------------------------- ... A good place to start looking is under /usr/include for C files that give their numbers. I just looked at to and the map of numbers to names was given there. ... Too dependent on the system for me to give a good answer. Start with the man pages, and library binaries under /usr/lib. ... - Wed, Sep 22 2004 10:47 am 3 messages, 3 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/21cd3c1aa175c1a4 elementary construction - 9 new ---------------------------------- Today is when I sing in the choir, and I was thinking about rehearsal tonight when I realized that in order to be in the C choir, I had to buy K&R to be reading the same "music." no resolution to my first question, which crops up on page 6. I have always called main with an integer that says how many pointers are being passed to it. Is this just a matter of style? Would int main(int a, int b, int c){ return (51);} be, while close to trivial, ANSI compliant? MPJ ... - Wed, Sep 22 2004 11:45 am 9 messages, 7 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/eddddaac4ec842ce Managing global vars between files - 3 new ---------------------------------- Reason: I am working on an embedded project which has very limited memory ( under 512 bytes, 60 or so of which is stack space), which translates into limited stack space. In order to save on stack space, I tried to only use parameters and stack space for things which are truely temporary. Instead of passing a pointer to a data structure which should always be populated with data, I have the data structure declared as a global variable and all functions access it directly. This works fine until I try and organize the code into... - Wed, Sep 22 2004 11:48 am 3 messages, 3 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/34560407c855474b Q: volatile struct elements or entire struct? - 2 new ---------------------------------- If I have a structure that may point to a volatile "region (e.g. device)" or a context in memory what would be the best way to use the volatile keyword? E. g. a) volatile on struct objects struct Foo { unsigned char command; unsigned char status; unsigned long baseAddr; unsigned long addrRange; ... volatile struct Foo *pDevFoo = (some dev. address); ... - or - b) volatile on struct members struct Foo { volatile unsigned char command; volatile unsigned char status; volatile unsigned long baseAddr;... - Wed, Sep 22 2004 12:42 pm 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/c4e2145f60d8146c Creating an MD5 hash with crypt.h - 3 new ---------------------------------- Hi, I want to generate an MD5 checksum with crypt.h, installed OS Debian Woody. Unfortunately I only get DES hashes with strncpy(salt, row[0], 12); salt[12] = '\0'; encryptedPass = crypt(passwd, salt); free(salt); Later I compare the two: if (!strcmp(row[0], encryptedPass)) row[0] looks like that: $1$mYV0L3j8$nUUWy09JYrzdXurr92ywv1 salt starts with $1$ to indicate that I want an MD5 hash. Unfortunately the encryptedPass looks like that: 1ba49f4d1 ff0f49c What am I doing wrong ? Did I forget anything ? Thanks ... - Wed, Sep 22 2004 4:47 pm 3 messages, 3 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/b3cf3a3900fa6904 Problem with DO-WHILE Loop - all new ---------------------------------- On 21 Sep 2004 04:12:12 -0700, [EMAIL PROTECTED] (ranjeet) wrote: ... And what happens if the user happens to type in multiple characters before hitting enter? <<Remove the del for email>> ... - Wed, Sep 22 2004 6:02 pm 1 message, 1 author http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/ca04bd76119d745a Beta testers needed - C to Java byte-code compiler/IDE - all new ---------------------------------- We are inviting beta testers for our MPC (Multi Platform C) compiler/IDE. MPC compiles C programs and generate Java byte-code. This allows users to develop platform independent software without having to learn or use the Java programming language. The C language implemented is a large subset of ANSI C ( 1989). Currently the compiler/IDE only works on the Linux platform but we intend to port it to other platforms in the near future. Hardware Requirements : -Any x86 compatible personal computer/workstation.... - Wed, Sep 22 2004 9:00 pm 1 message, 1 author http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/356fa865148069dc #ifdef - all new ---------------------------------- On Fri, 17 Sep 2004 10:12:39 -0000, Benjamin Ketcham ... there is a third possibility -- they may be "builtin" to the compiler, which may mean actually hardcoded or simply set somewhere in the compiler installation. For the particularly flexible and common case of gcc, this is in a file (usually?) in a place something like described in the compiler's documentation. <snip> ... dump out macros at the end of compilation -- which if you compile a (perhaps dummy) program that doesn't (significantly) change the builtins and system settings, will show you... - Wed, Sep 22 2004 10:07 pm 1 message, 1 author http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/3bd78f7e89e53da8 Q: Type'ing the infamous 'flags' field - all new ---------------------------------- ... ... Concur. And FWIW Ada has language-defined (standardized) interface to C. And Fortran and COBOL, which are less likely to be useful in a lowlevel hardware application. The GNU implementation GNAT also does C++ (g++) and will "play fairly nicely" in a C main -- I don't know about others -- but the OP said elsethread he isn't using GNU. ... "integer-like" class containing inlined methods, which would as you say actually compile the same as integers but with added type checks. Or in C++ you can just use enum types. Unlike... - Wed, Sep 22 2004 10:07 pm 1 message, 1 author http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/48da03290ab348d5 newbie-question: comments - all new ---------------------------------- ... Because they don't nest. This doesn't quite work, because the comment terminates at the first occurence of */. /* int x; /* This is a comment. */ */ ... A common way of commenting out regions of the source is to use `#if 0': ... This requires manual labor to remove the #if 0 blocks later on, but it shouldn't be much of a problem for regions of the source that are known to be buggy or even not C code at all. For parts of the source that are working fine but depend on some host system characteristic a properly... - Wed, Sep 22 2004 10:21 pm 1 message, 1 author http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/3f86f8e58946e4ac calling fopen using function - 3 new ---------------------------------- Hi, I'm a newbie compiling the following program on Sun Solaris platform for reading data from a file. The code commented as "/* WORKING */" is working (!). But in the current form of open_file(), it is generating coredump (no warnings while compiling): ... /* WORKING FILE *open_file(char *fname_tmp) { FILE *fptr_tmp ; fptr_tmp = fopen(fname_tmp,"r") ; if (fptr_tmp == NULL) { ... void open_file(FILE *fptr_tmp, char *fname_tmp) { fptr_tmp = fopen(fname_tmp,"r") ; if (fptr_tmp == NULL) { ... void read_file(FILE * fptr_tmp)... - Wed, Sep 22 2004 11:55 pm 3 messages, 3 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/69fdf19057fd0291 ======================================================================= 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
