0

I'm trying to run this code and here's the error that i get:

clang -fsanitize=signed-integer-overflow -fsanitize=undefined -ggdb3 -O0 -std=c11 -Wall -Werror -Wextra -Wno-sign-compare -Wshadow    zeki.c  -lcrypt -lcs50 -lm -o zeki
zeki.c:7:1: error: expected identifier or '('
{

I did try removing semicolon after my int main(void), i still got the same error. Any help would be appreciated :)

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

// user will be prompted to give a height for the pyramid. max 15 rows is allowed.

int main(void);
{
    int height = get_int();
    do
        {
        printf("How many rows do you want the pyramid to have?\n");
        }
    while (height < 0 || height > 15);

    for (int i = 0, i < height, i++ )
    {
        // print spaces to the left of the blocks.
        int space1 = height - 1;
        for (int j = 0; j < space1; space1--);
        {
            printf(" ");
        }
        // print blocks in the middle.
        int block =  0;
        for (block < i + 1; block++)
        {
            printf("#")
        }
        // print spaces to the right of the blocks.
        int space2 = height - 1;
        for (int j = 0; j < space2; space2--)
        {
            printf(" ");
        }
        printf("\n");
    }
}
2

The problem is on line 7, this line int main(void);. Remember, ; is the terminator, so the main function gets terminated before it has a chance to begin!

1

In addition, your program is full of fairly simple syntax errors that you should be able to solve on your own, perhaps the most serious is to use get_int () without using the header file cs50.h

1
  • Thanks so much. I fixed everything like you said and it works.
    – Shawn
    Aug 19 '18 at 2:03

You must log in to answer this question.

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