c

Declaring a function static and later non-static: is it standard?

Hello, I noticed a very curious behavior that, if standard, I would be very happy to exploit (what I'd like to do with it is fairly complex to explain and irrelevant to the question). The behavior is: static void name(); void name() { /* This function is now static, even if in the declaration * there is no static keyword. Test...

C/C++ IDEs that come with/without the compiler

I'm getting started with C and usually use eclipse for other development. But it turned out that the eclipse CDT plugin doesn't come with the compiler and therefore installing a compiler separately is required (since I'm on windows vista). What C/C++ IDEs do you use that you know already come with the compiler. I've been told Microsoft ...

Advantage and disadvantages of #defines vs. constants?

Can someone point out the advantages and disadvantages of using #defines vs. constants? Most of my work is done in C and Objective-C. Thanks! Matt ...

What is the fastest way to test if a double number is integer (in modern intel X86 processors)

Our server application does a lot of integer tests in a hot code path, currently we use the following function: inline int IsInteger(double n) { return n-floor(n) < 1e-8 } This function is very hot in our workload, so I want it to be as fast as possible. I also want to eliminate the "floor" library call if I can. Any suggestions? ...

Writing a file using fopen function.

I wrote the following C program to write data into a file.The program got compiled properly but nothing is getting written in the file.Please suggest modifications if required. #include <stdio.h> #include <errno.h> int main() { int i; FILE *fopen(),*fp; fp = fopen("D:\Satish_SharedSubstance\V13.4-CT_Testing\LONGRUN_Testing\...

How to Read same file in thread while other thread is writing text in the same file

How to read the content of file while the same file is writing the log entry in thread. I wanna to develop log viewer for my tool (like tail.exe) ...

Arbitrary Digit Counter

I need a counter algortihm which use arbitrary given digits for counting purpose. My code is similar to this: static char digits[] = {'x','y','z'}; /* Arbitrary number of arbitrary digits. */ int i; for(i=0; i<100; i++) { printf("%s\n", get_next()); } My expected output: x y z yx yy yz zx zy zz yxx yxy yxz yyx yyy yyz yzx yzy yz...

Is there any method for multiplying matrices having O(n) complexity?

I want to multiply two matrices but the triple loop has O(n3) complexity. Is there any algorithm in dynamic programming to multiply two matrices with O(n) complexity? ...

C: Dividing a double by a double outputs lnf

http://pastie.org/752941 When I divide dy/dx it returns lnf. Please tell me what this stands for and how I can find the actual result of dy/dx. Thanks. ...

Segmentation fault when executing program compiled from x86 assembly?

Hi everybody! I'm new to assembly language and I have to implement a function, in my case sin(x), that could be called from a C source file. I have to make 2 separate files: *.c and *.s When compiling through gcc on ubuntu all good, but when the program executes it gives me the error "Segmentation fault"... To compile I type: gcc -c -o...

Programs executes correctly and then segfaults

I'm trying to learn C programming and spent some time practicing with pointers this morning, by writing a little function to replace the lowercase characters in a string to their uppercase counterparts. This is what I got: #include <stdio.h> #include <string.h> char *to_upper(char *src); int main(void) { char *a = "hello world"; ...

How do I convert the exponential formats to the decimal format in c

additional please convert this exponential no. into int no. 5.52794e+15 ...

syntax error in C

Hi, I am trying to build a block where I am getting this error message pprbc_CONTENT_icverification_act.c", line 99.2: 1506-018 (S) Operand of indirection operator must be a pointer expression Can anyone please explain what this means? code below: *(WORK_migration_ind_f) = *(migration_status_in_MI9_CIRCLE_INFO(WORK_source_cir...

Is there better way to write do-while(0) construct to avoid compiler warnings?

I'm often use do-while(0) construct in my #defines, for the reasons described in this answer. Also I'm trying to use as high as possible warning level from compiler to catch more potential problem and make my code more robust and cross-platform. So I'm typically using -Wall with gcc and /Wall with MSVC. Unfortunately MSVC complain about...

UAC status without reading the registry

There's a simple way to read the registry and get the UAC status from there. The only problem is that if you are not an administrator user or the UAC is ON then you can't read that particular key. Is there a way (API, etc) to get the UAC status accurately without having to read the registry? Sample code is always appreciated. Thanks! ...

Example Code for MemCached in C

I am looking for some sample C code for using memcache to set a value Connecting to Server/Port using multiple memcache_set Close I have the app running in PHP in 5 lines of code but can not find any good memcache samples in C which I need to port to. ...

Win32 IO Performance Problem

Recently I ran into a "fun" problem with the Microsoft implementation of the CRTL. tmpfile places temp files in the root directory and completely ignores the temp file directory. This has issues with users who do not have privileges to the root directory (say, on our cluster). Moreover, using _tempnam would require the application to rem...

how to test for equivalence of several variables in C

Say I wanted to test not just one, but several variables for equivalence in an if statement: if(x1==x2==y1==y2){ printf("Input values shouldn't be equal!"); } But this doesn't seem to work. What other approach can do this? ...

How can I create a PDF file programmatically with C?

I want to write some String data to a pdf file programmatically, i want to know what are the C libraries that i have to use and how to use them ...

About pointer and reference syntax

Embarrassing though it may be I know I am not the only one with this problem. I have been using C/C++ on and off for many years. I never had a problem grasping the concepts of addresses, pointers, pointers to pointers, and references. I do constantly find myself tripping over expressing them in C syntax, however. Not the basics lik...