2
Okay, the problem is only in function q31 and q311.
I left the complete code on the link above.
then here is this function q311:
void q311(){
char forma;
int n,jota,b,i,j;
printf("Informe a figura e o tamanho: ");
scanf("%c",&forma);
scanf("%i",&n);
if (forma=='q')
{
for ( i = 0; i < n; ++i)
{
printf("*");
for ( b = 1; b < n; ++b)
{
if ((i==jota)|| (i==0))
{
printf("*");
}
else if (b==jota)
{
printf("*");
}
else
printf(" ");
}
printf("\n");
}
}
else if (forma=='t')
{
for(int i=n-1;i>=0;i--)
{
for(int j=0;j<=i;j++)
{
if(i==n-1 || j==0 ||i==j)
printf("*");
else
printf(" ");
}
printf("\n");
}
}
else
printf("Forma Invalida\n");
}
My program always gives as output "Invalid form" even if Voce type "t" or "q"... I wonder why this is happening.
I ran the posted function as a program and it worked right. The character comparison you’re doing is right. It could be junk, try using
fflush(stdin)
before theprintf
.– DaviAragao
which printf? the first?
– Leonardo Dias
Voce thinks the string is garbage value?
– Leonardo Dias
Yes it can happen, after all you have a large program with several functions. Try to use the command before the first
printf
. Try to run the function alone as I did and then tell me the result.– DaviAragao
Weird! It really works ...
– Leonardo Dias
But there’s no way to solve for the big show?
– Leonardo Dias
The
fflush(stdin)
did not resolve?– DaviAragao