Monday, September 8, 2008

Reading bit pattern of a datatype

here nothing to discuss much for the introduction....i will give the c++ code for reading the bit string of an integer..the program is in a very straight forward manner.....

#include iostream
#include conio.h
#include stdio.h
#include vector
//as this blogger tool doesnt allow some syntices ,so i consider here you will be doing it urself,we have to include vector header file besides some general i/o libraries...

using namespace std;int main()
{vector v;
int x =2000;
int collect;

int counter = 8*(sizeof(int));
for( int j=0;j{collect = x&1;
v.push_back(collect);
x >>= 1;
} for(int i=counter-1;i>=0;i--)
{ cout v[i];//i am not using the complete syntx due to restriction made

//by the blog editor
}
getch();
return 1; }


here i am reading the bit pattern of an int,,,applying little modifications..we can read for other data types too....hope this helped....