comp.lang.c http://groups-beta.google.com/group/comp.lang.c
Today's most active topics: * Why can't constants have commas? - 16 new http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/63c83bd31dbb075d * C to Java Byte Code - 15 new http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/88cb533585cafed4 * sorting an array of three kinds of stones - 14 new http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/7cd8153678600095 * Is this legal stuff as per C Standard? - 10 new http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/f7bf0fcaa4144b5a * Is this legal ? - 9 new http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/dbe05ac54921bc92 Active Topics ============= Is this legal stuff as per C Standard? - 10 new ---------------------------------- ... with a const-qualified type with non-const qualified type, the behaviour is undefined." So if you do it, anything might happen if you try to modify " abc" through s. Robert ... - Thurs, Oct 28 2004 2:17 am 10 messages, 7 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/f7bf0fcaa4144b5a C to Java Byte Code - 15 new ---------------------------------- In message , Galga writes ... "Something to hide"? Don't be silly, this is Usenet. ... Oh, I see. When others cross-post off-topic nonsense and *I* ask them to take it elsewhere, it's a royal decree. But when I ask people to consider where they're posting, it's OK for *you* to tell me I'm not entitled to do that. Did you ever hear that proverb about pots and kettles? ... For some value of "trying to decide" equal to "suggesting", maybe. The Followup- To header isn't some kind of... - Thurs, Oct 28 2004 2:27 am 15 messages, 9 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/88cb533585cafed4 Why can't constants have commas? - 16 new ---------------------------------- ... In C the size of an array must be constant. 1,9 is not a constant. ... - Thurs, Oct 28 2004 2:45 am 16 messages, 13 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/63c83bd31dbb075d [OT]Re: C to Java Byte Code - 8 new ---------------------------------- In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] says... ... Since the code resulting from C unions functions as *written*, the above speaks only of the incompetence of the designer. Absence of a large bandwidth double is a minor issue, which will likely be corrected in future versions if the product is successful, and in any case satisfies the criterion of "with some tweaking". On this thread you have demonstrated only egotism, incompetence, dishonesty, and (worst) vicious and unjustified bile directed at the ... - Thurs, Oct 28 2004 3:00 am 8 messages, 7 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/f0fc6e7be97f176 Some Interview Questions - all new ---------------------------------- ... Never said it was a compiler intrinsic. He was asking what a semaphore and you are right, that has nothing to do with the C standard. Was just trying to give an explanation and how it is often done ... - Thurs, Oct 28 2004 3:20 am 1 message, 1 author http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/e352a550394ff15d Is this legal ? - 9 new ---------------------------------- On 28 Oct 2004 00:08:40 -0700 ... The following is fine by C const char *const_ s = "abc"; char *s = (char *)const_s; puts(s); however, if you then do: *s= 'e'; you are invoking undefined behaviour. char *s = "abc"; *s='e'; also invokes undefined behaviour, since although string literals are not const in C any attempt to modify them invokes undefined behaviour. const char const_s[] = "abc"; char *s = (char *)const_s; *s='e'; also invokes undefined behaviour when the const data is modified. i.e. you can cast away the const without any. .. - Thurs, Oct 28 2004 3:18 am 9 messages, 8 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/dbe05ac54921bc92 Strings in C source code - 6 new ---------------------------------- ... Thank you. ... - Thurs, Oct 28 2004 4:58 am 6 messages, 5 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/5a77bf67f0cf4248 GetByte(int x, int n) - 3 new ---------------------------------- ... Sorry, I get left and right mixed up too much on this newsgroup. A right shift can result in negative zero. (1000...0001 >> 1) can be (1000...0000), - 0 in signed magnitude (1111...1110 >> 1) can be (1111...1111), -0 in one's complement ... - Thurs, Oct 28 2004 5:07 am 3 messages, 3 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/c5aa5da0d5dfa7f0 keyboard driver code for XP - 4 new ---------------------------------- Hi ppl, I am looking for the code of Microsoft Standard Keyboard driver. If you have any idea how can I achieve it please email me the link or send me the code to my email. I have searched all over the internet - with no result. I hope that somewhere, there is a brilliant programer that has this code. ...... - Thurs, Oct 28 2004 5:19 am 4 messages, 3 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/5b72ee35965f0c8c access union member via ptr - all new ---------------------------------- In DR#236 (recently brought about in "contiguity of arrays" thread) at the end ("Committee Discussion") it has been said that Example 2 is invalid, because it violates 6.5#7. I kindly ask you to explain exactly why. My (counter) arguments: 6.5#7 talks about accessing a *value*, whereas in Example 2 a new value is stored, without accessing the previous one. (In the corrected example in the DR it's been explicitly said: "union type must be used when changing effective type" - I don't see how 6.5 backs it up.)... - Thurs, Oct 28 2004 5:33 am 1 message, 1 author http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/3b0f4f0fd69d5627 Pointer Guide Nearing Completion - 3 new ---------------------------------- ... Bingo. ... True, but my main point was that NULL is not a pointer, neither a pointer object nor a pointer value, but a macro. A bit of text in your source code. Null pointers point at no object; a null pointer constant does not point. Confusion between null pointers and null pointer constants is probably the greatest cause of problems people have with null pointers. Richard ... - Thurs, Oct 28 2004 6:30 am 3 messages, 3 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/3aeeb768080be25b derangement: code review request - 4 new ---------------------------------- ... Whatever. It's still an abbreviation, and avoiding abbreviations would have been counterproductive, in this case. ... It's ugly. It splits the type of the function over two lines for no good reason (antediluvian editors are no excuse), and separates the return type from the identifier in a way that nobody would even consider using for objects. You don't write int i, j, counter; do you? Well, then, why do so for functions? ... Thankfully, yes. It's been quite well proven (for centuries; spacing is not something that is unique to source code)... - Thurs, Oct 28 2004 6:35 am 4 messages, 4 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/63c5271ccb9149a Linked List problem. - 2 new ---------------------------------- ... Thanks to all who have been advising and sorry for the long overdue reply. My question is all about casting and pointers and what conditions allow it. Please correct my following assumptions, 1) Int can be casted into a char int i=0; char a; a=(char *) i; 2) Structure casted into an array of char typedef struct { char name[20]; int age; int id; ... person p = (person *) malloc( sizeof(person)); p.name="hello"; p.age=2; p.id=2; char *a; a=(char *)p; ... - Thurs, Oct 28 2004 6:38 am 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/7db25f536a8a0c30 Binary files, little&big endian setting bits - 5 new ---------------------------------- Hi, i know this is an old question (sorry) but its a different problem, i need to write a binary file as follows ... program will be compiled in Microsoft Visual C++ was thinking of just writing it as chars (afaik chars are the only unsigned int thats only 1 byte) so basicly i'll be writing 3,0,0, 5,0,256,256,0 question is if i write a file like that will it come out as the bits above, does VC++ write little or big endian and other than endian issues if it doesn't come out as above, why not?? ... - Thurs, Oct 28 2004 6:53 am 5 messages, 5 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/df8099a70cd0a5a8 test - all new ---------------------------------- sorry .. test ... - Thurs, Oct 28 2004 7:13 am 1 message, 1 author http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/42f0082af5c883af detect recursive C code - 4 new ---------------------------------- Hi all, is there a good way to detect recursive C code in large systems? A method or a free tool? Best regards, E ... - Thurs, Oct 28 2004 7:18 am 4 messages, 3 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/4ec4eb836acd9e9d URGENT: Need help in setting environment variable.. pls help - 2 new ---------------------------------- Hey all: I need urgent information how to set the environment in Visual.NET wiritng in C. I am working with a licensed version of the Analyze 6.0 software from mayo clinic. I need to write code in C using AVW functions that are licensed by Mayo clinic. In order to access the AVW library of functions, I need to set the environment to look at the license file through my C code. The syntax to set the environment is something like: set "variable" = "path". I tried doing this but it gave me a lot of errors. Could someone please offer me a soln. ... - Thurs, Oct 28 2004 7:35 am 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/7b046388537281fb resolving a warning error - 6 new ---------------------------------- ... By using `int someFunc(void);' instead. "But I'll lose type safety!" Well, no. In the first place, there's almost no type safety to begin with: C's enums are pretty weak. In the second place, if you intend to hide the enum's values from someFunc(), what will its `return' statements look like? Where are you going to get a known-to-be-valid value? Copy it from a global? Bah! Or perhaps you intend to reveal the enum values to someFunc( ) but hide them from someFunc()'s callers. What's the point of that? It means that all the... - Thurs, Oct 28 2004 8:22 am 6 messages, 4 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/51163699c4d6ba84 couple of questions on streams - 3 new ---------------------------------- ... Eric has kindly demolished most of this already, but I thought it worth pointing out, for any readers who might be laboring under the same misapprehensions as Malcolm, that many C implementations today still run in environments with both "low-level" and "high-level" I/O, and with "buffered" and "unbuffered" I/O, and where it is still as easy as it ever was to "tweak" the "low-level" flavors of I/O. Further, while anyone certainly may assume that a given C stdio implementation is "as efficient[] as humanly... - Thurs, Oct 28 2004 8:09 am 3 messages, 3 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/999c750f9c648b21 Reduce duplication - all new ---------------------------------- ... or from UNIX/LINUX command line (sort first) etc. In C, one way (little bit clumsy, but works) is this: ... typedef struct lNode { ... lNode *append (lNode *p, char val[5]) { lNode *last = p; while (p) { ... { ... { // First node ... void list_print(lNode *list) { ... int main (void) { lNode * head = NULL; lNode *node, *p; FILE *fin = fopen("a.txt", "r"); FILE * fout; char line[5]; int i; // Make a linked list with words for (i = 0; (i < 50)&&!feof(fin); i++) { ... printf("The list:\n"); list_print( head);... - Thurs, Oct 28 2004 8:21 am 1 message, 1 author http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/fbc6bca4ea8e5582 Commenting the source code. - 2 new ---------------------------------- ... Wishful thinking. When the code is generated by a hand-written utility you don't even know what went wrong: a bug in the utility or a bug into the source code processed by the utility. You have to compare the ugly C code with the source code it came from and try to figure out what went wrong, which is seldom an easy job: it's like debugging a C program by examining the assembly output of the compiler and trying to figure out whether the bug was in the C code or in the compiler. ... Guess who introduced them in this thread?... - Thurs, Oct 28 2004 8:32 am 2 messages, 1 author http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/f8fb8ea8330fb9ef Infinite loop problem in linklist - 6 new ---------------------------------- I want to just create a linklist.The program below goes into an endless loop. The srange behaviour is that i can exit from the program if i create only two nodes.After two goes into infinite loop. ... { int data; struct node* next; . .. int create (sn *); //int add(sn *); //int delete(sn *); //int length(sn *) ; int main() { sn *head; printf("Create a list"); head =(sn*)malloc(sizeof(sn)) ; create(head); return 0; ... int create(sn *temp) { int i=0; printf("Enter data element:"); scanf("%d",&temp->data); printf("To continue press 1:");... - Thurs, Oct 28 2004 8:51 am 6 messages, 4 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/587befc5e360a488 What is multithread safety - 8 new ---------------------------------- ... ... It also means avoiding *any* library function: 4 The functions in the standard library are not guaranteed to be ... Dan... - Thurs, Oct 28 2004 10:03 am 8 messages, 7 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/a349b9ed0d65f0d3 vulnerabilities - 2 new ---------------------------------- ... You were supposed to be able to figure out the rest by yourself. Too bad you weren't. Dan... - Thurs, Oct 28 2004 9:58 am 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/5f5c39262f0a735e Why will this not generate a random number!? - 3 new ---------------------------------- ... Is it really *any* key, or only *some* keys? If the latter, then a function waiting for a well defined key is preferable. Dan... - Thurs, Oct 28 2004 10:14 am 3 messages, 3 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/2fc74627d42f41a sorting an array of three kinds of stones - 14 new ---------------------------------- There are three kinds of stones: red,green and blue. Each cell of the array contains one stone. The array needs to be sorted so that all the red stones will come first, then the blue ones and then all the green ones. There are N stones, as the number of cells in the array. switch(i,j)- switch the stone in the i-th place with the ... These functions can be used only N times. please help me,I tried to reach a proper solution but with no success. ... - Thurs, Oct 28 2004 10:53 am 14 messages, 10 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/7cd8153678600095 implementation of rand() ? - 5 new ---------------------------------- Hi, What is the implementation of rand() on say visual c/c++ 5 or 6 ? Another question... is this rand() implementation the same on any other platforms/compilers/libraries ? Where can I find/look at the implementation of rand() ? Thx for any help. Bye, Skybuck. ... - Thurs, Oct 28 2004 12:37 pm 5 messages, 4 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/ae4fdf62de7661b6 Reading from file - 2 new ---------------------------------- Im trying to read from a file but I want to take out the break statements and not have an infinite loop that only stops on breaks. for(;;) ... ... ... loop for while(EOF) it wouldn't get all the information in the file. ... - Thurs, Oct 28 2004 12:37 pm 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/9d8089825f4410a3 rand() implementation - all new ---------------------------------- I found some rand source code on this link: http://www.codeguru.com/forum/ showthread.php?t=312416&goto=nextnewest void __cdecl srand (unsigned int seed) { ... int __cdecl rand (void) { ... return( ((ptd->_holdrand = ptd->_ holdrand * 214013L + 2531011L) >> 16) & 0x7fff ); ... So I tried to re- create the rand() function like this on visual c/c++ 6: int holdrandbla = 0; int bla() { return(((holdrandbla = holdrandbla * 214013L + 2531011L) >> 16) & 0x7fff); ... int main() { printf("blablabla started \n"); printf("blabla1: %d \n", rand() );... - Thurs, Oct 28 2004 12:59 pm 1 message, 1 author http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/1e7efe7ef4874a38 Extract a function from C code? - 5 new ---------------------------------- I have a C/C++ file that I simply want to 'extract' a function from. Something like: extract <function name> <c or cpp file> I want it to return from the beginning of the function, to the end. I tried cscope, and that will find the function, but it won't tell me how many lines it is or extract it for me. Any ideas on what I could use? It would also be awesome if I could choose to extract struct definitions, multi-line macro defs, etc. [EMAIL PROTECTED] .. . - Thurs, Oct 28 2004 12:58 pm 5 messages, 5 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/142137b736cb8ea0 What is returned ? - 3 new ---------------------------------- Hi, I have a C question. Let's assume MT is not defined int holdrand = 1; int __cdecl rand (void) { ... return( ((ptd->_holdrand = ptd->_holdrand * 214013L + 2531011L) >> 16) & 0x7fff ); ... I have trouble understanding what this function returns. My confusion is with this line: return((( holdrand = holdrand * 214013L + 2531011L) >> 16) & 0x7fff); Apperently this line assigns some value to holdrand. Something like: holdrand becomes holdrand * blablabla etc. But what is returned ? I think it returns holdrand after the... - Thurs, Oct 28 2004 4:19 pm 3 messages, 2 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/eb30cb05005855e How to call a shell command within C? - 4 new ---------------------------------- I remember that there is a function that could invoke shell command such as " rm" "cp", directly in .c file. But I could not recall its name, and I googled with nothing meaningful. I vaguely remember it is like: foo("cp file1 file2"); it is that simple, but cant remember. Could anyone here give me a clue? Thank you very much. ... - Thurs, Oct 28 2004 10:55 pm 4 messages, 4 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/cd7d40b3c74475c9 How to delete files in a sub directory - 2 new ---------------------------------- I am new to dealing with the file system using C. And couldnt find anyone in my office to help me out. :( okay here is my questions. If I want to delete a file in a directory other than my working directory, I would construct a string look like this: add use "remove(str);" to delete this file. A lot of my work involves constructing the directory string, so I wonder if this is a common practice of deleting files in C. Do you guys have better ways of performing this task? Thank you. ... - Thurs, Oct 28 2004 11:15 pm 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.c/browse_thread/thread/659ee200a6137528 ======================================================================= 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
