Hello, I have been stuck on this for awhile, and can not seem to get it to work exactly correct.
I am trying to read in a file ("in_text.txt") and print out it's contents to the screen for now (eventually i will manipulate the data with a block_cipher class). Here is what I have so far...

in_text.txt

your cat

#include <iostream>
#include "block_cypher.h"
#include <fstream>
#include <string>

using namespace std;

int main()
{
  ifstream ins;
  long begin,end,length;
  char letter;
  
  {
    ins.open("in_text.txt", ios::in);
    if (ins.fail())
      {
	cerr << "Failed to open in_text.txt.\n";
	exit(1);
      }
  }
  
  begin = ins.tellg();
  ins.seekg(0, ios::end);
  end = ins.tellg();
  length = ((end - begin)-1);
  
  ins >> letter;
  while (!ins.eof())
    {
      cout << letter;
      ins >> letter;
    }    
  cout << endl;
  cout << "Length = " << length << endl;
  
  
  return (0);
}

Thanks

Please delete this post, I figured out what was happening. Sorry. and Thanks.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.