Garbage Output?

I know what i'm doing wrong, i just don't have a solution and can't word it correctly to find the answer via google. Here's me code:


1
2
3
4
5
6
7
8
9
struct Member
{
 char *name;
 char *address;	
 char Interests[][10];//<------problem
 int numofInterests;
 Numbers digits;
	
};


1
2
3
4
5
6
7
struct Club
{
	char *clubName;
	Member *ptrList;
	Member officers[3];
	int inumMembers; 
};


1
2
3
4
5
6
struct Numbers
{
	char *phone;
	char *birth;
	char *joined;
}


Now the Program:
1
2
3
4
5
6
7
8
newMember.Interests[numofInterests];
newMember.numofInterests = numofInterests;

for(int i = 0; i < numofInterests; i++)
{
 printf("Enter %s's %i interest: ", newMember.name, (i+1));
 cin.getline(newMember.Interests[i], 10); //<---problem
}


1
2
3
4
5
6
7
//Displays all information

for(int a = 0; a < ptrClubs[i].officers[j].numofInterests; a++)
{
	 printf("%s,",ptrClubs[i].officers[j].Interests[a]);//<--problem                   
}


it's a array of cstrings, but i can't figure out how keep it from outputting garbage, i'm assuming it's because i didn't end it with a null terminator but when i did, it didn't work Thanks for any suggestions
char Interests[][10];//<------problem

You're right, it is a problem. This isn't legal C++. You might want to turn off the compiler extension that allows it. It doesn't work because one dimension of your two dimensional array is 0.
Topic archived. No new replies allowed.