I keep reading that, in C, using pointer arithmetic is generally faster than subscripting for array access. Is this true even with modern (supposedly-optimizing) compilers?
If so, is this still the case as I begin to move away from learning C into Objective-C and Cocoa on Macs? (As is the primary goal of my picking up C -- get enough th...
In all honesty, I think the answer is "no;" however, I want to get a second opinion. Basically, I need one micro-controller device to send a steady signal to another one, but the communicate between them is using RS232. So I think that I have to create/update the communication messages to get it to do what I want.
What do you think?
...
I want to print the full length of a C-string in GDB. By default it's being abbreviated, how do I force GDB to print the string in full?
...
Hello,
I'm trying to write a small app that monitors how much power is left in a notebook battery and I'd like to know which Win32 function I could use to accomplish that.
...
I'm new to Windows programming and after reading the Petzold book I wonder:
is it still good practice to use the TCHAR type and the _T() function to declare strings or if I should just use the wchar_t and L"" strings in new code?
I will target only Windows 2000 and up and my code will be i18n from the start up.
...
I'm writing a client-server app using BSD sockets. It needs to run in the background, continuously transferring data, but cannot hog the bandwidth of the network interface from normal use. Depending on the speed of the interface, I need to throttle this connection to a certain max transfer rate.
What is the best way to achieve this, p...
Is there an easy way to cancel a curl_easy_perform from another thread?
...
Hi,
I am trying to use timerfd_create and timerfd_settime under Debian Linux lenny. The manpage says to include <sys/timerfd.h>. This file cannot be located on my System. According to the Debian Package Search the only packages with a timerfd.h are the linux-headers-* packets.
I have installed the packets linux-headers-2.6.26-1-amd64 ...
I have a legacy DLL written in C that contains a function that returns a string, and I need to access this function from Delphi. The only info I have about the DLL is the VB declare for accessing the function:
Public Declare Function DecryptStr Lib "strlib" (Str As String) As String
I've tried the following without success:
Declarati...
I'm using GCC; __FILE__ returns the current source file's entire path and name. Is there a way to get just the file's name and not its whole path too (at compile time)? Is it possible to do this in a portable way? Can template meta programming be applied to strings?
I am using this in an error logging macro. I really do not want my sour...
In cmd.exe, I can execute the command "copy c:\hello.txt c:\hello2.txt" and it worked fine.
But in my C program, I ran this piece of code and got the following error:
#include <iostream>
using namespace std;
int main()
{
system("copy c:\hello.txt c:\hello2.txt");
system("pause");
return 0;
}
Output:
The system cannot fi...
I have worked on projects for embedded systems in the past where we have rearranged the order of declaration of stack variables to decrease the size of the resulting executable. For instance, if we had:
void func()
{
char c;
int i;
short s;
...
We would reorder this to be:
void func()
{
int i;
short s;
ch...
How can I find out the size of a file? I opened with an application written in C.
I would like to know the size, because I want to put the content of the loaded file into a string, which I alloc using malloc(). Just writing malloc(10000*sizeof(char)); is IMHO a bad idea.
...
In win32, are thread input queues global to all applications?
So Application A can attach itself to application B's thread input queue?
...
I want to perform some transformations on C source code. I need a tool on linux that generates a complete AST from the source code so that I can apply my transformations on this AST and then convert it back to the C source code. I tried ELSA but it is not getting compiled. (I am using Ubuntu 8.4). Can anyone suggest a better tool/applica...
Hi,
I need a timer tick with 1ms resolution under linux. It is used to increment a timer value that in turn is used to see if various Events should be triggered. The POSIX timerfd_create is not an option because of the glibc requirement. I tried timer_create and timer_settimer, but the best I get from them is a 10ms resolution, smaller ...
I have a very large C project with many separate C files and headers and many dozens of contributors. Many contributors do not have a strong knowledge of makefiles and dependencies, resulting in the not uncommon problem where you almost always have to "make clean" before you can trust "make" to have produced correct output.
If make too...
I'm looking for a way to convert a preprocessor token to a string.
Specifically, I've somewhere got:
#define MAX_LEN 16
and I want to use it to prevent buffer overrun:
char val[MAX_LEN+1]; // room for \0
sscanf(buf, "%"MAX_LEN"s", val);
I'm open to other ways to accomplish the same thing, but standard library only.
...
What's the simplest way to convert a Unicode codepoint into a UTF-8 byte sequence in C? The only way that springs to mind is using iconv to map from the UTF-32LE codepage to UTF-8, but that seems like overkill.
...
I'm looking for Python code that removes C and C++ comments from a string. (Assume the string contains an entire C source file.)
I realize that I could .match() substrings with a Regex, but that doesn't solve nesting /*, or having a // inside a /* */.
Ideally, I would prefer a non-naive implementation that properly handles awkward case...