c

Deploying C app that uses the PCRE library

Hello, I wrote a C app that uses the PCRE library. Everything works on my own computer. However, when I copy the binary over to another computer and run it, it gives the following error: /libexec/ld-elf.so.1: Shared object "libpcre.so.0" not found, required by "myapp" I know I can probably get it to work by installing the PCRE lib on ...

Automatically port conversion elements of C code to C++

Hi, Is there some tool that can automatically convert the following c style code A *a = b; to A *a = (A*)b; Thanks, James ...

Rounding Number to 2 Decimal Places in C

How can I round a float (such as 37.777779) to two decimal places (37.78) in C? ...

How can I create an executable to run on a certain processor architecture (instead of certain OS)?

So I take my C++ program in Visual studio, compile, and it'll spit out a nice little EXE file. But EXEs will only run on windows, and I hear a lot about how C/C++ compiles into assembly language, which is runs directly on a processor. The EXE runs with the help of windows, or I could have a program that makes an executable that runs on a...

Erlang: The specified module could not be found.

I've got a bare-minimum Erlang port driver: erl_driver_bridge.c -> erl_driver_bridge.dll #define __WIN32__ #include "erl_driver.h" typedef struct { ErlDrvPort port; } erl_driver_bridge_data; static ErlDrvData bridge_start(ErlDrvPort port, char *buff) { erl_driver_bridge_data* d = (erl_driver_bridge_data*)driver_alloc...

Is it possible to view a binary in ones and zeros?

By that I mean is it possible to write a program in C, compile it and then see what it looks like in ones and zeros? It would be cool to act like a 1337 hacker and pretend to actually program in ones and zeros :p . ...

Possible to build a shared library with static link used library?

I can build a executable with gcc with static link: gcc -static xxx.c -o xxx So I can run xxx without any external dependent library. But what if I want to build shared library without externel dependent library? which I mean I want the shared library statically linked its externel reference in. ...

Why sockaddr_storage structure defined as the way it is defined?

Below is the definition of sockaddr_storage structure (rfc2553). According rfc2553, the sockaddr_storage should be aligned with 64 bit boundary and it should be able to hold both sockaddr_in and sockaddr_in6. Also, it must have atlest __ss_family member. Rest of the fields are implementation defined. #define _SS_MAXSIZE 128 /* Imple...

C : gdb behavior : value optimized out

Can anyone explain this behavior of gdb :- 900 memset(&new_ckpt_info,'\0',sizeof(CKPT_INFO)); (gdb) **903 prev_offset = cp_node->offset;** (gdb) **905 m_CPND_CKPTINFO_READ(ckpt_info,(char *)cb->shm_addr.ckpt_addr+sizeof(CKPT_** HDR),i_offset); (gdb) **903 prev_offset = cp_node->offset;** (gdb) **905 ...

Convert string to integer recursively?

Here is a simple function that converts a string to an integer. int str2int(char *str) { int ret = 0; char *c; for (c = str; (*c != '\0') && isdigit(*c); ++c) ret = ret*10 + *c - '0'; return ret; } As an exercise, I'd like to write a recursive function that does the same thing. This is what I came up with. ...

How to access Digital I/O using USB

Hi, How to access Digital I/O using USB using C or C++ or Vb.net Or C#.net? ...

Where is the best place to learn C?

I absolutely loved Dive Into Python when I picked up Python. In fact, "tutorials" such as Dive Into Python work really well for me; short brief syntax explanations, and plenty of examples to get things going. I learn really well via examples. I have programming experience in Java, Scheme, Python, PHP, Javascript, etc. Is there anywhe...

C memory space and #defines

I am working on an embedded system, so memory is precious for me. One issue that has been recurring is that I've been running out of memory space when attempting to compile a program for it. This is usually fixed by limiting the number of typedefs, etc that can take up a lot of space. There is a macro generator that I use to create a ...

Stack smashing detected

I am executing my a.out file .After execution the program runs for some time then exits with the message: ** stack smashing detected : ./a.out terminated ======= Backtrace: ========= */lib/tls/i686/cmov/libc.so.6(__fortify_fail+0x48)Aborted* What could be the possible reasons for this and how do I rectify it? ...

How to open an image using C??

Hi everyone, I have many times opened a txt file using C language Files manipulations. But when i try to open an image using C Files, I just cant do that. I even tried this by opening the image file in binary mode("rb"). Could you please help me out for doing this... Thanks :) ...

Find where a function (or macro) is called with a given argument

I need to know if it's possible to use a tool like ctags or cscope to find all the usages of a function but filter the results depending on the value of one of its parameters. For example, let's assume we have a function void foo(int a, int b) that is used a thousand times along all the source tree and I need to check if it's being call...

Detect usage of macro? (errno)

This is very specific, and a bit difficult to explain, and quite likely impossible, but here goes. Perhaps some C cracks out there have an idea... I want to implement <errno.h>. (My hobby project is implementing a Standard C library.) The naive way to go about it is: // in <errno.h> extern int errno; // in some .c file int errno = 0;...

32bit 64bit compatible

Hello, I am developing an application that will run on 64 bit computers. However, we are using a library that has 32 bit integers that we cannot change. And we will need to compile and run on a 64 bit computer. What would the implications be when the application is running? Is there any work around? Many thanks for any advice, ...

return two values out of a remote thread (C, windows)

I currently have a thread that I created using CreateRemoteThread(). Everything works great. Upon finishing (or an error before completion) the thread returns one of the five return codes that we defined. I run into a problem and I need to return the results of GetLastError() as well. Is there any way to return two values? I am using W...

How to implement tertiary search in C?

Write tertiary search program. Notes: Tertiary search is similar to binary search. In binary search we consider two parts of the array and select one part as the next search space. In tertiary search we consider the array in 3 equal parts. For this, we take two "middle" indices, middle1 and middle2 respectively at 1/3 and 2/3 of the arra...