R
Russell Mangel
Sorry about the Cross-Post, I posted my question in the wrong group.
Hello,
What is the simplest way to create a dynamic collection (during run-time),
using basic C (Struct data types). Since I am doing C++/CLI interop I wish
to avoid using vector class.
I am using Visual Studio 2005 C++/CLI, and I am writing an Un-Managed class
library. The project type will be a static library (possibly a dll). I have
designed this project type to support both Un-Managed Win32 Console client,
and a Managed (.NET) console client.
I have created a basic (static struct), which only handles 255
messageStores.
Can someone point me in the right direction? I don't need any sorting or
deleting. Just Adding.
Russell Mangel
Las Vegas, NV
// Unmanged C++ Class
class MyStuff
{
public:
MyStuff::MyStuff(void) { }
MyStuff::~MyStuff(void) { }
struct MessageStores {
int cValues;
struct {
LPTSTR AliasName;
LPTSTR ServerName;
int cMessages;
}MessageStore[255]; };
MessageStores MyStuff::GetMessageStores() {
/*
This will be a loop which fills the structure, currently it is static
(255).
I don't know in advance the count of MessageStores.
How would I create this collection at run-time using the basic data
structures of C ?
I am aware of Vector class. I can not use it.
*/
MessageStores messageStores;
messageStores.MessageStore[0].AliasName = "BugsBunny";
messageStores.MessageStore[0].ServerName = "AcmeServer";
messageStores.MessageStore[0].cMessages = 3333;
messageStores.MessageStore[1].AliasName = "Daffy";
messageStores.MessageStore[1].ServerName = "MallardServer";
messageStores.MessageStore[1].cMessages = 4000;
messageStores.MessageStore[2].AliasName = "Elmer";
messageStores.MessageStore[2].ServerName = "ToonServer";
messageStores.MessageStore[2].cMessages = 2000;
messageStores.cValues = 3;
return messageStores; }};
// Un-Managed Client
void main(void){
MyStuff ms;
MyStuff::MessageStores messageStores = ms.GetMessageStores();
for(int i = 0; i < messageStores.cValues; i++) {
printf("%s\n", messageStores.MessageStore.AliasName); } }
Hello,
What is the simplest way to create a dynamic collection (during run-time),
using basic C (Struct data types). Since I am doing C++/CLI interop I wish
to avoid using vector class.
I am using Visual Studio 2005 C++/CLI, and I am writing an Un-Managed class
library. The project type will be a static library (possibly a dll). I have
designed this project type to support both Un-Managed Win32 Console client,
and a Managed (.NET) console client.
I have created a basic (static struct), which only handles 255
messageStores.
Can someone point me in the right direction? I don't need any sorting or
deleting. Just Adding.
Russell Mangel
Las Vegas, NV
// Unmanged C++ Class
class MyStuff
{
public:
MyStuff::MyStuff(void) { }
MyStuff::~MyStuff(void) { }
struct MessageStores {
int cValues;
struct {
LPTSTR AliasName;
LPTSTR ServerName;
int cMessages;
}MessageStore[255]; };
MessageStores MyStuff::GetMessageStores() {
/*
This will be a loop which fills the structure, currently it is static
(255).
I don't know in advance the count of MessageStores.
How would I create this collection at run-time using the basic data
structures of C ?
I am aware of Vector class. I can not use it.
*/
MessageStores messageStores;
messageStores.MessageStore[0].AliasName = "BugsBunny";
messageStores.MessageStore[0].ServerName = "AcmeServer";
messageStores.MessageStore[0].cMessages = 3333;
messageStores.MessageStore[1].AliasName = "Daffy";
messageStores.MessageStore[1].ServerName = "MallardServer";
messageStores.MessageStore[1].cMessages = 4000;
messageStores.MessageStore[2].AliasName = "Elmer";
messageStores.MessageStore[2].ServerName = "ToonServer";
messageStores.MessageStore[2].cMessages = 2000;
messageStores.cValues = 3;
return messageStores; }};
// Un-Managed Client
void main(void){
MyStuff ms;
MyStuff::MessageStores messageStores = ms.GetMessageStores();
for(int i = 0; i < messageStores.cValues; i++) {
printf("%s\n", messageStores.MessageStore.AliasName); } }