After programming in C for several years, I realized that I have been ignoring the C convention of returning zero from a function to indicate success. The convention seems semantically wrong to me, as zero is of course false. The problem is I like to name functions like is_valid_foobar(), and in order to accomodate the convention of '...
Languages like C, Haskell, Lisp, Smalltalk, and assembly language are often touted as things every programmer should know for their effect on the way one thinks about programming, even if they're used very little in real world situations. However, to really learn a language in depth to the point where you know not only the syntax and se...
Let's say I have a function that accepts a void (*)(void*) function pointer for use as a callback:
void do_stuff(void (*callback_fp)(void*), void* callback_arg);
Now, if I have a function like this:
void my_callback_function(struct my_struct* arg);
Can I do this safely?
do_stuff((void (*)(void*)) &my_callback_function, NULL);
I'...
I am writing a system monitor for Linux and want to include some watchdog functionality. In the kernel, you can configure the watchdog to keep going even if /dev/watchdog is closed. In other words, if my daemon exits normally and closes /dev/watchdog, the system would still re-boot 59 seconds later. That may or may not be desirable behav...
I have been facing a weird issue in a piece of code.
void app_ErrDesc(char *ps_logbuf, char *pc_buf_err_recno)
{
char *pc_logbuf_in;
char rec_num[10];
char *y = "|";
int i, j;
memset(rec_num, 0, sizeof(rec_num));
memset(pc_buf_err_recno, 0, LOGBUFF);
.....
.....
}
For some reason the first me...
Is there a way to disassemble Pro*C/C++ executable files?
...
I want to delete unused local variables from C file.
Example:
int fun(int a , int b)
{
int c,sum=0;
sum=a + b;
return sum;
}
Here the unused variable is 'c'.
I will externally have a list of all unused local variables. Now using unused local variables which I have, we have to find local variables from source code & delete.
I...
To follow the example of The Definitive C++ Book Guide and List for C Books here is a wiki post for organization.
A tag search for "C" and "Books" returns no complete book list results as of writing this question. That search is here.
This post is to providing QUALITY books and an approximate skill level. Maybe we can add a short blur...
Duplicate: C: Network Programming
What are some good books for learning network programming in C/C++?
...
How would I compare 2 strings to determine if they refer to the same path in Win32 using C/C++?
While this will handle a lot of cases it misses some things:
_tcsicmp(szPath1, szPath2) == 0
For example:
forward slashes / backslashes
relative / absolute paths.
[Edit] Title changed to match an existing C# question.
...
Recently I was looking at the 'dirent' structure (in dirent.h) and was a little puzzled by its definition.
NOTE: This header file is from a Solaris machine at my school.
typedef struct dirent {
ino_t d_ino;
off_t d_off;
unsigned short d_reclen;
char d_name[1];
} dirent_t;
Particularly the d_name field. How would t...
I have just installed Ctags (to help with C++ development) with my Vim (or rather gVim), and would like to find out your favorite commands, macros, shortcuts, tips that go along with it...
Share your best arsenal. What other Vim add-ons you would recommend for C++ on Vim development?
EDIT What other add-on you would use in conjunction ...
take for instance the following code snippet, the creation of the socket, listening and acceptance of a new socket works fine. The non-blocking mode is also working, however the pselect (or even replacing with select) is not recognizing any IO requests ready on the FDset. so the return value is always 0 (timed out).
I was wondering if...
Windows GUI applications written in C/C++ have 'WinMain' as an entry point (rather than 'main'). My understanding of this is that the compiler generates a 'main' function to be called by the C Runtime. This 'main' function sets up the necessary environment for the GUI and calls into 'WinMain' (specifying the instance handles etc.).
In s...
Hello,
i have a library which i have to pass (char **)&return_string to the function hci_scan
as seen in this excerpt:
char return_string[250];
int num_hosts;
if ((num_hosts = hci_scan((char **) & return_string, 0x03)) > 0) {
//case where one or more devices are found...
} else {
//case where zero devices are found...
}
afte...
I am writing a simple C++ application which might be installed on Linux or Windows, and which will connect to a database. I want my application to be compatible at least with Oracle and MySQL (or PostgreSQL).
Which C or C++ library would you recommend to handle the database queries: I am open to any library, whether it's very thin (jus...
What is the easiest way to handle huge numbers in C? I need to store values in the Area 1000^900...
Does anybody know of an easy way to do that? Any help would really be appreciated!
...
Quick question, wondering if anyone knew what the limit is for SO_RCVBUF under Windows.
...
I wrote some code in C and I was surprised to see it take a longer time to execute than I expected. I want to know which operations are costly and how to get rid of them.
I use assignment statements, conditional(nested), loops, function calls and call backs.
What are some good references to common C performance pitfalls?
Is there a ...
So I understand that there are a few options available as far as parsing straight XML goes: NSXMLParser, TouchXML from TouchCode, etc. That's all fine, and seems to work fine for me.
The real problem here is that there are dozens of small variations in RSS feeds (and Atom feeds too), so supporting all possible permutations of feeds avai...