Bob:
I've been trying to get the code you kindly sent work, but windoze is giving
me an error to the effect, "This application has requested the Runtime to
terminate it in an unusual way."
I'm not sure if its spitting this out because I'm in ms vstudio 2005 and I
need to put in the iostream using endl
statement which I'll try or if its something else. I'd toss namespace in
there but that begins to get a bit more complicated in just a console app.
I also wanted to be as concise and terse in my first posting to the group as
I could, but I probably went overboard. Here's a better understanding of how
I need to get this engineered in psuedocode.
User starts program.
Program asks user for file name (some are intl this is why I have to have
the capability of opening a .bin .txt .jen .plt)
Program uses open function with (filename, DENYNO | ios::binary, etc....
Program temporarily stores contents in a one line, no spaces
array(doubtful), buffer or vector in 1's and 0's binary format (for
mathematical reasons).
From this point I can then put the math to the file in a function and then
display the binary on the console and store the math on a floppy.
I truly appreciate the help you have provided and if you know of a way to do
the above I might stop ripping out my hair.
Thanks so much,
pa*******@comcast.net
Paul
----- Original Message -----
From: "BobR" <Re***********@worldnet.att.net>
Newsgroups: comp.lang.c++
Sent: Saturday, November 25, 2006 12:31 PM
Subject: Re: File-Binary-Mathematics
>
nguser3552 wrote in message ...
>>Hello everyone,
I'm wondering if someone out there knows how in a visual c++ console
application how I can do the following, and man I've tried, it seems
simple
really:
I need to open up any file (the fnctl library offers hope), in binary or
raw
mode just 1' and 0's whichever is preferable. Once the file is open,
attached to a stream and a buffer is created, I have to be able to take
the
final object as though it were in the following form:
object->100010101010101010....0001010
and be able to perform mathematical operations on the data. There is a
great
program if you go to Google and just type in fb.c it should show up, it
does
a lot of what I'm talking about, however it far to in depth for what my
team
is asking of me and it is in c and uses the (argv, char**) method which
complicated things. Anyone have any idea on how to do this without
creating
a Leon Tolstoy program?
Any help at this point is more than appreciated, in the afterlife I'll
walk
your dog if you've any suggestions.
Thank you
Paul
#include <iostream>
#include <fstream>
#include <vector>
#include <bitset>
std::vector<std::stringTheFile;
void Open( char const *filename){
std::ifstream in( filename );
if(!in){ throw " Open Failed! ";} //if(!in)
for( std::string line; std::getline(in, line); ){
TheFile.push_back( line );
} // for(line)
return;
} //Open(const char*)
{ // main() or function
Open( "myfile.txt" );
std::string Bits32( TheFile.at( 0 ).substr(0, 32) );
// std::string Bits32( "00010011100010100010" ); // test
std::bitset<32Bits( Bits32 );
std::cout << Bits << std::endl;
Bits>>=5;
std::cout<<"Bits>>=5;\n"<< Bits << std::endl;
Bits&=24;
std::cout<<"b&=24;\n"<< Bits <<std::endl;
}
std::ifstream Tfile("SomeName.txt", std::ios::binary);
....is not what you seem to think.
--
Bob R
POVrookie
"BobR" <Re***********@worldnet.att.netwrote in message
news:qS*********************@bgtnsc04-news.ops.worldnet.att.net...
>
nguser3552 wrote in message ...
>>Hello everyone,
I'm wondering if someone out there knows how in a visual c++ console
application how I can do the following, and man I've tried, it seems
simple
really:
I need to open up any file (the fnctl library offers hope), in binary or
raw
mode just 1' and 0's whichever is preferable. Once the file is open,
attached to a stream and a buffer is created, I have to be able to take
the
final object as though it were in the following form:
object->100010101010101010....0001010
and be able to perform mathematical operations on the data. There is a
great
program if you go to Google and just type in fb.c it should show up, it
does
a lot of what I'm talking about, however it far to in depth for what my
team
is asking of me and it is in c and uses the (argv, char**) method which
complicated things. Anyone have any idea on how to do this without
creating
a Leon Tolstoy program?
Any help at this point is more than appreciated, in the afterlife I'll
walk
your dog if you've any suggestions.
Thank you
Paul
#include <iostream>
#include <fstream>
#include <vector>
#include <bitset>
std::vector<std::stringTheFile;
void Open( char const *filename){
std::ifstream in( filename );
if(!in){ throw " Open Failed! ";} //if(!in)
for( std::string line; std::getline(in, line); ){
TheFile.push_back( line );
} // for(line)
return;
} //Open(const char*)
{ // main() or function
Open( "myfile.txt" );
std::string Bits32( TheFile.at( 0 ).substr(0, 32) );
// std::string Bits32( "00010011100010100010" ); // test
std::bitset<32Bits( Bits32 );
std::cout << Bits << std::endl;
Bits>>=5;
std::cout<<"Bits>>=5;\n"<< Bits << std::endl;
Bits&=24;
std::cout<<"b&=24;\n"<< Bits <<std::endl;
}
std::ifstream Tfile("SomeName.txt", std::ios::binary);
....is not what you seem to think.
--
Bob R
POVrookie