c

How to return the index of ascii char in C

So you have Table mapping the 26 ascii characters from the English alphabet to their corresponding morse code strings typedef struct a_look_tab { char table[asciiNum][MORSE_MAX+1]; } ALookTab; and asciiNum is the 0 for a, 1 for b, and so on. how to return an index (int) that is the index of the morse char. So what we are doing...

gcc -fPIC seems to muck with optimization flags

Following along from this question: how-do-i-check-if-gcc-is-performing-tail-recursion-optimization, I noticed that using gcc with -fPIC seems to destroy this optimization. I am creating a shared library, but I doesn't seem to need the -fPIC option. Well, my question is, why does -fPIC change gcc optimizations ? Do I need to keep -fPIC ...

How to hide Gtk Popup Window when user clickes outside the window.

I have developed one popup window (Non decorated) using GTK+ and glade tool in C. It popup on its parent window when a button clicked. I want to destroy or hide this popup window when user clicks out side this window. User can click on parent window or any other window. I have tried to capture GDK_FOCUS_CHANGE event but I am not able t...

C: Accessing a pointer from outside a function

I have the following code: int takeEven(int *nums, int numelements, int *newlist) { newlist = malloc(numelements * sizeof *newlist); int i, found = 0; for(i = 0; i < numelements; ++i, nums++) { if (!(*nums % 2)) { *(newlist++) = *nums; found++; } } newlist -= found; printf(...

Pointer notation in C

I know more C++ than C. Does C use -> for pointers, or is that only used in C++? ...

Character decoding Conversion Function Implementation

Hi, I need to implement a character encoding conversion function in C++ or C( Most desired ) from a custom encoding scheme( to support multiple languages in single encoding ) to UTF-8. Our encoding is pretty random , it looks like this Because of the randomness of this mapping, I am thinking to use std::map for mapping our encoding t...

gtk beginner app won't work with assertion fail

I've done this simple app in Gtk, just to test things out... I come from swing so redefining a draw event function is normal for me... Anyway seems not to work: #include <gtk-2.0/gtk/gtk.h> #include <gtk-2.0/gdk-pixbuf/gdk-pixbuf.h> #include <stdlib.h> #include<string.h> #include<stdio.h> #include <iostream> GdkPixbuf *imm; void destr...

display a image from the internet in gtk

I wanna display a image from the internet how can I put it? ...

Passing three dimensional arrays into functions in C?

What is the best way to pass three dimensional arrays into functions in C? ...

Inconsistent results from printf with long long int?

struct DummyStruct{ unsigned long long std; int type; }; DummyStruct d; d.std = 100; d.type = 10; /// buggy printf, unsigned long long to int conversion is buggy. printf("%d,%d\n",d.std, d.type); // OUTPUT: 0,100 printf("%d,%d\n", d.type, d.std); // OUTPUT: 10,100 printf("%lld,%d\n",d.std, d.type); // OUTPUT: 100,10 ...

Converting C (not C++) to C#

I have some old C 32 Bit DLLs that are using Oracle's Pro C precompiler library (proc.exe) to expose a hundred or so sproc/func calls to an even older VB6 GUI which references these functions through explicit Declare statements like so: Declare Function ConnectToDB Lib "C:\windows\system32\EXTRACT32.DLL" (CXN As CXNdets, ERR As ERRdets)...

Linux inter-process reentrant semaphore

I'm porting a Windows application to Linux and I have a synchronization problem. In Windows I'm using a system-level named mutex to sync access to a shared memory block. How do I emulate that in Linux? I've created a SystemV semaphore, using semget. The problem is that it is not reentrant, if I already hold it it will block, unlike on ...

How do you actually use a C library?

I'm sure this question has been asked many times, but I can't figure this out. Bear with me. So when you download a library, you get a bunch of .c and .h files, plus a lot of other stuff. Now say you want to write a program using this library. I copy all the .h files into my project directory. It just doesn't compile. Great, so then I...

Prime number generator in C

Where can I find a prime number generator in C? ...

Check whether function is declared with C preprocessor?

Is it possible to tell the C preprocessor to check whether a function (not a macro) is declared? I tried the following, but it doesn't appear to work: #include <stdio.h> int main(void) { #if defined(printf) printf("You support printf!\n"); #else puts("Either you don't support printf, or this test doesn't work."); #endif ret...

help on typedefs - basic c/c++

hi, i have been going through some code and came across a statement that somehow disturbed me. typedef GLfloat vec2_t[2]; typedef GLfloat vec3_t[3]; From my perspective, a statement such as typedef unsigned long ulong; Means that ulong is taken to mean unsigned long Now, can the statement below mean that vec2_t[2] is equiv...

how do aim bots in fps games work?

I was curious if anyone had any experience/knowledge about aim bots in online FPS games such as Counter-Strike. I am curious and would like to learn more about how the cursor knows how to lock on to an opposing player. Obviously if I wanted to cheat I could go download some cheats so this is more of a learning thing. What all is involved...

Need help with brute force code for crypt(3)

Hello, I am trying to develop a program in C that will "crack" the crypt(3) encryption used by UNIX. The most naive way to do it is brute forcing I guess. I thought I should create an array containing all the symbols a password can have and then get all possible permutations of them and store them in a two-dimensional array (where all th...

How to specify a variable expression list in a Pro*C query?

I have a little problem with a Pro*C query I'm trying to optimise. To explain, our application searches for rows in a huge database. These rows exist in several languages and the old code selected a row for each language in an array. Now as these queries are the most time consuming part of our app, I wanted to make only one query which ...

Python, C: redirected stdout fires [Errno 9]

I try to log all the output of a program written in Python and C. However, printing from Python causes IOError: [Errno 9] Bad file descriptor Please, does anyone know what the problem is and how to fix it? PS: It's on Windows XP, Python 2.6 and MinGW GCC #include <windows.h> #include <fcntl.h> #include "Python.h" int main() { int...