954,492 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

MS VS 2008 Professional CString problem??

Hey all,

I have just updated to MS VS 2008 Pro. I am having some cross over problems from MS VC 6. Below is a simple example:

#include<afx.h>
#include<iostream>

using namespace std;

int main()
{
	CString s;
	CString sa("Strings ");
	CString sb = CString("are easy ");
	CString sc = "in MFC!";
	s = sa + sb + sc + '!';
	cout << s;
	return 0;
}


In MSVC 6 thisworks fine but in MSVS 2008 Pro the output is different on every run, typical output "0019ED10" . I do not understand what is happening here. Anyone any ideas? Thanks for the help.

Colm

colmcy1
Light Poster
39 posts since Feb 2009
Reputation Points: 10
Solved Threads: 0
 

Where is CString declared? Is it a visual studio thing? Because CString is definitely not a standard c++ thing.

daviddoria
Posting Virtuoso
1,996 posts since Feb 2008
Reputation Points: 437
Solved Threads: 204
 

Hey David,

thanks for the reply. I should have pointed out that I am using MFC programming and CString is defined in the header

Colm

colmcy1
Light Poster
39 posts since Feb 2009
Reputation Points: 10
Solved Threads: 0
 

>>I do not understand what is happening here

Microsoft completely rewrote CString to convert it from a c++ class in VC++ 6.0 compiler to a template in VC++ 2005 and later compilers. There were lots of changes to MFC, and CString was just one of them. Consequently you may have to rewrite parts of your programs to conform to the new version of MFC.

Ancient Dragon
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 

Thanks Ancient Dragon,
at least its not me going mad, which i was being to think was a posibility :). I guess I go find a book that explains MFC for MSVS 2008 as I am afraid to think of any other changes microsoft may have carried out. Thanks for the heads up again.

Colm

colmcy1
Light Poster
39 posts since Feb 2009
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You