You are here:

C++/tricky... please help me out

Advertisement


Question
and in the file "tester" there are no spaces, no new lines, just straight characters.

Then when this program is run, there are new lines, and there are other characters involved, i'm sure that this is due to the use of eof, please any other alternatives?





#include <fstream.h>     
#include <iostream.h>
#include <math.h>
#include <stdio.h>

using namespace std;

int main(){
string str;

  string FilePath="tester";
  ifstream block(FilePath.c_str());
  if(!block){
     str="";
  }
  while (!block.eof()){
     str += block.get();
  }

cout << str << str;

return 0;
}



those other characters must go!

Answer
Dear James,
I'm sorry, actually, i was on leave, and my vacation
ended, but my mind was in it, that it is after somedays.
So i couldnt see your question earlier. I apologize for
such a delay.

I am getting your question, may be it is something related
to garbage values, you are talking about, please let me
further details. I am unable to under this question of
what exactly, you wana ask me.

Please take care.
Chris

C++

All Answers


Answers by Expert:


Ask Experts

Volunteer


Professional

Expertise

I can answer any question about functions,pointers,structures,object oriented programming basics of classes and data structures.My strong field is structured programming.

Experience

I have got 2 years experiece under C . I am able to answer about the structured concepts pointers to a little extent,OOP concepts. I have also experience in data Strucutres like Linked List, Stacks , Queues, Heaps, B Trees, Red Black Trees. I will try to satisfy with my knowledge. I am the Student of an expert here Martin, what i have learnt today, i just owe my every knowledge to him. He is the greatest.

©2016 About.com. All rights reserved.