问题一:
怎么设置我的CListBox,使其不能加入重复值。
如果连续 AddString("test1"),则只加入一条即可。问题二:
typedef struct student
{
char name[20];
int age;
}
我定义struct student *p[5];是这样定义的吗?怎么初始化?怎么赋值?帮忙举个例子。谢谢。
怎么设置我的CListBox,使其不能加入重复值。
如果连续 AddString("test1"),则只加入一条即可。问题二:
typedef struct student
{
char name[20];
int age;
}
我定义struct student *p[5];是这样定义的吗?怎么初始化?怎么赋值?帮忙举个例子。谢谢。
2、
typedef struct student
{
char name[20];
int age;
} STU;
STU *p[5];
p[0] = new STU;
p[0]->age = 21;
strcpy(p[0]->age, "titilima");
p[1] = new STU;
// ...// delete them after using
for (int i = 0; i < 5; i++)
delete p[i];
{
char name[20];
int age;
}student;student stu[5];
for(int i=0;i<5;i++)
{
strcpy(stu[i].name,AnsiString("stu"+AnsiString(i)).c_str());
ShowMessage(AnsiString(stu[i].name));
stu[i].age=i;
}
BOOL IsInListBox( CString csData )
{
CString tmpString;
for( int i = 0; i < yourListBox.GetCount(); i++ )
{
yourListBox.GetText( i, tmpString );
if( tmpString == csData )
return TRUE;
}
retrun FALSE;
}第二个:
typedef struct student
{
char name[20];
int age;
}STU;
STU *p[5];for(int i=0;i<5;i++)
{
p[i] = new STU;
strcpy(p[i]->name,AnsiString("stu"+AnsiString(i)).c_str());
p[i]->age=i;
}
for( int i = 0; i < 5 ; i++ )
dele p[i];
直接student stu[5]就OK了嘛
new 来 new 去的不好吧