LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-31-2011, 03:16 PM   #1
Zssfssz
Member
 
Registered: Sep 2011
Location: Las Vegas!
Distribution: Ubuntu n' Flavors, ReactOS, MINIX3, FreeDOS, Arch
Posts: 339

Rep: Reputation: Disabled
Using Logical operators in Fstream binary mode.


I want to take the info from a file thats a non-text file NOT it then save it in a different file. I just cant seem to get this to work could anyone help me? The other logical operators dont work ether...
 
Old 10-31-2011, 04:11 PM   #2
Juako
Member
 
Registered: Mar 2010
Posts: 202

Rep: Reputation: 84
Maybe the "bbe" command, kind of a "binary sed" might be useful:

Code:
bbe -e '~' inputfile -o outputfile
 
Old 10-31-2011, 06:18 PM   #3
Zssfssz
Member
 
Registered: Sep 2011
Location: Las Vegas!
Distribution: Ubuntu n' Flavors, ReactOS, MINIX3, FreeDOS, Arch
Posts: 339

Original Poster
Rep: Reputation: Disabled
Man how did I forget this: I'm using C++, you seem to be using something else (or Its wayabove my head, if it is C++ please explain)
 
Old 10-31-2011, 06:28 PM   #4
Juako
Member
 
Registered: Mar 2010
Posts: 202

Rep: Reputation: 84
No, I should apologize: didn't have into account the subject at all. Sorry about that. :-)
 
Old 10-31-2011, 08:03 PM   #5
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,780

Rep: Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081
Quote:
Originally Posted by Zssfssz View Post
I want to take the info from a file thats a non-text file NOT it then save it in a different file. I just cant seem to get this to work could anyone help me? The other logical operators dont work ether...
What do you mean by "dont work"? What have you tried? Post some source code...
 
Old 10-31-2011, 08:31 PM   #6
Zssfssz
Member
 
Registered: Sep 2011
Location: Las Vegas!
Distribution: Ubuntu n' Flavors, ReactOS, MINIX3, FreeDOS, Arch
Posts: 339

Original Poster
Rep: Reputation: Disabled
Um... Tried XOR NOT AND I want not.
I don't know the tags so Amin help me:
ifstream asdf ("DATA.dat",ios_base::in|ios_base::binary);
ofstream qwer ("INFO.day",ios_baseut|ios_base::binary);
That's all for the binary fstream and works fine.
I can't show you what I tried because that was painfull on this iPod.
Could someone just give me a pice of code for logical gates for Binary Fstream?
The error message is:
No match for "operator(insert symbol here)" in "(insert line here)"
My closest try is :
asdf^=zxcb //zxcb being an int vareable
 
Old 11-01-2011, 09:14 AM   #7
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,780

Rep: Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081
Quote:
Originally Posted by Zssfssz View Post
ifstream asdf ("DATA.dat",ios_base::in|ios_base::binary);
...
My closest try is :
asdf^=zxcb //zxcb being an int vareable
You can't apply the bitwise operators to the streams directly. You have read to some data from the input stream, apply whatever operations you want on it, and then write the result to the output stream. The operator for bitwise NOT is "~":

Code:
int x;
in >> x;
x = ~x;
out << x;
 
Old 11-01-2011, 10:42 AM   #8
Zssfssz
Member
 
Registered: Sep 2011
Location: Las Vegas!
Distribution: Ubuntu n' Flavors, ReactOS, MINIX3, FreeDOS, Arch
Posts: 339

Original Poster
Rep: Reputation: Disabled
Well what the best variable for storing binary data? BINARY I'm working with a simple backup program and it needs to read the data as binary data.
 
Old 11-01-2011, 11:50 AM   #9
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,780

Rep: Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081
Quote:
Originally Posted by Zssfssz View Post
Well what the best variable for storing binary data? BINARY I'm working with a simple backup program and it needs to read the data as binary data.
unsigned char (possibly a vector of them) I guess. I don't understand why you would want to backup the bitwise NOT of a file...
 
Old 11-01-2011, 07:18 PM   #10
Zssfssz
Member
 
Registered: Sep 2011
Location: Las Vegas!
Distribution: Ubuntu n' Flavors, ReactOS, MINIX3, FreeDOS, Arch
Posts: 339

Original Poster
Rep: Reputation: Disabled
I want to NOT it so that it's at least feebly encrypted and so Linux doesnt recognize it.
 
  


Reply

Tags
c++



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] FTP always in binary mode Jerry Mcguire Linux - Newbie 3 12-27-2010 11:16 PM
logical operators in grep ahmedb72 Linux - Newbie 3 12-14-2009 07:55 PM
fstream.h is creating erratic binary programs sriram_16a SUSE / openSUSE 0 10-02-2007 12:48 AM
PHP5: Logical Operators vs. If-Else unreal128 Programming 2 11-15-2006 10:52 PM
? on logical operators in BASH eroica Linux - Software 10 02-01-2005 01:12 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:12 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration