c

Why is my C++ app faster than my C app (using the same library) on a Core i7

I have a library written in C and I have 2 applications written in C++ and C. This library is a communication library, so one of the API calls looks like this: int source_send( source_t* source, const char* data ); In the C app the code does something like this: source_t* source = source_create(); for( int i = 0; i < count; ++i ) ...

calling convention in c

some one please tell me how to change the default calling convention in c? ...

Help with opening a file in C on Xcode

I'm trying to open a simple .rtf file called test in C. I'm using Xcode. My code is: #include <stdio.h> #include <stdlib.h> int main (int argc, const char * argv[]) { FILE *filePtr; filePtr = fopen("test.rtf", "r"); if (filePtr == NULL) { fprintf(stderr, "Can't open \"test\"\n"); exit(EXIT_FAILURE); }...

char is signed or unsigned by default

In the book "Complete Reference of C" it is mentioned that char is by default unsigned. But i am trying to verify this with GCC as well as visual studio. It is taking it as signed by default. which one is correct ...

accessing sqlite with C program

Core dumped while running this program: int main(void) { sqlite3 *conn; int error = 0; error = sqlite3_open("cloud_db.sqlite3", &conn); if (error) { puts("Can not open database"); exit(0); } error = sqlite3_exec(conn, "update server set servername=\'Laks\' where ipaddress=\'192.168.1.111...

How to protect Python source code?

Is it possible to distribute only the bytecode version (.pyc file) of a Python script instead of the original .py file? My app embeds the Python interpreter and calls PyImport_Import to load a script. How can I tell it to look for a .pyc file and import that? ...

Adjust AGNAS::SampleCoreTemp polling rate

Anyone here familiar with the AGNAS library? I've got SampleCoreTemp mostly doing what I want but it spikes CPU usage too much when it's active and I don't want to have to enable/disable constantly if I can find a way to adjust the polling rate instead. ...

Performance/profiling measurement in C

I'm doing some prototyping work in C, and I want to compare how long a program takes to complete with various small modifications. I've been using clock; from K&R: clock returns the processor time used by the program since the beginning of execution, or -1 if unavailable. This seems sensible to me, and has been giving results whic...

BST implementation

What's wrong with the following implementation of a binary search tree (BST)? I have been told that it is better to use pointer to a pointer to struct node as an argument in insert function. struct node { int key_value; struct node* left; struct node* right; }; insert(int key, struct node *leaf) { if( leaf == 0 ) { leaf...

Cement Effect - Artistic Effect

I wish to give an effect to images, where the resultant image would appear as if it is painted on a rough cemented background, and the cemented background customizes itself near the edges to highlight them... Please help me in writing an algorithm to generate such an effect. The first image is the original image and the second image i...

Visual C++: Migrating traditional C and C++ string code to a Unicode world

I see that Visual Studio 2008 and later now start off a new solution with the Character Set set to Unicode. My old C++ code deals with only English ASCII text and is full of: Literal strings like "Hello World" char type char * pointers to allocated C strings STL string type Conversions from STL string to C string and vice versa using S...

forcing a program to flush its standard output when redirected

i have a closed source program that prints output to standard output. i need to parse the output. so i redirect the output to a fifo (from which i can read in the parent process that forks and execs the binary) using dup2 and then exec the program. the problem is that the fprintf calls in the file become buffered because it is now writin...

Netbeans C/C++ JavaDoc code-completion

Hello, I am developing C++ in NetBeans 6.7.1. When I press CTRL + space for autocomplete there is shown only method's signature. I am using JavaDoc for commenting my code but NetBeans doesn't show it. I have installed Doxygen plugin but it is only for generating complete documentation. Is there any way how to force the IDE to show sign...

VC++ replaces defines of different objects, GCC etc. not

Hi, I have a big app using many static libs, which is platform independant and deployed under Windows and Linux. All static libs and the main() itself are compiled with two defines: -DVERSION=1.0.0 -DBUILD_DATE=00.00.0000 These defines are used by macros inside each static lib and inside the main to store the current lib version ins...

Transform an array of integers into a string

A function returns an aray of integers and I want it to pass to another function which searches for some pattern. But the second function expects a string. Example: int IArray = {1, 2, 3}; // should be coverted into "123" Is there a direct function available? If not, how do I convert the array of integers into a string? ...

URL is changed after processing in C/CGI

Hello All, I have a C/CGI application. In order to redirect to the same page const char * redirect_page_format = "<html>\n" "<head>\n" "<meta http-equiv=\"REFRESH\"\n" "content=\"0;url=%s\">\n" "</head>\n" "</html>\n"; printf (redirect_page_format, getenv (URL)); Before this the url is like this "http://ipaddress/page.html". For so...

How to use socket in win32

i have created the socket program to run in win32 service but the problem i'm facing is that when i start the service it'll start and it is using CPU move its all most 50% of the CPU. i'm using AMD 64bit processor. if i write a program without socket it wont use CPU as much. wat should i do to solve this problem. ...

C: Creation of ordered list by checking 2 values

Hello, I'm new to C so be patient with me if you see some really newbie error in my code! As part of a homework, I need to create an ordered list in order to store some data. What I've done so far is to create the struct which will represent each node of the list (firstNode is a global variable that points to the first node of the list...

Modify nautilus source code, where to start?

I have a simple starter problem to change an open source project. Let me first explain the situation: I want to make some changes on an open source project (NAUTILUS) , The change is to work on This idea(Progress window for file operations) , The fist step is to download the source , done (using git) The next step is to read the ...

cannot write to pty - linux

i am the owner of the pty device created like this permissions are crw-w---- mknod pty1 c 1 1 cat > pty1 tells me operation not permitted. what i want to do later is that i open the file from a program using open and call write to send output to the terminal, as if it is a disk file. why is cat not working. can we write to a pty or ...