c

Import Makefile settings to VS2005 IDE

Hi, I'm a newbie in this vast world of programming. I've been given some codes in C which are compiled & linked using makefile. I can compile the code using nmake from VS2005. Now i want to build the program in C++ VS2005 IDE. From a quick google search, there seems to be no automated functions in importing makefile settings to VS IDE. ...

Dangerous ways of removing compiler warnings?

I like to force a policy of no warnings when I check someone's code. Any warnings that appear have to be explicitly documented as sometimes it's not easy to remove some warnings or might require too many cycles or memory etc. But there is a down-side to this policy and that is removing warnings in ways that are potentially dangerous, i....

C-library not linking using gcc/g++

I have a c-library which I use in gcc. The library has the extension .lib but is always linked as a static library. If i write a program which uses the library as c-code, everything as a-ok. If I however rename the file to .cpp (doing simple stuff that works in both c/c++) I get undefined reference. These are simple small programs I writ...

volatile in c

Possible Duplicate: What is the difference between these declarations in C? what is purpose of volatile? ...

Random number function is misfiring

I have a very simple iPhone app that requires a random integer from 1-100. I have a button that calls the random number function then displays it. -(IBAction)buttonReleased; { srandom(time(NULL)); int theNum = random() % 100 + 1; numberDisplay.text = [NSString stringWithFormat:@"%d", theNum]; } The problem is, if I press...

How do I determine the number of decimal digits of an integer in C?

for instance, n = 3432, result 4 n = 45, result 2 n = 33215, result 5 n = -357, result 3 I guess I could just turn it into a string then get the length of the string but that seems convoluted and hack-y. ...

Are members of a C++ struct initialized to 0 by default?

I have this struct: struct Snapshot { double x; int y ; }; I want x and y to be 0. Will they be 0 by default or do I have to do: Snapshot s= {0,0}; What are the other ways to zero out the structure? ...

Find program's code address at runtime?

When I use gdb to debug a program written in C, the command disassemble shows the codes and their addresses in the code memory segmentation. Is it possible to know those memory addresses at runtime? I am using Ubuntu OS. Thank you. [edit] To be more specific, I will demonstrate it with following example. #include <stdio.h> int main(in...

Assign array of pointers to array

If I have an array of char pointers and another static array of characters, how do I assign each element of the array of pointers to each element of a static array? (Trying to break down a problem into a smaller problem.) Thanks. array of pointers array of char +----+ ...

How to save current state of OFFSET in SQL

I have 1000 rows of data but need to only display 100 rows at a time. I would like navigation buttons (like on google next, prev) to go thought the groups of 100 My C cgi application runs and exits every new query, so it can't save states. Question is: What is the most efficient way to save the current state of the OFFSET, so I can n...

CUDA shared memory array - odd behavior

In a CUDA kernel, I have code similar to the following. I am trying to calculate one numerator per thread, and accumulate the numerators over the block to calculate a denominator, and then return the ratio. However, CUDA is setting the value of denom to whatever value is calculated for numer by the thread in the block with the largest th...

Turning C output into C# input

I am currently trying to develop a program which takes the output of an existing program (written in C) and uses it as input (in C#). The problem I am having is that the existing program prints data in redundant format but it dynamically changes. An example could be a random name generator and I need to make a program that logs all of t...

In C - check if a char exists in a char array

I'm trying to check if a character belongs to a list/array of invalid characters. Coming from a Python background, I used to be able to just say: for c in string: if c in invalid_characters: #do stuff, etc How can I do this with regular C char arrays? ...

How do I satisfy a 3rd-party shared library reference to stat when I'm creating a shared library shim rather than an executable?

I am the new maintainer for an in-house Python system that uses a set of 3rd-party shared C libraries via a shared library shim that is created using a combination of swig and a setup.py script. This has been working well until recently. The 3rd-party shared C libraries were updated for new functionality and now I get the following run-...

Error in qsort function in Programming Pearls?

Hello, is it just me or this code in Programming Pearls is wrong (quicksort wants 2 const voids, no?) If so, is my solution right? Apologies, just learning... int wordncmp(char *p, char* q) { int n = k; for ( ; *p == *q; p++, q++) if (*p == 0 && --n == 0) return 0; return *p - *q; } int sortcmp(char **p, char **q) ...

How Does Piping Work in Linux?

Probably a simple question but... How does piping work? If I run a program via CLI and redirect output to a file will I be able to pipe that file into another program as it is being written? Basically when one line is written to the file I would like it to be piped immediately to my second application (I am trying to dynamically dra...

GCC giving different numerical results with -O0 and -O2

I'm using 4.1.2. Does anyone have any ideas of the best places in my code to look? Experience with common causes? There are some ugly pointer casts (ie, d = (double) (* (float *) p), where p is pointer-to-int) that I'm working on eliminating, but no luck yet. For what it's worth, -O0 is giving the correct answer. Thanks for any help. ...

Looking for open-source http servers

Hi, all I'm looking for open-source http servers as benchmarks for my OS, which should satisfy: It folks several processes to handle http requests (not threads or I/O multiplexing) It can be compiled statically, which means no run-time code link like dynamic libraries. Is there any satisfied httpd? Thanks for your replies. ...

How do I get milliseconds since midnight UTC in C?

The time function in time.h gives milliseconds since the epoch. ...

WinVerifyTrust to check for a specific signature?

I'm implementing a process elevation helper for Windows. It's a program that will run in elevated mode and launch other programs with administrator privileges without displaying additional UAC prompts. For security reasons, I want to make sure only binaries that are digitally signed with my company's Authenticode key can be executed. Th...