0

When compiling, I'm struggling with this error, I know I don't have the logic for the pyramid yet but wanted to break the problem up into smaller steps. I can't see why this won't just do a simple printf though. I'm sure this is a very simple error and sorry if this is a stupid question.

#include <stdio.h>
#include <cs50.h>

int main (void)
{
    int py_height = 0;

    do
    {
        printf("Height:");
        py_height = GetInt();
    }
    while (py_height < 0 || py_height >23);

    for (int row = 0, row < py_height; row++);
    {

        printf(" ");
        printf("#");
        printf("\n);

    }
        //code outside
}

This is the first error that I get:

mario.c:15:27: error: redefinition of 'row'
    for (int row = 0, row < py_height; row++);
2

Check your for loop syntax, you want to separate the expressions with a ";". By using a ",", you are redeclaring row, thus the error.

1
  • Cheers Ronga, not sure how the comma slipped in there, now to do the logic for the spaces! :) Jan 26 '16 at 16:00
1

you are not using the correct syntax for the for loop header. see Loops for more information!

1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .