Start New Discussion within our Software Development Community

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.

This question has already been answered. Start a new discussion instead.