0

Could anyone help me figure out why I can not compile, but get the following error:

~/workspace/pset1/mario/less/ $ make mario
clang -fsanitize=signed-integer-overflow -fsanitize=undefined -ggdb3 -O0 -std=c11 
-Wall -Werror -Wextra -Wno-sign-compare -Wno-unused-parameter -Wno-unused-variable 
-Wshadow    mario.c  -lcrypt -lcs50 -lm -o mario

when trying to compile:

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

int main(void)
{
    int height;
    int spaces;
    int hash;

do
{
    printf("Please choose a height from 0 to 23");
    height = get_int("height:");
}
// Promt and loop if not between 0-23
while (height <= 0 || height >= 23);

for (int i = 1; i <= height; i++)
{
    // To print out spaces
    for (spaces = (height - i); spaces >=0; spaces--)
    {
        printf("  ");
    }
    // To print out hashes
    for (hash = 1; hash <= (i + 1); hash++)
    {
        printf("#");
    }
    printf("\n");
}
return 0;
}

Thanks!

1 Answer 1

0

Your program compiles perfectly, what you show us in your question is not an error, they are all the options of the clang compiler that come by default with the command make, work that the course staff have done for us. You should see in your directory a file called mario that contains the object code resulting from the compilation. Another thing is that program in c is not entirely correct, but almost yes, the number of spaces that are printed is not correct, there is a very simple arithmetic relationship between the number of hastags and the number of spaces, that you have to find

1
  • Sorry for super late answer, but thank you MARS, I figured it out eventually!
    – thonje
    Commented Jan 24, 2019 at 9:11

You must log in to answer this question.

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