Click here to Skip to main content
15,121,818 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: how to access member functions and variables in another project without .lib Pin
Daniel Pfeffer3-Apr-16 21:16
professionalDaniel Pfeffer3-Apr-16 21:16 
GeneralRe: how to access member functions and variables in another project without .lib Pin
kamal19774-Apr-16 13:10
Memberkamal19774-Apr-16 13:10 
AnswerRe: how to access member functions and variables in another project without .lib Pin
Richard MacCutchan3-Apr-16 22:43
mveRichard MacCutchan3-Apr-16 22:43 
GeneralRe: how to access member functions and variables in another project without .lib Pin
kamal19774-Apr-16 13:07
Memberkamal19774-Apr-16 13:07 
GeneralRe: how to access member functions and variables in another project without .lib Pin
Richard MacCutchan4-Apr-16 22:45
mveRichard MacCutchan4-Apr-16 22:45 
GeneralRe: how to access member functions and variables in another project without .lib Pin
leon de boer5-Apr-16 3:40
Memberleon de boer5-Apr-16 3:40 
AnswerRe: how to access member functions and variables in another project without .lib Pin
leon de boer5-Apr-16 3:50
Memberleon de boer5-Apr-16 3:50 
QuestionC++ file stream read/write[SOLVED] Pin
Biruk Abebe3-Apr-16 7:22
MemberBiruk Abebe3-Apr-16 7:22 
I need to open a file for both reading/writing using fstream and read each character then write that character back to the file. for example i have this code.
C++
fstream in("test.txt",ios::in | ios::out);
if(!in)
    cout<<"error...";
else
{
    char ch;
    in.seekg(0,ios::end);
    int end=in.tellg();//get the length

    in.seekg(0);//get back to the start
    for(int i=0;i<end;i++)
    {
       //in.seekg(in.tellg());//if i uncomment this the code will work
       if(!in.get(ch).fail())//read a character
       {
           in.seekp(static_cast<int>(in.tellg())-1);//move the pointer back to the previously read position,so i could write on it
           if(in.put(ch).fail())//write back,this also move position to the next character to be read/write
               break;//break on error
       }
    }
}

I have a file named "test.txt" which contains "ABCD". As i understand it both put() and get() methods of the stream object move the file pointer forward(i see that by getting the return value of tellg() or tellp() functions after each get() or put() method call). My question is when i comment out the code that will seek the stream pointer to "where it is now"(in.seekg(in.tellg()), the code will result incorrect results. I don't understand why this is since tellg() is showing the correct position of the character to be read next what is the purpose of explicitly seeking to it? The incorrect result is it write to the file "ABBB" instead of "ABCD". I am using visual studio 2005.

modified 3-Apr-16 16:26pm.

AnswerRe: C++ file stream read/write Pin
leon de boer3-Apr-16 8:12
Memberleon de boer3-Apr-16 8:12 
GeneralRe: C++ file stream read/write Pin
Biruk Abebe3-Apr-16 8:40
MemberBiruk Abebe3-Apr-16 8:40 
GeneralRe: C++ file stream read/write Pin
leon de boer3-Apr-16 10:22
Memberleon de boer3-Apr-16 10:22 
GeneralRe: C++ file stream read/write[SOLVED] Pin
Biruk Abebe3-Apr-16 11:26
MemberBiruk Abebe3-Apr-16 11:26 
QuestionC, Win32 API: l need help with ReadFile function[Solved] Pin
Member 121394421-Apr-16 1:46
MemberMember 121394421-Apr-16 1:46 
AnswerRe: C, Win32 API: l need help with ReadFile function Pin
Jochen Arndt1-Apr-16 2:30
professionalJochen Arndt1-Apr-16 2:30 
GeneralRe: C, Win32 API: l need help with ReadFile function Pin
Member 121394422-Apr-16 6:30
MemberMember 121394422-Apr-16 6:30 
GeneralRe: C, Win32 API: l need help with ReadFile function Pin
Richard MacCutchan2-Apr-16 7:10
mveRichard MacCutchan2-Apr-16 7:10 
GeneralRe: C, Win32 API: l need help with ReadFile function Pin
Jochen Arndt2-Apr-16 22:02
professionalJochen Arndt2-Apr-16 22:02 
AnswerRe: C, Win32 API: l need help with ReadFile function Pin
David Crow1-Apr-16 3:25
MemberDavid Crow1-Apr-16 3:25 
QuestionOpenCL program uses only 1 core from 192 cuda cores Pin
Javier Luis Lopez31-Mar-16 5:04
MemberJavier Luis Lopez31-Mar-16 5:04 
QuestionRe: OpenCL program uses only 1 core from 192 cuda cores Pin
David Crow31-Mar-16 7:09
MemberDavid Crow31-Mar-16 7:09 
AnswerRe: OpenCL program uses only 1 core from 192 cuda cores Pin
Javier Luis Lopez20-Apr-16 2:14
MemberJavier Luis Lopez20-Apr-16 2:14 
QuestionHow to overwrite one angle arc over other during runtime Pin
Member 1053643030-Mar-16 2:45
MemberMember 1053643030-Mar-16 2:45 
SuggestionRe: How to overwrite one angle arc over other during runtime Pin
Kornfeld Eliyahu Peter30-Mar-16 3:06
professionalKornfeld Eliyahu Peter30-Mar-16 3:06 
QuestionC, Win32 API: l need a help Pin
Member 1213944229-Mar-16 22:19
MemberMember 1213944229-Mar-16 22:19 
SuggestionRe: C, Win32 API: l need a help Pin
David Crow30-Mar-16 11:09
MemberDavid Crow30-Mar-16 11:09 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.