comp.lang.c http://groups-beta.google.com/group/comp.lang.c
Today's most active topics: * macro style guideline - 7 new http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/7986dd853067c85d * Bus Error asprintf. OS X 10.3.6. gcc 3.3 - 6 new http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/c3dc7ee1e05d7918 * Is FALSE == 0? - 5 new http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/ead0b78fb064b276 * Macro without string to substitute - 5 new http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/d80d84271dca55a * call to malloc with size 0 - 4 new http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/ac4d191d274907c6 Active Topics ============= call to malloc with size 0 - 4 new ---------------------------------- Herbert Rosenau scribbled the following: ... Furthermore, Trollsdale used the wrong type in his sizeof operation. The correct type would be what the pointer points at, not the pointer type itself. sizeof *p would have worked much better. ... - Sun, Nov 21 2004 1:17 am 4 messages, 3 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/ac4d191d274907c6 getc and ungetc - 2 new ---------------------------------- On Thu, 18 Nov 2004 20:21:41 UTC, "Bill Cunningham" wrote: ... Yes. But be aware of that ungetc can only unget ONE char at a time. On other hand you can simply by macro or function extend getc and ungetc to unget more than one char. Your UNGETC() would accept a number of chars to give back in your GETC() in reverse order. Your GETC() will give back the chars UNGETC had received before it gets new chars from the stream itself. A bit tricky is to ungent a char that you have never gotten - legally ... - Sun, Nov 21 2004 1:44 am 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/d9a46731ea9ea57c fast array copy - all new ---------------------------------- On Thu, 18 Nov 2004 20:43:46 UTC, [EMAIL PROTECTED] (simkn) wrote: ... No, a pointer NOT an array and an array is NOT a pointer. An Array is an array - even as the address opf an array(member) is a pointer. For example: ... You describes lists, not arrays, sou you should create a list of objects instead an a simple array, because reordering or resizing a list is much easier than reordering an array. There are some types of lists you can use depending on the type of work you have to do on: - single linked list: designed to work... - Sun, Nov 21 2004 2:07 am 1 message, 1 author http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/e6036b4e733b6e1a how to do this? - all new ---------------------------------- On Thu, 18 Nov 2004 22:25:45 UTC, "Fan Zhang" wrote: Please stop top posting! ... Write wrappers to the fuctions using less parameters than the one with the most number of parameters. There is no problem to give a fuction more parameters as it will access - but the parameters have always to match in number and type. You may change the interface to newfoo agin e.g.: double newfoo(double p1, double p2, unsigned int index) { ... kk += wrapit( index, double p1, double p2, <more parameters one of ... - Sun, Nov 21 2004 2:39 am 1 message, 1 author http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/8d010b8ce5211f65 Is FALSE == 0? - 5 new ---------------------------------- On 20 Nov 2004 21:10:57 -0800, in comp.lang.c , [EMAIL PROTECTED] (Old ... Incorrect. false is a macro defined as zero in stdbool.h Note however this final sentence: "Notwithstanding the provisions of 7.1.3, a program may undefine and perhaps then redefine the macros bool, true, and false" ... - Sun, Nov 21 2004 3:17 am 5 messages, 4 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/ead0b78fb064b276 macro style guideline - 7 new ---------------------------------- I wanted a suggestion regarding the following macro. I have to check the existence of some element in a 2D array, Which of the following would be the best way to write 1.) pass the array name, row and col ... 2.) pass only the row and col ... 3.) No arguments ... -- Vyom ... - Sun, Nov 21 2004 6:00 am 7 messages, 5 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/7986dd853067c85d Typedef with GCC/G++ - 4 new ---------------------------------- ... Well, actually, they don't. But they're not very useful this way. The following code snippet only yields one "shy" warning with gcc: ... struct ohmy { ... int main(int argc, char **argv) { struct ohmy sFunOne; char aEvenFunnierOne[0]; memcpy(&sFunOne, aEvenFunnierOne, sizeof(struct ohmy)); return 0; ... gcc -c -Wall test4.c test4.c: In function `main': test4.c:14: warning: statement with no effect ... - Sun, Nov 21 2004 7:29 am 4 messages, 3 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/57cceab6ca5afdf0 How to check the lock status? - all new ---------------------------------- ... You need to ask the newsgroup of the operating system you are asking about. It can be any of the following (as stated in the "Welcome to comp.lang.c!" posting): ... You should refer it to EOF, not -1. While not critical, it does help provide the context at which a '-1' will appear. In addition, you really should provide the name of the function you are using to read - for example, if you are using the fgetc() function or something else. ... - Sun, Nov 21 2004 8:56 am 1 message, 1 author http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/53ffdd4671f0e866 Bus Error asprintf. OS X 10.3.6. gcc 3.3 - 6 new ---------------------------------- ... Here's where I'm stuck. Comments and questions below. ... int main(void) { int i,buysfor[FAMSIZ]; /*initialize*/ for (i = 0; i < FAMSIZ; ++ i) buysfor[ i] = i; increase(MANGO); /* to console */ printf(" tja %3d\n", &buysfor[0]); return 0; ... int i; for (i = 0; i < FAMSIZ; ++ i) buysfor[i] = buysfor[i] + MANGO; return &buysfor[0]; ... This doesn't compile, but, believe it or not, represents a serious effort on my part to do so. What I'm trying to do is have a function RETURN a pointer to an int, in this case, the int is the first. .. - Sun, Nov 21 2004 9:26 am 6 messages, 2 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/c3dc7ee1e05d7918 i need help with this card game! - all new ---------------------------------- "Malcolm" ... to be talking to a wonderful lady who was a Harvard-trained statistician, and she described to me in great detail how they programmed such derangements in machine (not even assembly) code on the vacuum-tube machines. And most people think of C as a low-level language! MPJ ... - Sun, Nov 21 2004 9:38 am 1 message, 1 author http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/f99746be0e7010af Stacktrace code snippet? Like gdb's "bt" - 2 new ---------------------------------- Does anyone know about a code snippet that can be used to output a backtrace just like gdb's "backtrace" command does. One that can be called on a segmentation fault. (without resolving symbol names, just simple list of frames until the main() stack frame) ... - Sun, Nov 21 2004 10:56 am 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/9cf54c25773349ba Macro without string to substitute - 5 new ---------------------------------- Hello!!! I have been using C for a very short while. I am used to macros in C, but while i was reading the code for LittleOS (an open source OS), i came across a type of macro wherein no value was given to substitute the text. What does this imply? The code i came across is as follows: ... struct time { int sec, min, hour; ... struct date { int dayofweek, day, month, year; ... void gettime(struct time*); void getdate(struct date*); ... what does this do? Please Help Casanova... ... - Sun, Nov 21 2004 11:00 am 5 messages, 4 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/d80d84271dca55a Odd preprocessor behaviour? - all new ---------------------------------- Is the following code standard-compliant, and if so what should it do? And where in the standard defines the behaviour? ... int main(void) { ... How about the following code? ... int main(void) { ... As far as I can see the relative precedence of the join (##) operator and the defined operator (in an #if) are not stated anywhere. (Incidentally, using GCC 2.95.4 the first example works and parses the 'defined' in the macros as an operator in the #if and as an identifier (variable) in the printf statement. The... - Sun, Nov 21 2004 2:19 pm 1 message, 1 author http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/359d46ae1ae9547c Question about storing a maze board(like 2d array) into Tree. - all new ---------------------------------- ... How about a clue as to what kind of "doesn't work." ... The program is not that big. Did you use your degbugger to step through it? Your algorithm is flawed. Let's set up some notation: p{i} will be the local automatic variable p created for the i-th recursion of BuildTree. x{i}, and y{i} are the actual arguments passed to BuildTree on the i-th recursion. ... Hiding a pointer type inside a typedef or macro just leads to confusion. Consider the standard macro FILE. Even though a user never needs an object of type FILE but only... - Sun, Nov 21 2004 4:42 pm 1 message, 1 author http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/3355ffa7be5f95d5 a[3] <===> *(a + 3) ??? - all new ---------------------------------- Groovy hepcat KKramsch was jivin' on Thu, 18 Nov 2004 13:59:50 +0000 (UTC) in comp.lang.c. a[3] <===> *(a + 3) ???'s a cool scene! Dig it! ... No. ... Yes. Try the following code: ... void f(void) { ... /* Do something to the array. */ strcpy(a, "ab"); puts(a); ... int main(void) { f(); return 0; ... Compile this program. Does it compile? Next, put the directive "#define FOO" at the top of the code. Now, try compiling again. What happens? Does it compile this time? ... - Sun, Nov 21 2004 6:36 pm 1 message, 1 author http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/12202735902b4eac a simple c code - all new ---------------------------------- ... Sent: Sunday, November 21, 2004 3:09 AM ... ... Hi You code will give problem in files like this Test File //fsdfsf Test File // And if we modify the inner loop something like this while((c=fgetc(file))!='\n' && c!='\r' & & c != EOF) ; if(c == EOF)break; it works fine ... - Sun, Nov 21 2004 7:19 pm 1 message, 1 author http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/23e78ce738c982fb Handling text with C? - all new ---------------------------------- On Tue, 16 Nov 2004 15:06:36 -0500, Eric Sosman wrote: ... is of type int or a type that default-promotes to int, or is or promotes to unsigned int with a value in range of signed int; or failing that its value is in range and you add a cast. Alternatively it can be replaced by fwrite (buf, /* can swap these two: */ 1, sz, stdout) on only the condition that sz "fits in" size_t, and if it doesn't any decent compiler can and will give you a warning. ... Agree there. :-) - David.Thompson1 at worldnet.att.net... - Sun, Nov 21 2004 10:15 pm 1 message, 1 author http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/fc662b477263b5f6 Directory/File recursive listing using standard/portable C? - all new ---------------------------------- On 17 Nov 2004 19:43:04 GMT, [EMAIL PROTECTED] (Michael Wojcik) wrote: ... And to avoid being forgotten, the Guardian personality/mode of Tandem^WCompaq^ WHP NonStop, which is still used and needed for some new applications because it provides features the POSIX personality cannot although the overwhelming majority of applications are legacy, has exactly two levels of directory per disk (or pseudodisk) -- or actually, two levels of naming in a global directory rather like the OS/360-et-seq system catalog. Thus you can... - Sun, Nov 21 2004 10:15 pm 1 message, 1 author http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/6bb13eb49896e55a char array initialization: Is 'char a[] = ("a")' valid ANSI C? - all new ---------------------------------- On 18 Nov 2004 16:19:28 GMT, [EMAIL PROTECTED] (Michael Wojcik) wrote: ... a distinctive kind of value -- an anonymous static-duration array that may be shared, must not be written, but isn't const. Nothing else does quite this, although C99 compound literals (or their GCC equivalent, constructor expressions) are very close. ... static char foo [7]; char (* bar (char * unused)) [7] { return &foo; } * bar ("ABC") /* is a char array that you can access safely */ foo + strspn ("DEF", "ED") /* is a pointer,... - Sun, Nov 21 2004 10:15 pm 1 message, 1 author http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/2f5945f014c2cbd0 convert 'C' code to 'Fortran' - all new ---------------------------------- ... has pointer arithmetic, except that I hear it has been added (I think implementation-dependently) to PL/I more recently than the last time I used it seriously. Ada's primary form of pointers, access types, are opaque but it has standard syntax for conversion to and from 'address' types that support some arithmetic. F90 POINTERs are unusual -- AFAIK unique -- in that for arrays they are full dope vectors that can designate noncontiguous slices. - David. Thompson1 at worldnet.att.net ... - Sun, Nov 21 2004 10:15 pm 1 message, 1 author http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/7d307a1eec1f217a address of a statement in C - all new ---------------------------------- ... Suppose the function converts UTF-8 into Unicode points. Most of the time it takes just one byte, sees the high-order bit zero, and so it's a single- byte ASCII character. Once in a while it sees the high-order bit one, and so it's the start of a multi-byte representation of a non-ASCII Unicode character, so it must do i++ one or more times to gobble additional byte(s) before finishing this trip through the loop. [first idea] Upon exiting the loop, you need to check whether i is really exactly what you expected it to be,... - Sun, Nov 21 2004 10:33 pm 1 message, 1 author http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/9c7bf5671accbcf6 How does C cope if architecture doesn't address bytes? - all new ---------------------------------- ... Right, on my TMS320C5402 DSP char, short and int are all 16-bits. C is not at all a problem here. Its still, the plain old C. Well if U want to get how many bits, a byte consists of on Ur platform: printf("sizeof(char) = %d\n ", sizeof(char)); printf("Number of bits in a Byte = %d\n", CHAR_BIT); In my case output is : sizeof(char) = 1 Number of bits in a Byte = 16 Byte is simply a byte, it can consists of "n" bits. this is especially important when U R in embedded... ... Exactly, I've to take care when interfacing... - Sun, Nov 21 2004 11:27 pm 1 message, 1 author http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/30200c2a3cb93e0a ======================================================================= 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
