"Untitled Post" - Views: 511 · Hits: 511 - Type: Unlisted

#include<iostream>
#include<iomanip>
using namespace std;

int main()
{
    double s;
    cout<<sizeof(double)<<endl;           //output was 8
    
    cin>>hex>>s;                    //i input 0102030405060708
    cout<<hex<<fixed<<s<<endl;
    cout<<resetiosflags(ios::hex);
    
    char *c1=(char*)(&s);
    char *c2=(char*)(&s);
    char *c3=(char*)(&s);
    char *c4=(char*)(&s);
    char *c5=(char*)(&s);
    char *c6=(char*)(&s);
    char *c7=(char*)(&s);
    char *c8=(char*)(&s);
    
    c2++;
    c3+=2;
    c4+=3;
    c5+=4;
    c6+=5;
    c7+=6;
    c8+=7;
    
    cout<<(int)*c1<<"  and "<<(int)*c2 <<" and "<<(int)*c3 <<"  and "<<(int)*c4 <<"  and "<<(int)*c5 <<"  and "<<(int)*c6 <<"  and "<<(int)*c7 <<"  and "<< (int)*c8 <<endl;
   
    return 0;
}