Hi, i have the following code parts:
typedef struct Object* ObjectP;
ObjectP CreateObject(void *key) {
printf("GOT %d\n",(*(int*) key));
ObjectP objP = (ObjectP) malloc(sizeof(Object));
if (objP == NULL) {
//TODO ReportError(MEM_OUT);
return NULL;
}
objP->_key = key;
objP->_next = NULL;
objP...
how to reverse the input number and get the output
...
Hi,
Given the following regular expressions:
- alice@[a-z]+\.[a-z]+
- [a-z]+@[a-z]+\.[a-z]+
- .*
The string [email protected] will obviously match all three regular expressions. In the application I am developing, we are only interested in the 'most specific' match. In this case this is obviously the first one.
Unfortunately th...
Hi,
for an autotools-based C project, I'd like to get some more warnings from the compiler (e.g. at least -Wall in CFLAGS). What is the prefered way to enable compiler flags without breaking anything? Is there a m4 macro that tests if a given compiler flag is understood by the compiler?
With such a macro I could do
TEST_AND_USE(-Wall -...
I'm reading quite large lines(up to 128K) of text using fgets. I'm seeing excessive context switching on the server, using strace I see the following:
read(3, "9005 10218 00840023102015 201008"..., 4096) = 4096
i.e. fgets reads chunks of 4096 bytes at a time. Is there any way to control how big chunks fgets uses to when calling read()...
char * function decode time()
{
tm *ptm; //time structure
static char timeString[STRLEN]; //hold string from asctime()
ptm = gmtime( (const time_t *)<ime ); //fill in time structure with ltime
if(ptm)
{
strncpy(timeString, asctime( ptm ), sizeof(timeString) );
//EDIT
sprintf(test, "Sting is: %s", tim...
I would like to bin vectors in n-dimensional space. This can be done by pixelating the surface of an n-dimensional hypersphere.
Does anyone know any good algorithms for pixelating a hypersphere in C? I would like constant bin sizes. My space consists of only positive integers.
...
I am reading through a "Learn C" book right now and have come across a question I really don't understand. The point of the exercise is to find the problem with this code:
char c;
c = 'a';
printf("c holds the character %c.",c);
..and then it gives the explanation that: "The text string "a" is composed of two characters, both 'a' an...
I'm running a running a simple daemon test in c++. It runs fine without the sleep() but if I add sleep() func it runs once then stays a sleep. Further the first run should print once "Hello" in logs/log.dat file but that doesn't happen either. Here is the code:
#include <cstdlib>
#include <cstdio>
#include <iostream>
#includ...
I am really getting confused on how pointers work. I am trying to write short little programs that will illuminate exactly how they work and I am having some troubles. For example:
char c[3]; //Creates an array of 3 bytes - the first 2 bytes can be used for characters and the 3rd would need to be used for the terminating zero
*c = 'a...
I compiled the speex library for symbian using carbide C++. The compile completes with zero errors/warnings.
I use the compiled library in my QT application. Compiling the QT application gives the following error -
warning: COMDAT symbol '.exc$T' does not match section name '.rdata'
(Its really an error, not a warning. the word warnin...
This ought to simple. Say we have a struct from a library that doesn't offer copying facilities. Is there an easy way to copy a variable of the type of that struct to a new variable of the same type without doing assignments for each of its sub members? Or does one have to be making special copying functions?
...
char out_file_name[30];
ogSize = strlen(FileName); //i.e. - FileName_anylength.log (always.log)
ogSize -= strlen(IN_FILE_SUFFIX); //amount of chars before .log
strncpy( out_file_name, FileName, ogSize ); //out_file_name now is FileName_anylength (without the .log)
Is this the best way to do this?
Also, how do I guard that ogS...
I'm making a color dropper tool and while this tool is active, when the user clicks or taps I only want it to run my mouse event, not anything else,so while this tool is running,if the user clicks the start orb, it should not open the start menu (or if the user clicks anything else). How could I do this?
Thanks
...
I have a line-oriented text file (Unicode) that was created using CreateFile() and WriteFile().
Reading that file as a binary stream using ReadFile() is straightforward, but extra low-level processing is needed to break it into lines.
Is there a Win32 function that does this for me?
Again, please note that it's in 'C' (not C++) and I ...
Good evening, everyone.
I've now run into an odd warning, and for the life of me I can't figure out where it's going wrong. I've tried so many different options I can't remember.
The error is:
assignment from incompatible pointer type
Relative code:
// Server structure
typedef struct {
struct addrinfo address; // Addr...
In a test, I'm discarding anything from stderr since it clutters the output of the test case. I'm using the following code:
freopen("/dev/null", "w", stderr);
When compiling with -Wall -Werror, I get the error
error: ignoring return value of ‘freopen’, declared with attribute warn_unused_result
which is expected. However, the usual...
Hi geeks,
This maybe a linguistic question. I have checked the loop device on Wikipedia. It is just for mounting files as block device. But what does "loop" mean here? Its usage here is totally bizarre to me. I am not a native English speaker. So could someone explain this jargon to me in plain English? :)
Thanks.
...
Hello,
gcc 4.4.3 c89
I am trying to display the address. Basically, I just want to prove that I am displaying the correct address.
I want to display the address of each array of pointers to char 'device_gc', 'device_mg', 'device_cc'
So I display them in my main function. However, in my display_list function I just want to prove I am ...
Hi guys~
Does anyone know where to find a summery table or cheetsheet for the Linux system call in Assembly language? I am invoking Linux system calls through int 0x80 instruction and I need to refer to what register contains what value from time to time.
Thanks.
...