c

Is this possible to call c/c++ application from DB2 stored procedure/trigger?

Is this possible to call c/c++ application from DB2 stored procedure/trigger? If yes, what would be general steps doing it? Any pointers to web resources on the subject? Thanks! ...

What does explorer use to open a file?

I'm attempting to hook into whatever explorer calls when a file is opened (double-click, context menu open, etc.), however I can't figure out which function that is. Originally, I thought it was ShellExecute, as that does the same thing as far as I can tell, but after hooking into it I learned that it's only used when a new explorer win...

Implementing DHCP client

On unix using C, my client is listening on port 68 with superuser mode. After sending DHCP discover message, when I try to receive, it blocks in recvfrom means there is no message received or is it like system has a process (DHCP client) listening on same port 68 which receives the message and thats my process are not able to receive th...

This form of use of printf api makes it safer?

char str[] = "some text"; printf ( "%.*s", strlen(str), str ); ** Of course, their buffers, strings yet to be properly targeted ...

slightly weird (imo) C++ code

Sorry if this is simple, my C++ is rusty. What is this doing? There is no assignment or function call as far as I can see. This code pattern is repeated many times in some code I inherited. If it matters it's embedded code. *(volatile UINT16 *)&someVar->something; edit: continuing from there, does the following additional code conf...

Why doesn't getchar() recognise return as EOF in windows console?

I have a small snippet of code below that i'm running using PellesC. When the code is executed and i've typed a few characters into the console, i press enter. Can you explain to me why the printf("%ld\n", nc); line doesn't seem to get executed? As no output is written to the console. #include <stdio.h> int main(void) { long nc ...

Best way to check if a character array is empty

Which is the most reliable way to check if a character array is empty? char text[50]; if(strlen(text) == 0) {} or if(text[0] == '\0') {} or do i need to do memset(text, 0, sizeof(text)); if(strlen(text) == 0) {} Whats the most efficient way to go about this? ...

Why does GCC give me a syntax error when trying to return a struct pointer?

I'm using CodeLite on Ubuntu and for some bizzare reason GCC keeps throwing this error whenever I try to compile code with a function that returns a pointer to a struct: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token Here is an example I wrote up to demonstrate this error: #include <stdio.h> typedef struct ...

Why is separate getaddrinfo-like() + connect() not refactored into a (theoretical) connect_by_name() ?

Most of the applications I've seen that use TCP, do roughly the following to connect to remote host: get the hostname (or address) from the configuration/user input (textual) either resolve the hostname into address and add the port, or use getaddrinfo() from the above fill in the sockaddr_* structure with one of the remote addresses u...

Accessing data link layer packets

I want to create a socket for accessing IPv4 packets from data link layer. From unix network programming V1, socket(PF_PACKET, SOCK_DGRAM, htons(ETH_P_IP)) 1)I am implementing a dhcp client, is this the correct way of doing that? (means without accessing data link layer, i cannot receive reply from dhcp server) or is there any other e...

Draw a polygon in C

Hi, i need to draw a polygon of "n" sides given 2 points (the center and 1 of his vertex) just that i suck in math. I have been reading a lot and all this is what i have been able to figure it (i dont know if it is correct): Ok, i take the distance between the 2 points (radius) with the theorem of Pythagoras: sqrt(pow(abs(x - xc), 2) +...

Recommendations for C Profilers?

Everyone always says to profile your program before performing optimizations but no-one ever describes how to do so. What are your practices for profiling C code? ...

Check connection open or closed ?(in c in Linux)

In socket programming in Linux I need to write data in socket but I don't know socket is open or close . how to I know that socket is open and close without read ? printf("befor read%d\n", n); bzero(buffer, MAX_SIZE_BUFFER); n = read(sockfd, buffer, MAX_SIZE_BUFFER - 1); printf("after read%d\n", n); if (n <= 0) { break; } printf("be...

static - used only for limiting scope?

Is the static keyword in C used only for limiting the scope of a variable to a single file? I need to know if I understood this right. Please assume the following 3 files, file1.c int a; file2.c int b; file3.c static int c; Now, if the 3 files are compiled together, then the variables "a" & "b" should have a global scope and ...

Case fold UTF-8 without knowing the language

I'm trying to evaluate different strategies for case insensitive UTF-8 string comparison. I've read some material from the Unicode consortium, experimented with ICU and tried to come up with various quality-of-implementation alternatives. On multiple occasions I've seen texts differ between Simple Case Mapping and Full Case Mapping, an...

What is the current scheme for naming variables and functions?

Is there a standard way to name them or is it programmer's call? Thank you. ...

in lex how to make yyin point to a file with the main function in yacc?

I am storing the arguments passed to main in yacc in a file. Now I want the lex to read its input from this file rather than the terminal. I know I can point yyin to a file like yyin = fopen("fn","r"); but this works only when main is in lex. When I use this yyin declaration in main in yacc, it shows an error so please suggest something...

C - the limits of speed of the Desktop-CPUs if program is build using GCC with all optimization flags?

We are planning to port a big part of our Digital Signal Processing routines from hardware-specific chips to the common desktop CPU architecture like Quad-Core or so. I am trying to estimate the limits of such architecture for a program build with GCC. I am mostly interested in a high SDRAM-CPU bandwidth [Gb/sec] and in a high number of ...

Bit Shifting, Masking or a Bit Field Struct?

Hi, I'm new to working with bits. I'm trying to work with an existing protocol, which can send three different types of messages. Type 1 is a 16-bit structure: struct digital { unsigned int type:2; unsigned int highlow:1; unsigned int sig1:5; unsigned int :1; unsigned int sig2:7; }; The first two bits (type, in my struct abov...

What does (int (*)()) mean in a function call

Like the title says, I want to know what "(int (*)())" in a C-define-function-call means? As example, it looks similar to this: #define Bla(x) (Char *) read((char *(*)()) Blub, (char **) x) or this #define XXX(nx, id) PEM_ASN1_write_bio((int (*)()) id, (char *) nx) Thank you in advance! ...