c

creating thread on another core? (WinAPI)

I was wondering if there was a way to run a thread on a seperate core instead of just a thread on that core? Thanks ...

GNU Make - Dependencies on non program code

A requirement for a program I am writing is that it must be able to trust a configuration file. To accomplish this, I am using several kinds of hashing algorithms to generate a hash of the file at compile time, this produces a header with the hashes as constants. Dependencies for this are pretty straight forward, my program depends on c...

simple question regarding sorting

Given a array of random integers, sort the odd elements in descending order and even numbers in ascending order. e.g. for input (1,4,5,2,3,6,7) Output = (7,5,3,1,2,4,6) Optimize for time complexity. ...

SIGSEGV problem

I'm designing a protocol (in C) to implement the layered OSI network structure, using cnet (http://www.csse.uwa.edu.au/cnet/). I'm getting a SIGSEGV error at runtime, however cnet compiles my source code files itself (I can't compile it through gcc) so I can't easily use any debugging tools such as gdb to find the error. Here's the stru...

Can main() function return double?

Can the main function in a C program return a double data type? If yes, how and why? If no, why? ...

How to test reliability of my own (small) embedded operating system ?

I've written a small operating system for embedded project running on small to medium target. I added some automated unit test with a high test code coverage (>95%), but the scope is only the static part. I got some code metrics as complexity and readability. I'm testing my code with a rule checker with MiSRA support, and of course fixe...

POSIX: allocate 64KB on 64KB boundary.

I would really like to actually only allocate 64KB of memory, not 128KB and then do the alignment manually - far too wasteful. VirtualAlloc on windows gives precisely this behavior. Supposedly there's code in SquirrelFish for doing this on just about every platform, but I haven't managed to locate it. Is there a space efficient way to al...

How to initialize an array to something in C without a loop?

Hey guys.. Lets say I have an array like int arr[10][10]; Now i want to initialize all elements of this array to 0. How can I do this without loops or specifying each element? Please note that this question if for C ...

How to fill a section within c++ string?

Having a string of whitespaces: string *str = new string(); str->resize(width,' '); I'd like to fill length chars at a position. In C it would look like memset(&str[pos],'#', length ); How can i achieve this with c++ string, I tried string& assign( const string& str, size_type index, size_type len ); but this seems to truncat...

how do we know the graph is connected or not? by using depth first search

Possible Duplicate: What is the most efficient way to determine if a directed graph is singly connected? how do we know the graph is connected or not? by using depth first search ...

how to debug application as root in eclipse in Ubuntu?

I'm programming application using libpcap. when I debug the application in normal mode, pcap cannot get the network device. it seems that I have to debug the application in root. How can I debug the application in root? I have the root password. I think eclipse has such an option that can add root for the debugging application,but I don'...

UDP broadcast problem

I'm trying to do something like this. There is one server , and multiple clients in the same subnet. Clients will send something to server and server will send this message back to all the other clients in the subnet. So this looks like broadcast to me. But i never could manage to do this in C.. I'd be glad if you give me an example of t...

drawing above gtkentry using cairo

Hi Experts, I want to use cairo to enhance gtkentry look. For this, I have connected a callback to 'expose-event'. In callback, I call gtkentry's original expose-event handler. After that, I create cairo context and draw some lines and destroy the cairo. I return 'TRUE' as return value of callback function so that expose-event does not...

Shortest example to use templating function in C?

How do I approach a function echo_tpl that can take 1 parameter of type int or string ,and print it out? ...

sub-routines on Assembly

can I do something like this on Assembly bne jsr swap, if not how can I solve this problem from C, thanks in advance if(start!=pivot_index){ swap(board,start,pivot_index); } I was taught that I must write jsr and sub-routine but can I do something like this bne sub-routine ...

virtual function == function pointer?

A set of function pointers grouped into a data structure are often referred to as a virtual function table (VFT). The above statement makes me feel that virtual function == function pointer,is that so? ...

How to throw an exception in C?

I typed this into google but only found howtos in C++, how to do it in C? ...

how to use a class method as a WIN32 application callback method (WINPROC)... Error static struct HINSTANCE__

I am receiving errors and at the same time trying to make this work so please read what I got to say. Thanks.... I am creating a c++ application and majority of the application is encapsulated into a class. That means that my WinProc function is a static class method that I use as my call back method for my win32 application. The proble...

Which of the C-family languages have a preprocessor?

Among the C-syntax family of languages (C, C++, Java, C#, ObjC, JS, AS, ...), which have a preprocessor compatible (to whatever extent) with the C preprocessor? ...

How are macros evaluated in C?

#ifdef CONFIG_IP_MULTIPLE_TABLES struct fib_table * fib_hash_init(int id) #else struct fib_table * _ _init fib_hash_init(int id) { ... } How's the value of CONFIG_IP_MULTIPLE_TABLES populated? ...