Hi Guys..
I have a problem in tellg() function..
When I open file in Binary mode , It returns true value,but when I open in default mode it returns false value.I can't understand what has happened ...(the problem is in this code) :

for(int t=1;t<size;t++){

        char ch=input.get();
        codes_list[t].symbol=list[t].symbol=ch;
        input>>list[t].q;
        list[t].right=list[t].left=0;
        input.get();

    }

    position=input.tellg();

it is so interesting that when I add cout<<input.tellg() in the scope it returns very bad value and many -1 !
(aboat code : it read data from file that the order is : (char)(int)(space) ...and code_list and list are structures .

and my another problem is when I put open file in binary mode.. it reads some unknown characters for example it reads 26 and 13 that causes bad works of my code.

You've pretty much learned all there is to it: the STL streams library does not handle non-binary streams very well.

If you plan to seek[[b]g[/b]|[b]p[/b]]() / tell[[b]g[/b]|[b]p[/b]]() at all, use binary I/O.

Sorry.

You've pretty much learned all there is to it: the STL streams library does not handle non-binary streams very well.

If you plan to seek[[b]g[/b]|[b]p[/b]]() / tell[[b]g[/b]|[b]p[/b]]() at all, use binary I/O.

Sorry.

But I said that when I read characters in Binary I/O , it reads some characters like 13 and 26 ,and cause many other problems.
and when I build input file in Binary mode, for some files it works and for some doesn't.
(I write characters in input (when i wanna make it) by << ,does it make problems?)

May you help me how to get rid of this problem (how to solve one of them!)
tnx for your rapid answer.:)

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.