Passing CString as paramter

Discussion in 'MFC' started by answerme, Aug 31, 2009.

  1. answerme

    answerme New Member

    Joined:
    Dec 17, 2007
    Messages:
    114
    Likes Received:
    0
    Trophy Points:
    0
    How to pass CString as a paramterey . I am passing CString as paramter in a particular function & on its defintion it should be convert into char array or char pointer.

    Code:
    void CexapmleDlg::OnBnClickedButton3() //INPUT BUTTON
    {
    	UpdateData(TRUE);
    	Instring=(CString)InSpread;
    	User_command(Instring);
    }
    void	User_command(char* command)
    	{
    		char	mess[MAX_MESSLEN];
    		char	group[80];
    		char	groups[10][MAX_GROUP_NAME];
    		int		num_groups;
    		unsigned int mess_len;
    		int	ret;
    		int	i;
    
    		for( i=0; i < sizeof(command); i++ )
    			command[i] = 0;
    		/* if( fgets( command, 130, stdin ) == NULL ) 
    			Bye();*/
    
    		switch( command[0] )
    		{
    		case 'j':
    			ret = sscanf( &command[2], "%s", group );
    			if( ret < 1 ) 
    			{
    				a = CString(" invalid group \n");
    				break;
    			}
    			ret = SP_join( Mbox, group );
    			if( ret < 0 ) SP_error( ret );
    
    			break;
    }
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    So whats the problem?
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice