Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

More help struct arrays

Status
Not open for further replies.

ToddT

Programmer
Feb 7, 2003
14
US
when I say

struct some_struct{
string Name;
int Count;
};
some_struct MyStruct[5];
it is okay, but when I say
MyStruct[3].Name="Todd";
I recieve a cannot allocate 0 sized constant array
does anyone know why, I've include just about every library there is just to be safe, and I am using namespace std.
 
What is "string"? I know only CString under MSVC (MFC).
What include files do you use?
 
>mingis (Programmer)
>What is "string"? !smart question
string is std::string from STL file named string (not string.h). Read more about STL.

Ion Filipski
1c.bmp
 
>>What is "string"? !smart question
:)
> Read more about STL.
I'll try...
 
What about my first STL application?
It works, nevertheless I still do not understand how...

#include <string>
#include <iostream>

namespace std
{

struct some_struct
{
string Name;
int Count;
};

some_struct MyStruct[5];

void test(void)
{
MyStruct[3].Name="Todd";
cout << MyStruct[3].Name << endl;
}

}

main()
{
std::test();
return(0);
}
 
#include <string>
#include <iostream>

using namespace std;
.....

Ion Filipski
1c.bmp
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top