Click here to Skip to main content
15,886,919 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionC++ fstream's write operation is Sync or aSync? Pin
iceman861620-Jan-10 16:46
iceman861620-Jan-10 16:46 
AnswerRe: C++ fstream's write operation is Sync or aSync? Pin
Chris Losinger20-Jan-10 17:00
professionalChris Losinger20-Jan-10 17:00 
GeneralRe: C++ fstream's write operation is Sync or aSync? Pin
iceman861621-Jan-10 13:20
iceman861621-Jan-10 13:20 
QuestionReading files... Pin
Jacob Dixon20-Jan-10 16:25
Jacob Dixon20-Jan-10 16:25 
AnswerRe: Reading files... Pin
Jacob Dixon20-Jan-10 16:37
Jacob Dixon20-Jan-10 16:37 
AnswerRe: Reading files... Pin
Avi Berger20-Jan-10 16:48
Avi Berger20-Jan-10 16:48 
GeneralRe: Reading files... Pin
Jacob Dixon20-Jan-10 16:54
Jacob Dixon20-Jan-10 16:54 
GeneralRe: Reading files... Pin
Jacob Dixon20-Jan-10 17:00
Jacob Dixon20-Jan-10 17:00 
I have also tried this: (from: http://www.cplusplus.com/doc/tutorial/files/[^])
#include <iostream>
#include <fstream>
#include <string>

int main () {
	using namespace std;
	
	string line;
	ifstream myfile("/Users/Dixon/test1.txt");
	if (myfile.is_open())
	{
		while (! myfile.eof())
		{
			getline(myfile,line);
			cout << line << endl;
		}
		myfile.close();
	}
	else {
		cout << "Unable to open file";
	}
	
	return 0;

}


But I seem to get:
[Switching to process 17059]
Running…
Exploration 13(17059) malloc: *** error for object 0x10000a700: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
Program received signal: “SIGABRT”.
sharedlibrary apply-load-rules all
(gdb)


If I change this:
while (! myfile.eof())

to:
while (myfile.eof() != false)

it runs but still does not read anything
GeneralRe: Reading files... Pin
Jacob Dixon20-Jan-10 17:02
Jacob Dixon20-Jan-10 17:02 
GeneralRe: Reading files... Pin
Avi Berger20-Jan-10 17:16
Avi Berger20-Jan-10 17:16 
GeneralRe: Reading files... Pin
Jacob Dixon20-Jan-10 17:17
Jacob Dixon20-Jan-10 17:17 
GeneralOT [modified] Pin
Avi Berger20-Jan-10 18:15
Avi Berger20-Jan-10 18:15 
QuestionRe: Reading files... Pin
David Crow20-Jan-10 17:03
David Crow20-Jan-10 17:03 
AnswerRe: Reading files... Pin
Jacob Dixon20-Jan-10 17:11
Jacob Dixon20-Jan-10 17:11 
QuestionSpin control: how does it works, specially when it changes acceleration ? Pin
timbk20-Jan-10 13:40
timbk20-Jan-10 13:40 
Questionconcat two char * variables Pin
santhosh-padamatinti20-Jan-10 6:13
santhosh-padamatinti20-Jan-10 6:13 
AnswerRe: concat two char * variables Pin
Rajesh R Subramanian20-Jan-10 6:26
professionalRajesh R Subramanian20-Jan-10 6:26 
GeneralRe: concat two char * variables Pin
santhosh-padamatinti20-Jan-10 6:33
santhosh-padamatinti20-Jan-10 6:33 
GeneralRe: concat two char * variables Pin
Fatbuddha 120-Jan-10 6:46
Fatbuddha 120-Jan-10 6:46 
QuestionRe: concat two char * variables Pin
CPallini20-Jan-10 10:47
mveCPallini20-Jan-10 10:47 
AnswerRe: concat two char * variables Pin
Luc Pattyn20-Jan-10 11:18
sitebuilderLuc Pattyn20-Jan-10 11:18 
GeneralRe: concat two char * variables Pin
CPallini20-Jan-10 11:23
mveCPallini20-Jan-10 11:23 
AnswerRe: concat two char * variables [modified] Pin
santhosh-padamatinti20-Jan-10 20:13
santhosh-padamatinti20-Jan-10 20:13 
GeneralRe: concat two char * variables Pin
CPallini20-Jan-10 21:20
mveCPallini20-Jan-10 21:20 
GeneralRe: concat two char * variables Pin
Saravanan Sundaresan21-Jan-10 18:52
professionalSaravanan Sundaresan21-Jan-10 18:52 

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.