1. C programming star count

Code:
```#include <stdio.h>
#include <stdlib.h>

int DrawRow(int length)
{
int i, count=0;
for(i = 1; i <= length; i++)
{
printf("*");

}
printf("\n");
return count;
}
int DrawSquare(int length)
{
int j,i, count=0;
for(j=1; j<=length; j++)
{
DrawRow(length);
count++;
}
printf("\n");
return count;
}
int DrawTriangle(int length)
{
int j,i,count=0;
for(j=1; j <=length; j++)
{
DrawRow(j);
count++;
}
printf("\n");
return count;
}
int DrawTriangles(int length)
{
int i,j,k,count=0;
for(k=1; k<=length; k++)
{
DrawTriangle(k);
count=k*count;
}
printf("\n");
return count;
}

main()
{
int choice,x,count,total,total_stars;

while(1)
{
printf("enter a number greater than 0 here:\n", x);
scanf("%i",&x);

if (choice == 0) break;

printf("choose 1(row of stars),2(square),3(triangle),4(triangles) or 0(quit)\n");
scanf("%i",&choice);
if (choice == 0) break;
if (choice == 1) total_stars=DrawRow (x);
if (choice == 2) total_stars=DrawSquare (x);
else if (choice ==3) total_stars=DrawTriangle (x);
else if (choice ==4) total_stars=DrawTriangles (x);
else if (choice >=5) break;
total_stars=x+total_stars;
}
printf("\n");
printf("Numbers of stars are %i\n", total_stars);

system("pause");
}```

I'm trying to have it count the total number of stars or * when i finish. So I would enter the number on the first line greater than 0, and then on the second line and it would produce a line, square or triangle, and then enter 0, and 0 again to end the loop. However i can only make it count certain number of stars. Any help on fixing the count so i can count all the * ?

2. Code:
```{
int i, count=0;
for(i = 1; i <= length; i++)
{
printf("*");

}
printf("\n");
return count;
}```
'count' here is not actually used. You look like you've got the right idea though. Any time you have it spit out a star, increment your star counter.
Code:
```int drawline( int length )
{
int stars = 0, x;
for( x = 0; x < length; x++ )
{
spitoutastar( );
stars++;
}
return stars;
}```

Quzah.

3. Originally Posted by quzah
Code:
```int drawline( int length )
{
int stars = 0, x;
for( x = 0; x < length; x++ )
{
spitoutastar( );
stars++;
}
return stars;
}```

Quzah.
I tested that out, but i would get an error undefined reference to spitoutstar.

4. /facepalm

That was just an example. You should replace that with whatever you plan on using to put a '*' on the screen.

Quzah.

5. oh my bad, I'm new at this I just started C programming like a month ago.