Yes, you can simplify this code - I would suggest to dismiss branching statements in "decode" procedure and make use of static array of LED patterns. Something like:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAKE_PATTERN(b1, b2, b3, b4, b5) ((b1 << 4) | (b2<<3) | (b3<<2) | (b4<<1) | b5)
#define EXTRACT_BIT(pattern, bit) (((1<<bit) & pattern) != 0)

static int ledStates[] = {

typedef struct LATGbits
    unsigned char LATG1;
    unsigned char LATG0;
    unsigned char LATG13;
    unsigned char LATG14;
    unsigned char LATG12;

} LATGbits;

void decode (unsigned char * msg) {
    char * found = strstr(msg, "DO=");

    if (found == NULL)

    int ledPatternIndex = (int)strtol(found+3, NULL, 16);

    // something wrong with input string parsing
    if (ledPatternIndex == 0 && strstr(msg, "DO=0x00") == NULL)

    if (ledPatternIndex > 31)

    int pattern = ledStates[ledPatternIndex];

    LATGbits lATGbits;

    lATGbits.LATG1    = EXTRACT_BIT(pattern, 4);
    lATGbits.LATG0    = EXTRACT_BIT(pattern, 3) ;
    lATGbits.LATG13   = EXTRACT_BIT(pattern, 2) ;
    lATGbits.LATG14   = EXTRACT_BIT(pattern, 1) ;
    lATGbits.LATG12   = EXTRACT_BIT(pattern, 0) ;

int main()
    return 0;

Hope that helps !

As unofficial rule - all C/C++ macros are written in all caps. Underscores simply helps to improve readability if constant consists from several words. It's possible to name a variable with underscores, but it's uncommon. So if you see all caps symbol with underscores in it - you can be pretty sure that it's a macro definition.

[QUOTE=hovestar;1721794]Or you could devise an AI to follow the left wall[/QUOTE]
This doesn't works if maze has disconnected walls.

[QUOTE=fallopiano;1464979]Hey everyone, as the title suggests I'm trying to find a function or some code that'll execute a string of code in Lua.

What language is the most difficult to compile and why ? (except natural ones)

[QUOTE=mohan_198505;787487]4.Login name and password are hardcoded in the program and not strored in any file.[/QUOTE]
I find this self-contradictory. "Hardcoded" means that password WILL BE stored in program file as embedded string resource. So for added security i suggest to hardcode not plain password, but instead MD5 hash of password. And when user enters password - you will do check md5(password)==[ICODE]hardcoded_md5_of_password[/ICODE].
Point is that if something will extract password hash from the executable file - he/she will not find-out password, because md5 hash is one way encryption. (Unless he/she does bruteforce,- generates all possible passwords and compares it's hash with stored one).
In any case a way of storing md5 hash is a LOT more secure than storing just plain password.
google MD5,- there a a lot of md5 implementations in C.
good luck

seems there is a better way to implement what you want, see here:

[ICODE]write_data(...)[/ICODE] is callback function which will be called every time each new data portion arrives from internet. So basically you should measure download speed and remaining time in your function write_data():

  1. save current time in local variable time1
  2. then download speed will be [ICODE]written/(time1-time2)[/ICODE]

  3. save current time in global variable time2
  4. remaining time will be [ICODE]bytes remaining/download speed[/ICODE]
    Current time you can get with functions in time.h.
    As about bytes remaining, i am not sure. It should be => total fize size - current file size. The problem is how to get total file size. Check libcurl documentation - maybe there are some functions which probes file sizes on net before downloading it.

good luck.

And a bit shorter version ;)

Also i want to say that this question is related to compiler design. So i would suggest to learn compiler design/programming in general, before advancing to concrete problem.

[QUOTE=anu john;416424]Ye. it will be a kit with ethernet chip n rj45 connections.therefor the tcp/ip protocols needed will be taken care of..
nw i need to program my controller using c language in a way that i can access my sql server 2005 on a remote machine...Also im trying to find out if keil compiler supports vc++, since i know that sql can be connected using this language...
plz reply...[/QUOTE]

Then i think most simple way to achieve this is:

  1. run your own web server somewhere on net.
  2. connect web server to SQL database through PHP or other methods.
  3. make HTTP calls (POST/GET) from your ethernet chip to that web server.

So that is communication will be =>
your controller <-> http server <-> sql server

As about SQL problems i could suggest only 2 things, because main perfomance problem is disk IO:

  1. Read/write from/to SQL server as rarely as possible. (Maybe you can cache data localy for some miliseconds or so and after reaching cache limit - send data for update to SQL server. Reads you can perfom more frequently, but also should be lowered as possible)
  2. Put all database files on [URL="

From the problem description is not clear - Do you want just move 3D model in space or animate different pose ? Ok, I make assumption that you want to animate pose, because you mention different body parts.
How to do that just google keywords "mesh deformation" and/or "skinning GPU".
Here is a crash tutorial how to do very simple mesh deformation on GPU-
(skinning should be done on GPU with the help of vertex shaders because it should be more efficient)

Happy coding.

I don't think that SQL server (or any other database server) is suited for multiplayer purposes. Usually game devs for multiplayer mode writes it's own server and client. So I would recommend to you to write TCP/UDP server and client by using System.NET library. Check this out-

Since you didn't write a language in which you want to program - for the beginner i would recommend either [URL="

[QUOTE=akki30;1285547]how this function is used. i m so confused n not getting the proper result[/QUOTE]
Fibonacci number is calculated in pretty straightfoward way:
No additional comments needed...

Indeed CUDA is only for nVidia cards. I suggest better using OpenCL. Also if these calculations is only for computing image transformations- you can try Pixel Shader.

Additional idea how to see similarity between Vigenère and XOR ciphers is this- compare encryption formulas-

Vigenère cipher => [ICODE]C = (P+K) mod 26[/ICODE]

XOR cipher => [ICODE]Cb = (Pb+Kb) mod 2[/ICODE]

Here C/P/K is ciphertext/plaintext/key letters respectivelly and Cb/Pb/Kb is ciphertext/plaintext/key bits respectivelly.

So the only differences are:

  1. Vigenère performs modulo 26 arithmetic and XOR performs modulo 2 arithmetic.
  2. Vigenère encryption is letter-by-letter and XOR encryption is bit-by-bit.

So as you can see from the formulas both ciphers make substitution in plaintext data. And hence both ciphers are called [URL="

A VERY interesting question ! Thanks for asking such thing :)

Both methods are polyalphabetic ciphers. There are some algorithms for polyalphabetic ciphers which computes key size from ciphertext. Once key size is known, ciphertext can be splitted into columns which are vulnerable to simple [URL="

Wiki is our friend:
Kadane's algorithm performs in O(n) for 1D array.

I pointed out that we started with a language that was much farther from natural languages, i.e. machine language, and have since developed languages that are more similar in structure to English.
Seems you are over-fitting your observations of programming language evolution of C-like languages. Take a look at array programming language named J, which descended from APL in 1990.
Quicksort algorithm written in J is:
quicksort=: (($:@(<#[) , (=#[) , $:@(>#[)) ({~ ?@#)) ^: (1<#)
Is it closer to natural language ? Or is it closer to machine language ? Or maybe is it closer to neither ?
Still you may ask some fans/matematicians which uses J for math related problems quick research, and I guarantee that you will get answer Where is the power of tacit programming J language. So in the end you may understand that programming languages (like natural languages) evolves in many directions. The only reason for language to be alive (like natural one) is active community of developers that still develops in that language. Thats all.

How long, if I have no experience, until I am making 3D FPS'?
My advice - don't start with FPS project. It's the problem which faces beginners of game programming. If you want to learn 3D game programming - at first choose very basic 3D project - such as 3D card game. For example take a look at my 3D card game which i've developed in about 3-4 months:
And these 3-4 months I've also spent for learning C++/DirectX. But given the fact that i have general development experience about 8-9 years, it is not hard for me to learn basics of any language. So im predicting, that for novice programmer such 3D card project may take even longer => 6-8 months. So FPS project is certainly not for beginners (except maybe if you wont develop 3D game engine, but use already existing. Still in that case i think FPS is not the way to go). So choose lighter 3D project and go on.

If you want you can use my card game as starting point. You can modify/use it's source as you wish.

Books that i've used in process of development -

  1. "C++ Primer, Fourth Edition
    By Stanley B. Lippman, Josée Lajoie, Barbara E. Moo"

  2. "Introduction to 3D Game Programming with DirectX® 9.0
    Frank D. Luna"

  3. "3D Math Primer for Graphics and Game Development
    By Fletcher Dunn and Ian Parberry"

1,2 was heavily used while 3 can be considered as optional, ...


include <stdlib.h>

// on windows clear screen with
// on unix/linux clear screen

I made some fixes, here corrected version:

include <stdlib.h>

void getOption();
void getData(int num1, int num2);
void calc(int option, int num1, int num2);
float add(int num1, int num2);
float sub(int num1, int num2);
float mul(int num1, int num2);
float divm(int num1, int num2);
void printResult(float result);

void clrscr() {
// define what is clrscr() - legal on Win

void getch() {
// getch is non-standard C and should be avoided.
// use ANSI-C compliant getchar function

int main()


void getOption()
// initialize num1,num2 to something
// otherwise you will get runtime error
int option,num1=0,num2=0;

printf("[1] Addition\n");
printf("[2] Subtraction\n");
printf("[3] Multiplication\n");
printf("[4] Division\n");
printf("\nChoose options: ");
scanf("%d", &option);


void getData(int num1, int num2)
printf("Enter two integers: ");
scanf("%d %d", num1, num2);

void calc(int option, int num1, int num2)
case 1: clrscr();

case 2: clrscr();

case 3: clrscr();

case 4: clrscr();

default: printf("Invalid key");

// put pause, before repeating user actions

float add(int num1, int num2)
int add;

return add;

float sub(int num1, int num2)
int sub;

return sub;

float mul(int num1, int num2)
int mul;

return mul;

float divm(int num1, int num2)
float div;

return div;

void printResult(float result)
printf("The result is: %.2f\n", result);


-If you want to become better [I]generalist developer[/I] - linux is a must because of plenty development languages/environments choises.
-If you want to become better [I]game developer[/I] - windows is a must because of tools avialable for GPU development. (Unless you want develop for some console/device, in such case Win may not have big bonus)

nope, this is just my little research on your problem.

You can start here-
Yes, you will need to track motion, but it's problem you concentrate too early.
At first you need to concentrate at object (hand) recognition phase.
You could start here-
Also somehow i think for such project perfomance is important thing cause you will operate on video frame data on real-time, so JAVA is not an option here.
Better take C/C++.

Good luck.

[QUOTE=pato wlmc;1260648]Well, right now i'm using linux, but i've heard that windows is really best for programing videogames ( on c++ ) well, wich O.S. do you think is the best?

P.D. Sorry for the bad english jeje :$[/QUOTE]
When it comes to game development definitely answer is Windows. Simply because nothing beats it at tools available for game & graphics development. For example,- take a look at existing programs for Pixel Shader development & testing under Linux/Mac/Windows:
From these nothing beats feature-rich and bug-free program "Render Monkey" which currently is only for Windows.
This is just one example, but in principle same should hold for many other development tools for graphics-driven applications.
If you want second example take a look at NVIDIA solution which lets developing programs for GPU (through OpenCL,CUDA,...) DIRECTLY in Visual Studio ->
So we can say that now Windows has IDE for GPU development. Do Linux has GOOD alternatives to this ?

at first i was very happy seeing all the links you provided but when i implemented it, it did not workout.
Can you be more concrete ? What results you got and what you expected instead ? Also have you tried different sharpness kernels - 3x3 and 5x5 ?

checked up nvidia site also downloaded opengl cg library also it is very slow i think it does not run on my pc and laptop very slow can get that to work at that pace.
It can be that your computer video card has no pixel shader support - and hence program runs under emulation mode, which is slow. Google it- does your video card supports pixel shaders and until what version pixel shaders are supported. (1.0-5.0).

(That Cg lib MUST run fast on modern GPU's, because it uses hardware accelerated processing. Unless your video card is OLD and/or integrated - like Intel).

Shall i send the code to you and blurred image to u r email id.
Just post here image after sharpness filter applied and tell us - what was not like you expected to be.