c

What is the fastest looping in Java?

Recently, I want to optimize my code. Would any one tell how to speed up looping? While-loop is faster than for-loop? And which type of for-loop is faster? It is surely I am not talking about a empty content looping. I mean If any good way to loop a huge data in Java or Python. And I got the answer from here ...

C question related to pointers and arrays

Hi, Basically in the code below, my final array does not seem to have the contents from function1(). Any ideas on why I can't get this to work ? Thanks. #include <stdio.h> #include <string.h> #include<stdlib.h> unsigned char *function1() { unsigned char array2[] = { 0x4a,0xb2 }; return (array2 ); } main() ...

64-bit issues: trying to copy value from %rsp into temp variable using inline assembly

I'm taking an operating systems design class in which they have given us a microkernel written in C that we're building on top of. The kernel seems to have been designed with 32-bit machines in mind and I'm running snow leopard. So a friend in the class and I have been trying to hack it into 64-bit addressing. The biggest issue seems to...

Why does Lua report that lua_pushlstring is undefined?

I managed to compile Lua 5.1.4 for Palm webOS and now I'm trying to write an extension to use webOS' services from Lua. However, when I try to load my library, Lua reports: undefined symbol: lua_pushlstring Here's my code: #define LUA_LIB #include "lua.h" #include "lauxlib.h" static int hellopalm(lua_State *L) { lua_pushliteral(...

How to retrieve the current processor time in Linux?

Hi, I am using C language and Linux as my programming platform in embedded device. My question is, how to correctly retrieve the current processor time(tick). I am using clock() function in time.h and it seems I am getting inconsistent value. Thanks. ...

making an isolated process via c program in windows xp?

i have an application with 4 threads from which 2 are event based and 2 are not event based. the problem is i have to isolate the 2 non event based threads in which while(1) loop is executing that takes a huge cpu usage and this usage reaches even up to 100%, i think making these threads isolated can reduce the cpu usage, will it be a...

Prevent Up-Down control for Tab Control?

As documented: "If not all tabs can be shown at once, the tab control displays an up-down control so that the user can scroll additional tabs into view." http://msdn.microsoft.com/en-us/library/bb760550%28VS.85%29.aspx I don't want this. I don't want an up down control to show if I have too many and I don't want multiline tabs. I...

Is Visual C++ as powerful as gcc?

My definition of powerful is ability to customize. I'm familiar with gcc I wanted to try MSVC. So, I was searching for gcc equivalent options in msvc. I'm unable to find many of them. controlling kind of output Stop after the preprocessing stage; do not run the compiler proper. gcc: -E msvc: ??? Stop after the stage of compilation pr...

In C, How does memcpy deal with a signed integer argument?

In C, what will happen if I supply a signed integer especifically a negative integer as the 3rd argument to the memcpy function? Example: memcpy(destBuf, source, -100*sizeof(source)) Will the result of -100*sizeof(source) be interpreted by memcpy as unsigned? Thanks! ...

Double Pointer question

Greetings all, Please take a look at following code: #include <stdio.h> #include <iostream> using namespace std; typedef struct MyType{ int num1; }; void test(MyType **src) { MyType *ret=new MyType; ret->num1=666; *src=ret; } int main(){ MyType *mSrc; test(&mSrc); printf("%d Address\n",mSrc); printf("%d Value \n",mSrc->num1)...

Validation For Phone Number and Mobile Number

Hi Friends, I need a c,c++ code for validating a Phone Number(8 Digits- Starting with 2) and Mobile Number(10 Digits- Starts with 9). Also it should not allow to enter any space, special charcter, as well as charcters. Here user can enter either phone number or mobile number. Plese Help in this, Thanks, ...

Syncronize system clock with UTC time using c uder Window OS

I have UTC time which is coming from UDP, I have a program to calculate Day and Time of UTC, how can I set my system clock at that day and time, kindly give me some direction so that I can make it possible. I am using window OS. ...

How to make printf() properly print a binary blob from within a macro?

In a project of mine (which for technical reasons must not depend on any external libraries or third-party sources) I have set up the following test.h: static int rc = 0; #define TESTCASE( x ) if ( x ) {} \ else \ { \ rc += 1; \ printf( "FAIL...

How to pass a pointer to a member function to a C function?

Possible Duplicate: Using a C++ class member function as a C callback function I'm writing an object-oriented library using a C library (winpcap). I need to pass the callback function that is called when a network packet arrives as a function pointer. I would like to pass a member function pointer to winpcap, to keep my design...

Problem between IO heavy operations and network application listening for UDP and SCTP data.

We have an application that uses two types of socket, a listening UDP socket and an active SCTP socket. At certain time we have scripts running on the same machine that have high IO activities (such as "dd, tar, ..."), most of the time when these IO heavy applications run we seem to have the following problems: The UDP socket closes T...

Using a hash table to create an unlimited array

I am currently developing a programming language in C, and I want to allow users to create apparently "unlimited" arrays with numerical indices without sacrificing performance in the process. For example, table [1000000000] would ideally be creatable and accessible in an instant without the memory overhead of a table of 1,000,000,000 ite...

Transfer files in C

How do I transfer files from one folder to another, where both folders are present in oracle home directory? int main(int argc, char *argv[]){ char *home, *tmp2; home = getenv("ORACLE_HOME"); temp2 = getenv("ORACLE_HOME"); strcat (home,"A"); strcat (tmp2,"B"); //transfer files from home to tmp2 } strcat doesn't ...

Library to manage menus in embedded device for C/C++

I'm looking for a library to manage menus. I'm looking for something which is based on configuration files. It doesn't have to manage keyboard input or display, just the menu logic. What I have in mind something like: //menu.xml <menu> <Start /> <Stop /> <Configuration displayname="Configure System"> <Sound type="tog...

confused about printf() that contains prefix and postfix operators.

If int var=20 then how printf("%d %d %d", var--, ++var, --var); execution happens in C programming language. ...

C++ or Python (maybe else) to create GUI for console application in C

I have a Visual C console application (created in VC++2008EE) and I need to add GUI to it. One idea was to invoke the console app as a subprocess and communicate with it using stdin and stdout. I tried to do that with Python subprocess module - but it deadlocks (probably because my console app is running continuously). As I understood f...