CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 15 of 37

Threaded View

  1. #12
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,637

    Re: Can't intialize C++ Struct with CString in it??

    Quote Originally Posted by ADSOFT View Post
    GCDEF,

    No it doesn't work. did you try to compile it, or is this something you made up?

    What does your compilier tell you?
    My compiler told me your first two worked, but the second two it couldn't convert a CString* to a CString. When I removed the &, it compiled cleanly. You may want to dump the attitude. Sheesh. This compiled cleanly.

    Code:
    #include "stdafx.h"
    
    #ifdef _DEBUG
    #define new DEBUG_NEW
    #endif
    
    struct print
        {
        int  x; //row
        int  y; //col
        int  fid;
        CString data;
        char *format;
        };
    
    
    // The one and only application object
    
    CWinApp theApp;
    
    using namespace std;
    
    int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
    {
    	int nRetCode = 0;
    
     CString temp("Address");
    
     print form [] =
    {
    { 30, 40, 1,CString("Name"), "N/A" },
    { 30, 42, 1, temp , "N/A" },
    { 30, 44, 1, temp, "N/A" },
    { 30, 50, 1, temp, "N/A" },
    
    };
    
    	// initialize MFC and print and error on failure
    	if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
    	{
    		// TODO: change error code to suit your needs
    		_tprintf(_T("Fatal Error: MFC initialization failed\n"));
    		nRetCode = 1;
    	}
    	else
    	{
    		// TODO: code your application's behavior here.
    	}
    
    	return nRetCode;
    }
    Last edited by GCDEF; April 9th, 2013 at 05:38 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured