Hi
I want to populate a number in the Shared Memory of Linux.
Iam doing the following
This is my header file which contains the Shared memory structures
#ifndef _DATABASE_SHARED_
#define _DATABASE_SHARED_
typedef struct
{
char m_sTransactionNo[15];
} DBShared;
#define _SHM_KEY (key_t)0x100
#define _SHM_SZ sizeof(_SHM)
#endif
----------------------------------------------------
This function gets the shared memory
DBShared * GetDBSharedMemory()
{
static DBShared * pSharedMemory = NULL;
if (!pSharedMemory)
{
int nShmID = shmget( _SHM_KEY, _SHM_SZ, 0);
if ( nShmID >= 0)
{
pSharedMemory = (DBShared*) shmat( nShmID, 0L, 0);
}
}
return pSharedMemory;
}
Now how do i populate the stucture's element m_sTransactionNo with a number which is 14 character long ex A7247274724727"
Also,how do i read the same .
Can anybody help me in writing a good c++ program for it
Thanks in advance
I want to populate a number in the Shared Memory of Linux.
Iam doing the following
This is my header file which contains the Shared memory structures
#ifndef _DATABASE_SHARED_
#define _DATABASE_SHARED_
typedef struct
{
char m_sTransactionNo[15];
} DBShared;
#define _SHM_KEY (key_t)0x100
#define _SHM_SZ sizeof(_SHM)
#endif
----------------------------------------------------
This function gets the shared memory
DBShared * GetDBSharedMemory()
{
static DBShared * pSharedMemory = NULL;
if (!pSharedMemory)
{
int nShmID = shmget( _SHM_KEY, _SHM_SZ, 0);
if ( nShmID >= 0)
{
pSharedMemory = (DBShared*) shmat( nShmID, 0L, 0);
}
}
return pSharedMemory;
}
Now how do i populate the stucture's element m_sTransactionNo with a number which is 14 character long ex A7247274724727"
Also,how do i read the same .
Can anybody help me in writing a good c++ program for it
Thanks in advance