I am new to c programming. As a part of my uni course for network security, I have to design a SSL handshake simulation. I found a sample code online, however i don't understand some parts of the code. Could you please help me with following :
What does (char) 0
do ?? ( send_data is defined as char send_data[1024];
)
send_data[0] = (char) 0; //Packet Type = hello
send_data[1] = (char) 3; //Version
EDIT + FOLLOWUP
Folks I know what type casting is.
I understand what casting is But the code I posted is doing nothing. Even though integer 0 is being cast as a character, its not doing anything because when you print it - its a blank - no value.
eg :
#include <stdio.h>
#include <stdlib.h>
int main(){
char test;
int num;
num = 1;
test = (char) num; // this does nothing
printf("num = %d , %c\n",num,num);
printf("test = %d , %c\n",test,test);
// Isn't this the correct way to do it ?? :
num = 3;
test = '3'; // now this is a character 3
printf("num = %d , %c\n",num,num);
printf("test = %d , %c\n",test,test);
return 0;
}
the output of above code is :
num = 1 ,
test = 1 ,
num = 3 ,
test = 51 , 3
So why is it being done ?? isn't this the right way to do it :- send_data[0] = '0'; send_data[1] = '3';