1)What's the safest way to receive data from a php script and return to an exe?

2)If I have lets say

char Hi[4] = "3E2C";

and I wanted to put this into a BYTE Bye[2]; how would I do this so that Bye[0] = 0x3E and Bye[1] = 0x2C?

Thanks guys!

Your Hi variable

char Hi[4] = {'3','E','2','C'};

is four bytes with the values of(in ascii)
0x33 = '3'
0x45 = 'E'
0x32 = '2'
0x43 = 'C'

and this (in ascii)

Bye[0] = 0x3E and Bye[1] = 0x2C

would equate to

Bye[0] = '>' and Bye[1] = ','

I think your mixing up characters and their acsii values.

no those are the hex values that should be placed in the byte accordingly.


char Hi[4] = "3E2C";
needs to be converted into:
Bye[0] = 0x3E;
Bye[1] = 0x2C;

no those are the hex values that should be placed in the byte accordingly.


char Hi[4] = "3E2C";
needs to be converted into:
Bye[0] = 0x3E;
Bye[1] = 0x2C;

Firstly, you got to read the Hi array 2 characters at a time. For the first character, bit shift it to the left 4 positions using the operator (<<). Using the results, apply the bitwise OR operation (|) with the second character. You should get the result in a single byte.
For bitwise operations, you can refer to this link http://www.fredosaurus.com/notes-cpp/expressions/bitops.html

Jesus, I don't understand :(

Also whats the safest c++(exe) to php and php to c++(exe) communication

Sorry for bumping after 9 hrs but I'm going back to school in 2 days and I will not be able to code so I want to finish this :(

I don't known much about PHP, but can you use a pipe or set up a socket connection?

Maybe this will help.

#include <iostream>
using namespace std;

int main(){
 char sample[] = "3E";
 int result[1] = {};

 cout << "Encoding : " << sample << endl;

 result[0] = (sample[0] << 8) | (sample[1]) ; //encode

 cout << "Encoded value : " << hex << result[0] << endl;
 cout << char( (result[0] & 0xff00) >> 8) << endl; //decode top 8 bits
 cout << char(result[0] & 0x00ff) << endl; //decode bottom 8 bits
 return 0;
}

This was awesome! But, it needs to be placed inside a byte
BYTE[0] = 0x3E;

And what's the problem?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.