c

How to store and remove dynamically and automatic variable of generic data type in custum list data structure?

Hi I have created a List data structure implementation for generic data type with each node declared as following. struct Node { void *data; .... .... } So each node in my list will have pointer to the actual data(generic could be anything) item that should be stored in the list. I have following signature for adding a node to...

C code won't compile

Please help me to understand why the following code will not compile: #include <stdio.h> //#include <iostream> //using namespace std; int main(void){ int i,k,x,y,run,e,r,s,m,count=0; char numbers[19][19]; for(i=0;i<19;i++){ for (k=0;k<19;k++){ numbers[i][k]='.'; } } void drawB(){ printf("...

Is there an example for mark with right gravit?

Quoted from here: The standard left-to-right cursor is a mark with right gravity (when you type, the cursor stays on the right side of the text you're typing). Now I see what's an mark with right gravity. But I still don't have an idea what's a mark with left gravity like,is there an example of left gravity mark? ...

DeviceIoControl problem (IncorrectFunction)

Hi there! I'm trying to make my own ioctl driver command for calling it from an user-mode application dll. For now I just wanted to make sure the dll succesfuly calls that command on the driver code. So I defined my command (in the dll and in the driver's code) like this: #define BUSENUM_IOCTL(_index_) \ CTL_CODE (FILE_DEVICE_BUS_E...

How do I understand what the following means?

Quoted from here: if (to_end) { /* If we want to scroll to the end, including horizontal scrolling, * then we just create a mark with right gravity at the end of the * buffer. It will stay at the end unless explicitely moved with * gtk_text_buffer_move_mark. */ gtk_text_buffer_create_mark (buffer...

Feasability of reverse engineering some embedded code

All, My company is in the situation where we are using an embedded control system from another company in another country. We do not have the source code or the schematics to this system, and the manufacturer doesn't want to release them, seemingly at any price or under any terms. We are thus stuck with a 6 month turn around to get eve...

Inline function in other inline function in C.

Will this code: inline int funcA(int a) __attribute__((always_inline)) { return a + 1; } inline int funcB(int b) __attribute__((always_inline)) { return funcA(b + 2); } int main() { return funcB(3); } transformed to code like this?: int main() { return ((3) + 2) + 1; } GCC, ARM (iPhone) ...

What is sys/user.h used for ?

I was inspecting the code of a linux application and i saw the #include in one of the code files. I tried looking it up on opengroup.org but i couldn't find it there, this is what the sys directory looks like: http://www.opengroup.org/onlinepubs/000095399/basedefs/sys/ . I guess it's not standard header file, but i checked it in my /usr...

Correct way to initialize a NULL-terminated array of strings in C

Is this code correct? char *argv[] = { "foo", "bar", NULL }; ...

How do I control widgets added later with gtk in c?

func1(); func2(); ... In func1 there is a button widget,and in func2 a textview widget.(Both calls gtk_box_pack_start to add widgets to the window, so the order can't be changed.) I want to operate textview when I click on button widget. But at the time I define the callback,textview is not available yet. How can I work around this?...

While with multiple conditions

Can somebody please explain why an expression (I study C) like while(a!=1 || b!=1 || c!=1) causes problems. In particular I have this specific code: while (ch != '\n' || ch != '\t' || ch != ' ') { ... } ...

Multiply with negative integer just by shifting.

Hi, I'm trying to find a way to multiply an integer value with negative value just with bit shifting. Usually I do this by shifting with the power of 2 which is closest to my factor and just adding / subtracting the rest, e.g. x * 7 = ((x << 3) - x) Let's say I'd want to calculate x * -112. The only way I can imagine is -((x << 7) - (...

How, exactly, does the double-stringize trick work?

At least some C preprocessors let you stringize the value of a macro, rather than its name, by passing it through one function-like macro to another that stringizes it: #define STR1(x) #x #define STR2(x) STR1(x) #define THE_ANSWER 42 #define THE_ANSWER_STR STR2(THE_ANSWER) /* "42" */ Example use cases here. This does work, at least i...

Is there a way to ‘join’ (block) in POSIX threads, without exiting the joinee?

I’m buried in multithreading / parallelism documents, trying to figure out how to implement a threading implementation in a programming language I’ve been designing. I’m trying to map a mental model to the pthreads.h library, but I’m having trouble with one thing: I need my interpreter instances to continue to exist after they complete ...

Run-Time Check Failure #2 - Stack around the variable 'indices' was corrupted.

well I think I know what the problem is. I am just having a hard time debugging it. I am working with the directx api and I am trying to generate a plane along the x and z axis according to a book I have. The problem is when I am creating my indices. I think I am setting values out of the bounds of the indices array. I am just having a ...

Does C use lambda expressions?

And, if it does, how do you use one? (syntax) Also, why does or why doesn't C support lambda expressions? ...

I need to consume an ocx for voice recording and playblack

Hi. The current ocx controls I'm using for voice recording and playback are not compatible with Windows 7. I'm already feeling the pressure to produce a Windows 7 compatible version of my software. The author has already stated that he is not planning to write a Windows 7 compatible ocx. I work from xharbour so I need to consume an...

C semaphores: sem_wait throwing inexplicable error

I'm working on a problem which we have to use semaphores to solve. I have an array which contains two semaphores, gsem, and given certain conditions call sem_wait(&(gsem[me])), which is supposed to waiting until that particular process is woken up. However, for some reason it gives me the error Bad file descriptor. I looked up sem_wait a...

C++ LPTSTR to int (but memory overwrite problem using atoi)

I have the following code, m_edit is a MFC CEdit (I know I would never use MFC but project demanded it). It's a simple loop, that gets the text from a text edit, converts it to integer after getting the first line, then stores it in m_y vector. LPTSTR szTemp; vector<int> m_y; for(int i = 0; i < m_edit->GetLineCount(); i++){ szTemp ...

How do I get rid of the console when writing GUI programs with gtk in C?

I'm following the tutorial: http://zetcode.com/tutorials/gtktutorial/firstprograms/ It works but each time I double click on the executable,there is a console which I don't want it there. How do I get rid of that console? Platform: windows XP. BTW I also have this trouble when right click on the icon: GLib-WARNING **: g_main_contex...