I'm having a hard time coding understanding the format of the specifier and string functions.
My aim is to use %[] to readin all characters and spaces and then use the strcpy function followed by the strcat function.
So far i've managed to enter individual characters and print them out, excluding spaces.
here's the code so far;
int m...
I need to run a Linux CLI command and get its stdout output from C.
I can use pipe() to create a pipe, then fork/exec, redirecting child's stdout descriptor into the pipe before calling exec(), and reading from the pipe in parent. Plus I'll need to wait on the child.
Is there a simple call to do fork + redirect + exec + wait, like syst...
I've often used pointers to const objects, like so...
const int *p;
That simply means that you can't change the integer that p is pointing at through p. But I've also seen reference to const pointers, declared like this...
int* const p;
As I understand it, that means that the pointer variable itself is constant -- you can change th...
I have a class with the following member functions:
/// caller pid
virtual pid_t Pid() const = 0;
/// physical memory size in KB
virtual uint64_t Size() const = 0;
/// resident memory for this process
virtual uint64_t Rss() const = 0;
/// cpu used by this process
virtual double PercentCpu() const = 0;
/// memory used by this p...
From time to time, I run into communications issue with other programmers, when we talk about NULL. Now NULL could be
a NULL pointer
the NUL character
an empty data element in some sort of database.
NUL seems to be the most confusing. It is the ASCII character 0x00.
I tend to use '\0' in my code to represent it. Some develop...
how can i detect keyboard event in c language without using third party libraries? Should I use signal handling?
...
Should my program support IA64, or should it only support x64?
I haven't been able to easily find IA64 computers myself. Is IA64 dead?
MS seems to have a wide support for IA64, but it took me a long time to be able to find an IA64, and I had to end up getting it on eBay.
...
I have a COM SDK written in C++ and I'd like to create documentation for my product. I understand that most people will probably not use C++ for integration with this COM component, but many will.
Which method is best to describe the API, without losing details that a C++ developer would need to know.
...
termios.h defines
#define TIOCM_OUT1 0x2000
#define TIOCM_OUT2 0x4000
but what are the flags good for?
...
Hi,
How can I access Ethernet statistics from C/C++ code like netstat -e?
Interface Statistics
Received Sent
Bytes 21010071 15425579
Unicast packets 95512 94166
Non-unicast packets 12510 7
Discards 0 ...
I know it, forgets it and relearn it again. Time to write it down.
...
This article describes a way, in C#, to allow the addition of arbitrary value types which have a + operator defined for them. In essence it allows the following code:
public T Add(T val1, T val2)
{
return val1 + val2;
}
This code does not compile as there is no guarantee that the T type has a definition for the '+' operator, but th...
In an Open Source program I
wrote, I'm reading binary data (written by another program) from a file and outputting ints, doubles,
and other assorted data types. One of the challenges is that it needs to
run on 32-bit and 64-bit machines of both endiannesses, which means that I
end up having to do quite a bit of low-level bit-twiddling. ...
I recently started using Linux as my primary OS. What are the tools that I will need to set up a complete programming environment in Linux for C and C++?
...
What libraries are available for writing xml-rpc clients in native C++ or C?
...
I have been reading the MSDN documentation on subclassing and I have been successful in handling events in a subclass
My issue is with passing messages back to the original WndProc.
As an example, if I have a window, with a sub-classed groupbox control and a button as a child of that groupbox, I want to handle the button event in the ...
I'm looking for programs/projects that are small to moderate size that show good modern practices for developing applications in C on Linux. I'd like to learn by example and curious how things are done out in the real world.
...
In the spirit of questions like Do your loops test at the top or bottom?:
Which style do you use for an infinite loop, and why?
while (true) { }
do { } while (true);
for (;;) { }
label: ... goto label;
...
How would you program a C/C++ application that could run without opening a window or console?
...
In a coding style question about infinite loops, some people mentioned they prefer the for(;;) style because the while(true) style gives warning messages on MSVC about a conditional expression being constant.
This surprised me greatly, since the use of constant values in conditional expressions is a useful way of avoiding #ifdef hell. F...