I'm currently writing a wrapper library for windows mobile in C/C++. I have to implement and export the following functions:
void start_scanning();
int wait_for_scanning_result();
void stop_scanning();
start_scanning() is called to start the scanning process. wait_for_scanning_result() will wait until a result is available and return ...
What do people use to denote that size_t is invalid? -1 does not work, and 0 can be a valid size.
Thank you
...
I read somewhere that if you want a C/C++ function to return a character array (as opposed to std::string), you must return const char* rather than char*. Doing the latter may cause the program to crash.
Would anybody be able to explain whether this is true or not? If it is true, why is returning a char* from a function so dangerous? Th...
Hi, I am inexperienced with using C, and I need to use PCRE to get matches.
Here is a sample of my source code:
int test2()
{
const char *error;
int erroffset;
pcre *re;
int rc;
int i;
int ovector[OVECCOUNT];
char *regex = "From:([^@]+)@([^\r]+)";
...
In Perl, I can say
my $s = "r\x{e9}sum\x{e9}";
to assign "résumé" to $s. I want to do something similar in C. Specifically, I want to say
sometype_that_can_hold_utf8 c = get_utf8_char();
if (c < '\x{e9}') {
/* do something */
}
...
So I get the point of headers vs source files. What I don't get is how the compiler knows to compile all the source files. Example:
example.h
#ifndef EXAMPLE_H
#define EXAMPLE_H
int example(int argument); // prototype
#endif
example.c
#include "example.h"
int example(int argument)
{
return argument + 1; // implementation
...
The question is given like this:
Using the CreateProcess () in the Win32 API. In this instance, you will need to specify a separate program to be invoked from CreateProcess(). It is this separate program that will run as a child process outputting the Fibonacci sequence. Perform necessary error checking to ensure that a non-negative ...
I have an embedded system (ARM 9263) running an RTOS, IAR tools. The system supports the standard time() function which gives me the current time. I need the reverse call, that is I need to set the time - is there a "C" standard way to do this? I've googled around, sure thought it would be obvious, but perhaps it is platform dependent? I...
Suppose both parent and child use one pipe for writing and reading means when one writes then only other read otherwise it blocks. Is there any way to do it? I tried to do it with sleep function but due to race conditions, it does not give the correct output.
This is my code
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#i...
Possible duplicate
Uninitialized values being initialized?
When we create a variable and don't initialize it, then some (random) number called garbage value is assigned to it.
How this value is assigned to the variable?
What is whole concept/mechanism behind this?
Does this happen only in C?
...
Everything I'm finding via google is garbage... Note that I want the answer in C, however if you supplement your answer with a C++ solution as well then you get bonus points!
I just want to be able to read some floats into an array from a binary file
EDIT: Yes I know about Endian-ness... and no I don't care how it was stored.
...
Is there an equivalent to the C preprocessor directive ## in Erlang?
Let's say I want to concatenate two atom() using a -define preprocessor directive, how would I do this without having run-time side-effects?
...
I have these headers in a c code
#include <stdio.h>
#include <unistd.h>
Everything compiled fine until I added -std=c99 flag to gcc command (to enable restrict). And this triggered the following errors.
warning: implicit declaration of
function fileno
error: F_LOCK undeclared (first use
in this function)
error: (Each u...
struct {
char a;
int b;
} x;
Why would one define a struct like that instead of just declaring it as:
struct x {
char a;
int b;
};
Thanks
...
I am writing an application where it would be helpful to automatically switch between having Windows XP's desktop in dualview or cloned. The application uses a small wxWidgets window for the GUI. It would be nice to have a button within the GUI that could easily switch between dualview and cloned.
Is there a c/c++ library that gives...
I have code that uses Microsoft Active Accessbility to get information about the active window. Strangely, I can only enumerate all the controls in a window (in this case Internet Explorer) if I use a process. If I spawn a thread and call the EXACT same code, MSAA will return only a subset of controls. Usually just the menu bar and toolb...
I am working with a multithreaded embedded application. Each thread is allocated stack sizes based on its functionality. Recently we found that one of the thread corrupted the stack by defining a array of local variables that was more than the stack size. The OS is uItron.
My solution,
I registered a timer for 10 mS, and this timer will...
So if I understand well, Garbage collection automatically deallocates objects that are not used by the program anymore. like the garbage collector in java.
I hear in languages like C that don't support garbage collection the programs can have memory leaks and subsequently exhaust the memory.
So what are the errors that programmer make ...
Hi Forum,
I am a newbie programmer.I have a problem as goes below,
void SockSend()
{
char *sendbuf;
int sendsize; /* send data size(variable size)*/
int iPos = 0, iTotSize;
char hdr;
char *data = "ABCDEFGHIJKLMNO"; /* its just example, data can be any thing */
sendsize = strlen(data);
hdr = '\0'; /* header charac...
I want to create a series of files under "log" directory which every file named based on execution time. And in each of these files, I want to store some log info for my program like the function prototype that acts,etc.
Usually I use the hard way of fopen("log/***","a") which is not for this purpose.And I just write a timestamp function...