Is this a binary false or bitwise operation or Did i make false?
Mar 5, 2011 at 11:06pm UTC
Input.cpp:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
#include <iostream>
#include <fstream>
#include <bitset>
#include <conio.h>
using namespace std;
int main(){
string c;
ofstream file;
file.open("Binary.txt" );
cout<<"Entry ur text : " ;
cin>>c;
cout<<"Ur text saved binary format in Binary.txt" ;
for (int i=0;i<c.length();i++){
bitset<8>binary(c[i]);
file<<binary;}
file.close();
return 0;}
Output.cpp:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
#include <iostream>
#include <bitset>
#include <fstream>
#include <stdlib.h>
using namespace std;
int main(){
string a,c;
char * b;
fstream file;
file.open("Binary.txt" ,ios::in|ios::binary);
file>>c;
for (int i=0,j=c.length()/8;i<c.length()/8,j>0;i++,j--){
a[i]=c[i];
bitset<8>file(a[i]);
file>>binary;
b=new char [j];
if (c.length()/8!=8)
delete [] b;
cout<<"\t\t Binary format:" <<binary<<endl;
cout<<"Char format: " <<a[i]<<"\t\t" ;}
system("PAUSE" );
return 0;}
My input text binary values not equal output values.Where is my error?What must make me for to solve this problem?Can u give me alternate ways?
My OS is Win xp.
Last edited on Mar 5, 2011 at 11:57pm UTC
Topic archived. No new replies allowed.