how to get the size of a byte buffer

Discussion in 'MFC' started by manisha khare, Feb 5, 2008.

  1. manisha khare

    manisha khare New Member

    Joined:
    Feb 5, 2008
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Code:
    DPError		dpResult		=  DPMS_SUCCESS;
        FILE		*hFile			= NULL;
    	BOOL		bRetValue		= FALSE;
    	CDPString   dpFilePath;
    	size_t      size            = 0;
    	char       *tBuffer		= new char[m_sFileSize];
    	tBuffer = m_pszStream;
    
    
    	dpFilePath   = m_dpFilePath;
    	dpFilePath   += "\\";
    	dpFilePath   += m_dpFileName;	
        
    	if(hFile == NULL)
    	{
    		hFile = fopen(dpFilePath, "a+");
    		if(hFile)
    		{
    			size = fwrite(m_pszStream, m_sFileSize,sizeof(char), hFile);			
    			if(size < 0)
    			{
    				dpResult = DPMS_FILE_WRITE_ERROR;
    			}
                fclose(hFile);
    		}
    		else
    		{
    		   dpResult = DPMS_FILE_OPEN_ERROR;
    		}		
    	}	
    	
    	return dpResult;
    }
    in this code i had made size of file as member variable but i want it to access through the char* type of buffer. this char* could contain any type of data like binary string so the size should be for binary data also.
     
    Last edited by a moderator: Feb 5, 2008

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