[c-prog] Re: Help in finding crash cause in given peace of code.

2009-08-13 Thread John Matthews
--- In c-prog@yahoogroups.com, Ravi Mishra ravics...@... wrote: Please help me and provide your suggetion for finding the cause of crash dump. Suggestions: 1. Put comments in your code. Then we (and you) might all have a better chance of understanding what the code is doing. 2. Use the

[c-prog] Re: Help in finding crash cause in given peace of code.

2009-08-13 Thread John Matthews
--- In c-prog@yahoogroups.com, John Matthews jm5...@... wrote: --- In c-prog@yahoogroups.com, Ravi Mishra ravicse04@ wrote: Please help me and provide your suggetion for finding the cause of crash dump. Suggestions: 4. Your MacCommon type appears to contain 2 arrays, both indexed

[c-prog] Re: Help in finding crash cause in given peace of code.

2009-08-13 Thread John Matthews
--- In c-prog@yahoogroups.com, John Matthews jm5...@... wrote: Suggestions: 6. Does timerStartInst_ms() take a void* argument in the 4th parameter? If so, then you should not be casting to void* (assuming you are using a C compiler) - no cast is required, and adding one just complicates

[c-prog] Re: Help in finding crash cause in given peace of code.

2009-08-13 Thread John Matthews
--- In c-prog@yahoogroups.com, John Matthews jm5...@... wrote: --- In c-prog@yahoogroups.com, John Matthews jm5678@ wrote: 5. Your code is made more difficult to understand (and hence maintain/debug) by the length of the lines. You should use pointers - combined with the typedef in (4

[c-prog] Re: plz solve

2009-08-07 Thread John Matthews
--- In c-prog@yahoogroups.com, Uday Oberio uday_obe...@... wrote: i have one question that is float a=1.1; double b=1.1; if(a==b) printf(hello); else printf(how are u ); now tell me which part will be executed and why ? Paul's link gives the full answer, but in simple terms there

[c-prog] Re: moving average problem

2009-07-22 Thread John Matthews
--- In c-prog@yahoogroups.com, peternilsson42 peternilsso...@... wrote: I have used 8MB implementations where int was still only 16-bit. I dare say there are some embedded environments where this is still the case. Yep. You could argue that size_t may have performance issues because it is

[c-prog] Re: QA vs Development

2009-07-22 Thread John Matthews
--- In c-prog@yahoogroups.com, Anusha K una_...@... wrote: Is QA (quality assurance/testing) job better than development job .. or vice-versa pls tell me?? Surely that largely depends on which you prefer doing. Or don't you have a preference?

[c-prog] Re: moving average problem

2009-07-21 Thread John Matthews
--- In c-prog@yahoogroups.com, Christopher Coale chris95...@... wrote: double Sma(double *ds, int size) A slight improvement is: double Sma(const double *ds, int size) The const tells the compiler and the reader that the function isn't supposed to modify the data at ds; it is 'constant'. For

[c-prog] Re: function pointers

2009-07-18 Thread John Matthews
--- In c-prog@yahoogroups.com, Bill Cunningham bill...@... wrote: I would like to start writing code and calling functions in C code with a pointer to a function. This so I can learn functions pointers. Simple example: #include stdio.h static void inc(int *p) /* increment */ { (*p)++;

[c-prog] Re: Bug finding contest for C experts

2009-07-15 Thread John Matthews
--- In c-prog@yahoogroups.com, Ravi Mishra ravics...@... wrote: for (delIndex = rachQIndex; delIndex rachTxQueue-n; delIndex++) { rachTxQueue-queue[(delIndex + rachTxQueue-start) % (petMaxUEInstancePerProcess+1)] = rachTxQueue-queue[(delIndex + rachTxQueue-start + 1) %

[c-prog] Re: Bug finding contest for C experts

2009-07-15 Thread John Matthews
--- In c-prog@yahoogroups.com, John Matthews jm5...@... wrote: --- In c-prog@yahoogroups.com, Ravi Mishra ravicse04@ wrote: for (delIndex = rachQIndex; delIndex rachTxQueue-n; delIndex++) { rachTxQueue-queue[(delIndex + rachTxQueue-start) % (petMaxUEInstancePerProcess+1

[c-prog] Re: Bug finding contest for C experts

2009-07-15 Thread John Matthews
--- In c-prog@yahoogroups.com, John Matthews jm5...@... wrote: Also, rachQIndex should *not* be incremented at the end of the loop if the UE is deleted ...or should there just be a break to exit the loop when the UE is deleted?

[c-prog] Re: Process creation in Unix with C Program

2009-07-11 Thread John Matthews
--- In c-prog@yahoogroups.com, Sudipta Deb dsudipta.1...@... wrote: How can i print parent's PID from child's and vice versa. int main(void) { pid_t pidParent, pidChild = fork(); const char *who; if (pidChild == 0) { who = child; pidChild =

[c-prog] Re: Process creation in Unix with C Program

2009-07-11 Thread John Matthews
--- In c-prog@yahoogroups.com, John Matthews jm5...@... wrote: #include stdio.h #include sys/types.h #include unistd.h int main(void) { :

[c-prog] Re: Volatile variable in C

2009-06-11 Thread John Matthews
--- In c-prog@yahoogroups.com, peternilsson42 peternilsso...@... wrote: --- In c-prog@yahoogroups.com, John Matthews jm5678@ wrote: peternilsson42 peternilsson42@ wrote: I haven't seen a system where this will seriously fail, but I prefer... printf(reg = %u\n, 0u + *reg

[c-prog] Re: Volatile variable in C

2009-06-10 Thread John Matthews
--- In c-prog@yahoogroups.com, Sharma, Hans Raj \(London\) hansraj_sha...@... wrote: Can someone please help me understand how can I write a program which, using volatile variable, access some memory mapped devices? If you have an 8 bit register at address 0x1234 containing an unsigned 8 bit

[c-prog] Re: Volatile variable in C

2009-06-10 Thread John Matthews
--- In c-prog@yahoogroups.com, John Matthews jm5...@... wrote: --- In c-prog@yahoogroups.com, Sharma, Hans Raj \(London\) hansraj_sharma@ wrote: Can someone please help me understand how can I write a program which, using volatile variable, access some memory mapped devices

[c-prog] Re: Volatile variable in C

2009-06-10 Thread John Matthews
--- In c-prog@yahoogroups.com, Sharma, Hans Raj \(London\) hansraj_sha...@... wrote: Just one doubt, are you talking about CPU registers below? Can we get address of them? How? I was talking about registers in your memory mapped device; you have to know the memory location of your memory

[c-prog] (unknown)

2009-06-10 Thread John Matthews
--- In c-prog@yahoogroups.com, iamwljiang iamwlji...@... wrote: you will know macro swap(a,b) just execute temp = a; behind this not execute. temp = a; is the only bit of the macro that isn't executed for the given values of i and j; it's a=b;b=temp; that is executed: a=b = i=j = i=10 b=temp

[c-prog] Re: Volatile variable in C

2009-06-10 Thread John Matthews
--- In c-prog@yahoogroups.com, peternilsson42 peternilsso...@... wrote: I haven't seen a system where this will seriously fail, but I prefer... printf(reg = %u\n, 0u + *reg); Haven't seen that before - thanks.

[c-prog] Re: unpredictable OUTPUT????

2009-06-08 Thread John Matthews
--- In c-prog@yahoogroups.com, piyush_4love_4ever piyush_4love_4e...@... wrote: using TerboC/C++ # define swap(a,b)temp=a;a=b;b=temp; void main() { int i=5,j=10,temp=0; if(ij) swap(i,j); This is the same as: if (i j) temp = i; i = j; j = temp;

[c-prog] Re: unpredictable OUTPUT????

2009-06-08 Thread John Matthews
--- In c-prog@yahoogroups.com, iamwljiang iamwlji...@... wrote: don't forget () #define swap(a,b) (temp=a;a=b;b=temp;) That doesn't compile. See http://tech.groups.yahoo.com/group/c-prog/message/70718

[c-prog] Re: unpredictable OUTPUT????

2009-06-08 Thread John Matthews
--- In c-prog@yahoogroups.com, Sharma, Hans Raj (London) hansraj_sha...@... wrote: Proper way of defining # define swap(a,b){temp=a;a=b;b=temp;} No it isn't - the following doesn't compile: if (i j) swap(i, j); else printf(no swap\n); You could put do .. while (0) outside the braces,

[c-prog] Re: unpredictable OUTPUT????

2009-06-08 Thread John Matthews
--- In c-prog@yahoogroups.com, tan_backagain tan_backag...@... wrote: --- In c-prog@yahoogroups.com, piyush_4love_4ever piyush_4love_4ever@ wrote: using TerboC/C++ # define swap(a,b)temp=a;a=b;b=temp; TANMAY:: Just add braces #define swap(a,b) {temp=a;a=b;b=temp;}

[c-prog] Re: unpredictable OUTPUT????

2009-06-08 Thread John Matthews
--- In c-prog@yahoogroups.com, John Matthews jm5...@... wrote: or add an else after the closing brace (although that can result in an 'empty else' compiler warning from gcc) Sorry- ignore that; I was thinking of situations where the 'if' is inside macro.

[c-prog] Re: unpredictable OUTPUT????

2009-06-08 Thread John Matthews
--- In c-prog@yahoogroups.com, John Matthews jm5...@... wrote: --- In c-prog@yahoogroups.com, John Matthews jm5678@ wrote: or add an else after the closing brace (although that can result in an 'empty else' compiler warning from gcc) Sorry- ignore that; I was thinking of situations

[c-prog] Re: unpredictable OUTPUT????

2009-06-08 Thread John Matthews
--- In c-prog@yahoogroups.com, WLJiang WLJiang iamwlji...@... wrote: O,the right is #define swap(a,b) {temp=a; a=b; b=temp;} No it isn't - see previous posts.

[c-prog] Re: death of recursion?

2009-06-04 Thread John Matthews
--- In c-prog@yahoogroups.com, Olufowobi Lawal wolex...@... wrote: So that left me wondering if recursion is in same category as goto , know it, but don't use it. or are there some instance or some way where they can be used effeciently, like in my case? I don't think your case is a good

[c-prog] Re: confusing output

2009-05-30 Thread John Matthews
--- In c-prog@yahoogroups.com, Ahmed Mahmoud eng_hamada2...@... wrote: You are right but if you read my message you will find that i substituted with m=5 so i got this If you replace the variable with a number in the C code, it isn't a valid expression. If you assign the number to the

[c-prog] Re: confusing output

2009-05-29 Thread John Matthews
--- In c-prog@yahoogroups.com, Ahmed Mahmoud eng_hamada2...@... wrote: i hope you read them -this is true as i tried them many times if you have another opinion illustrate it In the expression: v=(m++)+(++m); the value of v depends on the order of evaluation. Therefore the result is

[c-prog] Re: confusing output

2009-05-28 Thread John Matthews
--- In c-prog@yahoogroups.com, Arvind Balodia arvind.balo...@... wrote: v=(m++)+(++m); if it is against the rule of c language then the all the compilers that have been developed should leave a message telling the User that it is against the programming laws. g++ does give a warning:

[c-prog] Re: confusing output

2009-05-28 Thread John Matthews
--- In c-prog@yahoogroups.com, Steve Searle st...@... wrote: Around 06:59am on Thursday, May 28, 2009 (UK time), John Matthews scrawled: As does (f)lint: Is this a free version of lint? If so, where do you get it from? Sorry - flint is the executable name of Gimpel's FlexeLint. http

[c-prog] Re: limiting precision on float

2009-05-24 Thread John Matthews
--- In c-prog@yahoogroups.com, Jos Timanta Tarigan jos_t_tari...@... wrote: hi, im currently having a problem try to calculate this: directionZ = -cos((angleX+90)*PI_RADIAN); most of the time it works but when im in the boundary of the coordinate, it gives me a little error that im not

[c-prog] Re: Where are my C header files?

2009-05-19 Thread John Matthews
--- In c-prog@yahoogroups.com, Paul Herring pauljherr...@... wrote: [...@pjhxps ~]# locate stdio.h I wish you'd told me about that 2 years ago when I started doing linux - would have saved a lot of time fiddling around with find :-)

[c-prog] Re: Where are my C header files?

2009-05-19 Thread John Matthews
--- In c-prog@yahoogroups.com, Paul Herring pauljherr...@... wrote: On Tue, May 19, 2009 at 11:42 AM, John Matthews jm5...@... wrote: --- In c-prog@yahoogroups.com, Paul Herring pauljherring@ wrote: [...@pjhxps ~]# locate stdio.h I wish you'd told me about that 2 years ago when I

[c-prog] Re: How to lseek the larger file 2GB under linux

2009-05-17 Thread John Matthews
--- In c-prog@yahoogroups.com, Nicle yni...@... wrote: I have a file 2GB, and my job is seeking the file to pos: 2.1G. But, the lseek doesn't work. Try lseek64()?

[c-prog] Re: char to float to char

2009-05-15 Thread John Matthews
--- In c-prog@yahoogroups.com, Paul Herring pauljherr...@... wrote: On Thu, May 14, 2009 at 5:32 PM, Rick mowgl...@... wrote: If you work with embedded or real-time systems, hand-coding may still be important Not in the two (distinctly different[1]) industries I've been working in over

[c-prog] Re: char to float to char

2009-05-14 Thread John Matthews
--- In c-prog@yahoogroups.com, mikejd42 mikej...@... wrote: --- In c-prog@yahoogroups.com, John Matthews jm5678@ wrote: newPixel = (pixel1 + pixel2) / 2; instead of the /2 use 1 its faster with less overhead. The compiler will generate code that effectively does 1 to implement

[c-prog] Re: char to float to char

2009-05-14 Thread John Matthews
--- In c-prog@yahoogroups.com, Jos Timanta Tarigan jos_t_tari...@... wrote: i dont know if i coded it wrong. plus working properly but the /2.0 return always zero. Should be / 2, not 2.0. Can you show us your code?

[c-prog] Re: char to float to char

2009-05-14 Thread John Matthews
--- In c-prog@yahoogroups.com, mikejd42 mikej...@... wrote: --- In c-prog@yahoogroups.com, John Matthews jm5678@ wrote: --- In c-prog@yahoogroups.com, mikejd42 mikejd42@ wrote: --- In c-prog@yahoogroups.com, John Matthews jm5678@ wrote: newPixel = (pixel1 + pixel2) / 2

[c-prog] Re: char to float to char

2009-05-14 Thread John Matthews
--- In c-prog@yahoogroups.com, mikejd42 mikej...@... wrote: newpixel = ( pixel1 + pixel2 ) 1; This is hard to understand? Harder than: newpixel = (pixel1 + pixel2) / 2; because I (and I think others) would think - why are we using a bit shift here? Are the pixels bit masks or

[c-prog] Re: char to float to char

2009-05-14 Thread John Matthews
--- In c-prog@yahoogroups.com, Thomas Hruska thru...@... wrote: I try to not pull the 'x' years of experience card out too often. Yes, it trumps everything (assuming the person actually has more years of experience) but should only be pulled out as the last resort. I get to win the

[c-prog] Re: char to float to char

2009-05-14 Thread John Matthews
--- In c-prog@yahoogroups.com, mikejd42 mikej...@... wrote: Your correct Tom. Too much nit-picking. You started it! :-)

[c-prog] Re: Job Offer !

2009-05-14 Thread John Matthews
--- In c-prog@yahoogroups.com, Tiba industry jm5...@... wrote: Tiba industry Nothing to do with me, and I'm in Linux so I don't think I've been infected. Just someone putting my address in the 'from' field.

[c-prog] Re: char to float to char

2009-05-13 Thread John Matthews
--- In c-prog@yahoogroups.com, Jos Timanta Tarigan jos_t_tari...@... wrote: the problem is i want to merge two image and merging the value of each pixel. so basically pixel1 + pixel2 / 2.0; the problem is each of these pixels is char. how can I convert it to float and then convert it back

[c-prog] Re: char to float to char

2009-05-13 Thread John Matthews
--- In c-prog@yahoogroups.com, John Matthews jm5...@... wrote: --- In c-prog@yahoogroups.com, Jos Timanta Tarigan jos_t_tarigan@ wrote: the problem is i want to merge two image and merging the value of each pixel. so basically pixel1 + pixel2 / 2.0; the problem is each of these pixels

[c-prog] Re: explicit cast from char to int?

2009-05-08 Thread John Matthews
--- In c-prog@yahoogroups.com, abcpqr70 abcpq...@... wrote: --- In c-prog@yahoogroups.com, Stephane Lesoinne lesoinne@ wrote: If you want to convert a string representation of a number to his integer equivalent, you'll have to use the atoi(...) function. yeah! even i have same

[c-prog] Re: malloc

2009-05-07 Thread John Matthews
--- In c-prog@yahoogroups.com, Paul Herring pauljherr...@... wrote: On Thu, May 7, 2009 at 12:53 PM, Tyler Littlefield ty...@... wrote: that's what I was talking about. No you weren't. Or if you were, you didn't express it correctly. See also

[c-prog] Re: explicit cast from char to int?

2009-05-06 Thread John Matthews
--- In c-prog@yahoogroups.com, Jos Timanta Tarigan jos_t_tari...@... wrote: so im currently try to read a binary file and try to represent it in rgb image. i save the file into char[length] and then try to convert it to int to get 0-255 value. is it ok to do it explicitly eg. (int)thisChar ?

[c-prog] Re: looping constructs

2009-05-02 Thread John Matthews
--- In c-prog@yahoogroups.com, Thomas Hruska thru...@... wrote: Bill Cunningham wrote: Does anyone know what the looping constructs are that are used in command line interfaces that use a switch such as -d or -a in their argv? The POSIX approach is to use getopt(). Example:

[c-prog] Re: doubtttttttt---------please replyyyyyyyyyy

2009-04-28 Thread John Matthews
--- In c-prog@yahoogroups.com, Thomas Hruska thru...@... wrote: I've been rejecting a number of messages for being unprofessional. Some of the replies from regular contributors to this forum have been very unprofessional. I think it should work both ways - an unprofessional question doesn't

[c-prog] Re: server code help

2009-04-22 Thread John Matthews
--- In c-prog@yahoogroups.com, Tyler Littlefield ty...@... wrote: the array gets deleted, but I could shift that over to a real array rather than on the heap, might help somewhat. It's not a performance issue, just a matter of principle and using the right construct for the job. If you don't

[c-prog] Re: server code help

2009-04-21 Thread John Matthews
--- In c-prog@yahoogroups.com, Tyler Littlefield ty...@... wrote: Server::~Server() { if (users.size() ) { unsigned int count=0; for ( count=0;count ( users.size() +1 );count++ ) { delete users[count]; } Haven't examined it in detail (C++

[c-prog] Re: Integration

2009-04-20 Thread John Matthews
Mathematical integration - area under a curve?

[c-prog] Re: scientific notation

2009-04-19 Thread John Matthews
--- In c-prog@yahoogroups.com, Rick rdo...@... wrote: I'm a little confused about how, when, (if) scientific notation gets used. Are you talking about printf conversion specifiers, namely %g? If so, the manual says: Style e [scientific] is used if the exponent from its conversion is less than

[c-prog] Re: system's protection against buffer overflow

2009-04-13 Thread John Matthews
--- In c-prog@yahoogroups.com, Pedro Izecksohn izecks...@... wrote: I found that static data is executable on some platform. FYI CentOS 5 (linux): Compiled with gcc version 4.1. Now I'll try to overwrite the beginning of main (int, char **). It caused a SIGSEGV. Continuing. Now I'll try to

[c-prog] Re: system's protection against buffer overflow

2009-04-13 Thread John Matthews
--- In c-prog@yahoogroups.com, Pedro Izecksohn izecks...@... wrote: There is no reason for a constant string not be executable. ...unless program memory and data memory are physically separate (Harvard architecture) eg. my company's chips:

[c-prog] Re: testing exit status in makefile

2009-04-12 Thread John Matthews
--- In c-prog@yahoogroups.com, John Matthews jm5...@... wrote: --- In c-prog@yahoogroups.com, Tyler Littlefield tyler@ wrote: I'm building modules in separate directories, so I have something like: O_FILES= module1/file1.o, MODULE2/file2.o then I have: O_FILES_A = file1.o file2.o

[c-prog] Re: testing exit status in makefile

2009-04-11 Thread John Matthews
--- In c-prog@yahoogroups.com, Tyler Littlefield ty...@... wrote: I'm building modules in separate directories, so I have something like: O_FILES= module1/file1.o, MODULE2/file2.o then I have: O_FILES_A = file1.o file2.o for the linking. Is there a way I can do this with one line? There's

[c-prog] Re: Implementing a Parser

2009-04-10 Thread John Matthews
--- In c-prog@yahoogroups.com, Bill Cunningham bill...@... wrote: - Original Message - From: John Matthews jm5...@... Have you looked at lex/yacc (or their modern equivalents)? flex too That's what I meant by 'modern equivalents' - typically (AFAIK) flex for lex and bison

[c-prog] Re: About debuging merge sort!But I can't find the errors.

2009-04-10 Thread John Matthews
--- In c-prog@yahoogroups.com, qzqiang917 qzqiang...@... wrote: --- In c-prog@yahoogroups.com, John Matthews jm5678@ wrote: Have you tried using the VC debugger? Yes,but cannot pass Sorry - I don't understand what you mean by 'cannot pass'. If you try single-stepping through your code

[c-prog] Re: Implementing a Parser

2009-04-09 Thread John Matthews
--- In c-prog@yahoogroups.com, Sri linkto...@... wrote: just wanted to know that if there are some more efficient ways to any other scripting languages like perl/python. Have you looked at lex/yacc (or their modern equivalents)? Eg. http://epaperpress.com/lexandyacc/ More of a library than a

[c-prog] Re: About debuging merge sort!But I can't find the errors.

2009-04-09 Thread John Matthews
--- In c-prog@yahoogroups.com, qzqiang917 qzqiang...@... wrote: Dear you, I'm sorry that I can't understand you well becanse I use XP. I have never used Linux before.When I use Vc 6.0 to complier the program,it always gets the errror: Access Violation. Have you tried using the VC debugger?

[c-prog] Re: languge of c-compiler

2009-04-08 Thread John Matthews
--- In c-prog@yahoogroups.com, piyush_4love_4ever piyush_4love_4e...@... wrote: i want to know in which language , the c-compiler is written first http://www.livinginternet.com/i/iw_unix_c.htm

[c-prog] Re: About debuging merge sort!But I can't find the errors.

2009-04-04 Thread John Matthews
--- In c-prog@yahoogroups.com, qzqiang917 qzqiang...@... wrote: for(i = 0; i length; i++) k[i] = scanf(%d); If you are using Linux and compile this using gcc -Wall, you get a warning for the scanf(): warning: too few arguments for format Presumably it should be:

[c-prog] Re: Quadrature Rotary Encoder read

2009-04-02 Thread John Matthews
--- In c-prog@yahoogroups.com, Csaba Zvekan czve...@... wrote: The problem that I was having was while porting from Basic to C got me confused . I didn't know how to state the else command . Sorry, I should have said that my question wasn't anything to do with your 'else' question - I just

[c-prog] Re: pointer basic

2009-03-31 Thread John Matthews
--- In c-prog@yahoogroups.com, kathir resh resh_perso...@... wrote: main() {    char *p=hai friends,*p1;  p1=p; while(*p!='\0') ++*p++; printf(%s%s,p,p1); }   output   ibj!gsjfoet please explain it..   what is the difference between ++*p and p++whether here ++*p means

[c-prog] Re: List change: Paul Herring no longer a moderator + rule changes

2009-03-21 Thread John Matthews
--- In c-prog@yahoogroups.com, Thomas Hruska thru...@... wrote: Tamas Marki, Andrew Clarke, John Gaughan, and John Matthews are at the top of my list of possible candidates (if they are interested). Thomas- I'm flattered, but to be honest I spend more (work) time than I should on this list

[c-prog] Re: cutting down on output from ctime

2009-03-21 Thread John Matthews
--- In c-prog@yahoogroups.com, Tyler Littlefield ty...@... wrote: Hello list, I've got a quick question; I'm using ctime for logs, and want to cut down on it somewhat, so it won't show the date. Maybe just something that will show like 3 hours 5 minutes ago, or something similar, or

[c-prog] Re: Bit Operator

2009-03-21 Thread John Matthews
--- In c-prog@yahoogroups.com, Satya Prasad satya_prakash_pra...@... wrote: Is it safe to refer same variables in LHS and RHS while using Bitwise operators. Like: int x = 0 ; int y = 0; x = x | y; Yes, that is safe. Perhaps you are thinking of expressions such as: x = x++ | y; which

[c-prog] Re: Bit Operator

2009-03-21 Thread John Matthews
--- In c-prog@yahoogroups.com, Tyler Littlefield ty...@... wrote: But the following does the same thing and is also safe, and is what I think you should use: it doesn't really matter, just makes it quicker coding. :) I realise that the generated code is probably identical, but if a language

[c-prog] Re: please help

2009-03-20 Thread John Matthews
--- In c-prog@yahoogroups.com, pearlprist...@... pearlprist...@... wrote: hai friends i am not comfortable with using linked lists and pointer but i wish to learn these topics. can anyboby help with some notes or programs about these??? and their applications too. please explain the

[c-prog] Re: climate control system

2009-03-19 Thread John Matthews
--- In c-prog@yahoogroups.com, rizwannu rizwa...@... wrote: can any one give me asimple c program for climate control system using file handling You are more likely to get help if you have a go at writing the program yourself, and ask for help when you get stuck. If you are having trouble

[c-prog] Re: strange structure assignment !!!!

2009-03-18 Thread John Matthews
--- In c-prog@yahoogroups.com, Ahmed Shabana unlimited...@... wrote: can any one till me exactly what is this ? http://gcc.gnu.org/onlinedocs/gcc-3.4.6/gcc/Designated-Inits.html

[c-prog] Re: How to load only one instance in Windows startup?

2009-03-18 Thread John Matthews
--- In c-prog@yahoogroups.com, Brett McCoy idragos...@... wrote: mutexes are used on Unix-ish systems, too, although it's easy enough to iterate across the process list even with a shell script. Never tried it, but is there a danger with the process list approach (Windows or Unix) that if 2

[c-prog] Re: How to load only one instance in Windows startup?

2009-03-18 Thread John Matthews
--- In c-prog@yahoogroups.com, John Matthews jm5...@... wrote: --- In c-prog@yahoogroups.com, Brett McCoy idragosani@ wrote: mutexes are used on Unix-ish systems, too, although it's easy enough to iterate across the process list even with a shell script. Never tried

[c-prog] Re: an example about factorial numbers

2009-03-17 Thread John Matthews
--- In c-prog@yahoogroups.com, peternilsson42 peternilsso...@... wrote: % fact 1000 4023872600770937735437024339230039857193748642107146325437999104 2993851239862902059204420848696940480047998861019719605863166687 2994808558901323829669944590997424504087073759918823627727188732 ...

[c-prog] Re: to clean screen

2009-03-15 Thread John Matthews
--- In c-prog@yahoogroups.com, ruhatadiyaman ruhatadiya...@... wrote: i want to clean screen in somewhere of my codes but 'clrscr()' does not work with #includeconio.h . as i search it does not work in DEVC++(bloodshed). and i saw the system(cls) function which is declared in stdlib and it

[c-prog] Re: an example about factorial numbers

2009-03-14 Thread John Matthews
--- In c-prog@yahoogroups.com, ruhatadiyaman ruhatadiya...@... wrote: thanks for all replies. i tried them but still the problem is continuing. this is my code with 'unsigned long int'; If you just use double for your fak variable, you end up with this, which works for me (gcc):

[c-prog] Re: an example about factorial numbers

2009-03-14 Thread John Matthews
--- In c-prog@yahoogroups.com, John Matthews jm5...@... wrote: --- In c-prog@yahoogroups.com, ruhatadiyaman ruhatadiyaman@ wrote: thanks for all replies. i tried them but still the problem is continuing. this is my code with 'unsigned long int'; If you just use double for your fak

[c-prog] Re: binary number to decimal in C++.

2009-03-14 Thread John Matthews
--- In c-prog@yahoogroups.com, rajatsaini4u rajatsain...@... wrote: Here is my program in Turboc compiler(problem is described below it) sum=sum+s*pow(2,i); Instead of using pow(), which is a floating point function, it would be better to use: sum += s * (1 i);

[c-prog] Re: an example about factorial numbers

2009-03-14 Thread John Matthews
--- In c-prog@yahoogroups.com, andrew clarke m...@... wrote: On Sat 2009-03-14 14:08:58 UTC-, John Matthews (jm5...@...) wrote: Sorry - I left out the getch(), because on linux it comes from the curses library. If you need to wait for a key press, it might be better to use a stdio.h

[c-prog] Re: an example about factorial numbers

2009-03-13 Thread John Matthews
--- In c-prog@yahoogroups.com, ruhatadiyaman ruhatadiya...@... wrote: i wrote a code which calculates the factorials of 1-20. it gives the correct result until 13 but it is not correct after 13. Because 13! 2^31. That is, the int type is not big enough to hold the answer. Try using long or

Fw: Re: [c-prog] binary to decimal without using arrey or pointer or function

2009-03-12 Thread John Matthews
--- In c-prog@yahoogroups.com, peternilsson42 peternilsso...@... wrote: However main() is optimised effectively to a no-op since the compiler was able to recognise that foo(i) will indeed equal bar(i) for the iterated values of i! I'm not disputing the evidence, but I'm very surprised it can

Fw: Re: [c-prog] binary to decimal without using arrey or pointer or function

2009-03-12 Thread John Matthews
--- In c-prog@yahoogroups.com, John Matthews jm5...@... wrote: --- In c-prog@yahoogroups.com, peternilsson42 peternilsson42@ wrote: However main() is optimised effectively to a no-op since the compiler was able to recognise that foo(i) will indeed equal bar(i) for the iterated values

Fw: Re: [c-prog] binary to decimal without using arrey or pointer or function

2009-03-11 Thread John Matthews
--- In c-prog@yahoogroups.com, praveen indian85 praveen_india...@... wrote:    dec=dec+temp*pow(2,i); pow() takes double arguments and returns a double. The following would be more appropriate: dec += temp * (1 i); BTW is (int)pow(2, i) guaranteed to return the same as (1 i) for

[c-prog] Re: Strings Help

2009-03-06 Thread John Matthews
--- In c-prog@yahoogroups.com, Michael Comperchio mcmp...@... wrote: he did say he was accepting strings can't accept a string without a second buffer :) #include stdio.h #include string.h #define BUFSZ 1000 int main(void) { char buffer[BUFSZ], *s; size_t len; for (*(s = buffer)

[c-prog] Re: Plz clarify my doubts.....

2009-03-06 Thread John Matthews
--- In c-prog@yahoogroups.com, rasheed abdul rashu_76...@... wrote: Dear Sir,    While using cos( ) function to find the cos value of 30, 60, 90, 120, 130, 150,.. etc.. in C , the output is coming wrongly The expect the argument in radians, not degrees.

[c-prog] Re: static type checking

2009-03-06 Thread John Matthews
--- In c-prog@yahoogroups.com, mina mina_sa2...@... wrote: how is hardware supporting for static type checking? Please could you clarify - what do you mean by 'hardware'?

[c-prog] Re: Strings Help

2009-03-06 Thread John Matthews
--- In c-prog@yahoogroups.com, Michael Comperchio mcmp...@... wrote: anyway, 'tis better to be zeroed and sure, than to never have zeroed at all. Michael- I agree that defensive programming is A Good Idea, but in general I don't think initialising things 'just in case' is the best

[c-prog] Re: Strings Help

2009-03-06 Thread John Matthews
--- In c-prog@yahoogroups.com, John Matthews jm5...@... wrote: --- In c-prog@yahoogroups.com, Michael Comperchio mcmprch@ wrote: anyway, 'tis better to be zeroed and sure, than to never have zeroed at all. Michael- I agree that defensive programming is A Good Idea BTW bug

[c-prog] Re: Strings Help

2009-03-06 Thread John Matthews
--- In c-prog@yahoogroups.com, Michael Comperchio mcmp...@... wrote: Would lint have caught my silly typo? It does detect attempts to access beyond the end of arrays it knows the size of, but unfortunately in this case it doesn't know the size of argv[]. I take it you haven't used PC-Lint (or

[c-prog] Re: Strings Help

2009-03-06 Thread John Matthews
--- In c-prog@yahoogroups.com, Michael Comperchio mcmp...@... wrote: and of course, no compiler or tool can check access of the end of arrays I think :) static int table[] = {1, 2, 3, 4, 5}; int main(void) { int i, sum; for (sum = i = 0; i = 5; i++) { sum +=

[c-prog] Re: Strings Help

2009-03-06 Thread John Matthews
--- In c-prog@yahoogroups.com, Michael Comperchio mcmp...@... wrote: Ok, now I remember why i don't have it at home PC-Lint, one workstation license - $389 us. Yes - pity it's so expensive for personal have-a-play type use, but as I said in

[c-prog] Re: Strings Help

2009-03-05 Thread John Matthews
--- In c-prog@yahoogroups.com, Paul Herring pauljherr...@... wrote: On Thu, Mar 5, 2009 at 4:27 PM, Michael Comperchio mcmp...@... wrote: memset( buffer, 1000, 0); strcat(buffer, first_text); strcat(buffer, second_text); workable although strcpy(buffer, first_text); strcat(buffer,

[c-prog] Re: Non-0 internal value for NULL (C)

2009-03-04 Thread John Matthews
--- In c-prog@yahoogroups.com, Paul Herring pauljherr...@... wrote: http://c-faq.com/null/machnon0.html Don't rely on NULL being all bits zero. Sorry Paul - I don't see the bit that tells me whether static initialisation to 0 means that pointers are set - to NULL independent of the internal

[c-prog] Re: Non-0 internal value for NULL (C)

2009-03-04 Thread John Matthews
--- In c-prog@yahoogroups.com, peternilsson42 peternilsso...@... wrote: But to answer your question, 6.7.8p10: ...If an object that has static storage duration is not initialized explicitly, then: - if it has pointer type, it is initialized to a null pointer; ... Thanks,

[c-prog] Re: DirectX and Access Violation [SOLVED]

2009-03-01 Thread John Matthews
--- In c-prog@yahoogroups.com, Michael Sullivan msulli1...@... wrote: The array index was the problem. I had numbered them 1-4. That's a beginner's mistake. It does what I wanted it to now. I don't know how much programming you do, but if you can afford it (or can persuade your employer to

[c-prog] Re: DirectX and Access Violation [SOLVED]

2009-03-01 Thread John Matthews
--- In c-prog@yahoogroups.com, John Matthews jm5...@... wrote: Gimpel's PC-Lint is great at spotting things like that, and a whole lot more: http://www.gimpel.com/ Wow- I've seen how much it costs now. Last time I looked it was about £100, now it's £346! Definitely something you ask your

[c-prog] Re: DirectX and Access Violation [SOLVED]

2009-03-01 Thread John Matthews
--- In c-prog@yahoogroups.com, Brett McCoy idragos...@... wrote: There are free (open source) versions of Lint for Windows also, like splint: I did play with splint for a while, and although of course it's better than nothing, I would say that PC-Lint is worth the money. Especially if you can

  1   2   3   >