Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

console giving Output in other text format

Tags:

c++

I am doing my work but suddenly while reading data from file, i suddenly faced text in other form i also carried a small test to check whether is it my code fault or Visual Studio 2012 gone mad. I also debug but values in "line[]" coming correct. But i found small test is still giving me same thing: here is my small code test:

file: input.txt
{
value := (rate * dollar) + (rate1 * dollar1);
totalvalue := value / 2;
t1 = ivariable > 10 && ivariable < 100
    {
        value := (rate * dollar) + (rate1 * dollar1);
        totalvalue := value / 2;
    }
}

code:

#include <sstream>
#include <fstream>
using namespace std;

void main(){
    const int si = 1500;
        string line[si];
        ifstream infile;
        infile.open("input.txt");

        cout<<"Reading"<<endl;
    //  infile>>data;
    //  cout<<data<<endl;
        int a=0;
        int size=0;
    //  string line[1500];
    //  for (int i=0;i<10;i++){
        while(!infile.eof()){

            getline(infile,line[a],'\n');
            cout<<line[a]<<endl;
            a++;
        }
}

and the output: enter image description here

Any idea please share......

like image 715
dell pk Avatar asked Feb 22 '15 16:02

dell pk


2 Answers

Looks like you have copied down some text from pdf either from Adobe or Nitro and pasted in notepad as a .txt. Never do such thing always try to either by write your self or use Notepad editor. I also faced such thing while doing compiler. My teacher gave me inputs in pdf file and i copied. Sorry for late reply i was reading Light comments and me a laugh that he such you.... Good Luck!

like image 81
user3508182 Avatar answered Nov 13 '22 21:11

user3508182


Your input.txt is encoded in Unicode, but your console is not set to render Unicode.

Save your file as plain ASCII.

like image 22
Lightness Races in Orbit Avatar answered Nov 13 '22 22:11

Lightness Races in Orbit