Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Passing multidimensional arrays to functions

Passing multidimensional arrays to functions

Scheduled Pinned Locked Moved C / C++ / MFC
helpdata-structuresquestion
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Royce Fickling 0
    wrote on last edited by
    #1

    Hi, I am having a problem declaring and passing a multidimensional array of floats as an argument to a function. Can someone help me with this problem? My code is enclosed. Any help appreciated.

                float\* pData = new float\[nNumRows,2\];
    	for( int i = 0; i < nNumRows;  i++ )
    	{
    		pData\[i\]\[0\] = ((CSodSpecData\*)pOdbSpecData)->m\_cvData\[i\].Real();
    		pData\[i\]\[1\] = ((CSodSpecData\*)pOdbSpecData)->m\_cvData\[i\].Imag();
    	}
    
    	lErrorCode = pService->serviceNotifyDataEventSet( pData\[0\], strSensorName );
    
    // The function to store the data
    CDFstatus CABCDEntryPointService::serviceNotifyDataEventSet(float\* dataSet, const CString& varName)
    
    L D 2 Replies Last reply
    0
    • R Royce Fickling 0

      Hi, I am having a problem declaring and passing a multidimensional array of floats as an argument to a function. Can someone help me with this problem? My code is enclosed. Any help appreciated.

                  float\* pData = new float\[nNumRows,2\];
      	for( int i = 0; i < nNumRows;  i++ )
      	{
      		pData\[i\]\[0\] = ((CSodSpecData\*)pOdbSpecData)->m\_cvData\[i\].Real();
      		pData\[i\]\[1\] = ((CSodSpecData\*)pOdbSpecData)->m\_cvData\[i\].Imag();
      	}
      
      	lErrorCode = pService->serviceNotifyDataEventSet( pData\[0\], strSensorName );
      
      // The function to store the data
      CDFstatus CABCDEntryPointService::serviceNotifyDataEventSet(float\* dataSet, const CString& varName)
      
      L Offline
      L Offline
      led mike
      wrote on last edited by
      #2

      Royce Fickling wrote:

      I am having a problem declaring and passing a multidimensional array of floats

      Without knowing what that method requires at the address sent as the first parameter all I can offer is this will compile. No way to know if is correct. pService->serviceNotifyDataEventSet( pData, strSensorName ); or pService->serviceNotifyDataEventSet( &pData[0], strSensorName );

      1 Reply Last reply
      0
      • R Royce Fickling 0

        Hi, I am having a problem declaring and passing a multidimensional array of floats as an argument to a function. Can someone help me with this problem? My code is enclosed. Any help appreciated.

                    float\* pData = new float\[nNumRows,2\];
        	for( int i = 0; i < nNumRows;  i++ )
        	{
        		pData\[i\]\[0\] = ((CSodSpecData\*)pOdbSpecData)->m\_cvData\[i\].Real();
        		pData\[i\]\[1\] = ((CSodSpecData\*)pOdbSpecData)->m\_cvData\[i\].Imag();
        	}
        
        	lErrorCode = pService->serviceNotifyDataEventSet( pData\[0\], strSensorName );
        
        // The function to store the data
        CDFstatus CABCDEntryPointService::serviceNotifyDataEventSet(float\* dataSet, const CString& varName)
        
        D Offline
        D Offline
        David Crow
        wrote on last edited by
        #3

        Royce Fickling wrote:

        float* pData = new float[nNumRows,2];

        Should this be:

        float pData = new float[nNumRows][2];

        "Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown

        "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups