here i have portion of code where im supposed to list data with commas but i am having a lot of difficulty getting rid of the beginning comma for some reason.
elseif (choice == 2)
{
cout << "Show teams with at least how many wins?";
cin >> ww;
for (int i = 0; i < x; i++)
{
if ((list[i].wins >= entry))
{
if (list[i].name > mark[0].name)
{
cout << ", " << list[i].name;
}
else
{
cout << list[i].name;
}
}
}
}
elseif (choice == 2)
{
int flag=0;
cout << "Show teams with at least how many wins?";
cin >> ww;
for (int i = 0; i < x; i++)
{
if ((list[i].wins >= entry))
{
if (list[i].name > mark[0].name)
{
flag++;
if (flag==1)
cout << list[i].name;
else
cout << ", " << list[i].name;
}
else
{
cout << list[i].name;
}
}
}
}
the same thing you can do with your else statement (if you want a comma there too )