Vector<string> issues in release, not debug

Its hard to put a title on this issue, but I hope thats ok!

I have the following code (Please forgive the messagebox's, I'm just tracing the failure):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
vector<string> text_file;

	MessageBox(NULL,"Open Text File and Read",NULL,MB_OK);
	ifstream ifs( "..\\output.txt" );
	
	string temp;

	while( getline( ifs, temp ) )
		text_file.push_back( temp );

        MessageBox(NULL, "Push_backs done", NULL, MB_OK);
	
	strToName = text_file[1].c_str();
	MessageBox(NULL,"Variables defined - strToName",NULL,MB_OK);
	strToEmail = text_file[1].c_str();
	MessageBox(NULL,"Variables defined - strToEmail",NULL,MB_OK);
	pszSubject = (LPSTR)text_file[4].c_str();
	MessageBox(NULL,"Variables defined - pszSubject",NULL,MB_OK);
	pszSender = (LPSTR)text_file[0].c_str();
	MessageBox(NULL,"Variables defined - pszSender",NULL,MB_OK);


The code works fine in debug, just crashes in release on while( getline( ifs, temp ) )
text_file.push_back( temp );
Is this a configuration issue between debug and release?

Thanks very much in advance!

Darren

** Edit - I pegged the wrong line as the error, changed it now **
Last edited on
Is this a configuration issue between debug and release?
Nope. It just won't crash if nothing went wrong before.

Line 13, 15, 17, 19 will crash if 'output.txt' cannot be opened or you don't read a line.
Last edited on
It does not get to lines 13, 15, 17 and 19. It crashes on the vector call.
This is resolved, aparently I can't use ./ for the parent directory, I have to specify the full path, bit annoying but no worries!
so what was the reason for the crash?
It was trying to put data into the vector for a file stream that contained no data, because the path to the file was incorrect. I really wanted to use parent directory so used ".\\Filename". Had to use "C:\\Working\\FileName".
Topic archived. No new replies allowed.