17
votes
Accepted
Error: "make: *** No rule to make target `mario'. Stop."
This is a very common question asked by new students. The make command is used to compile the source code and generate an executable program. While there are complexities to this process (more ...
12
votes
What's wrong with my code for mario?
Five months is too long for a problem like mario or pretty much any other problem in the course.
You could try solving it manually with low-tech tools (e.g., a pencil and a paper) trying to draw half ...
8
votes
Accepted
Problem with "expression result unused" error in for-loop
In a for loop, the first item is the initialization. You are saying
for (height; height>0; height--)
and the compiler is expecting that first item to be an initialization but you have simply ...
7
votes
Accepted
Stuck on pyramid for mario.c
I can not seem to make a pyramid, only a straight line of #'s.
In order to make a pyramid, you'll need more than one line. The way to move to the next line when printing out characters to the ...
6
votes
Completely lost.. pset1, Mario help
You are validating the input after they enter it.
So your program asks for input using GetInt(), which it sounds like you have figured out.
and then you write a piece of code (a loop might be pretty ...
6
votes
Tips on spaces and hashes Mario
Well, you wanted some tips, so here are a few thoughts on it. You know that you have to create the correct number of rows, you have that part. Now, you need to think about how to create the spaces ...
5
votes
Accepted
How to debug "initialized element is not a compile-time constant" and "expected identifier" errors
You have the right idea behind how the code works, it's just your English to C needs some practice (understandably).
int main(void);
This is, as its name suggests, the "main" method. Essentially, ...
5
votes
How to approach Problem Set 1 Mario!
If the white space on the screen intimidates you, try outlining the problem on scrap paper. Think in broad terms, and describe what you're going to do in plain English before you write the code. Think ...
5
votes
pset1 mario - declaration shadows a local variable
With your usage of int you're creating a new variable.
Example:
int blocks = 5;
{// Just creating a block, similar to a loop
int blocks = 4; //Variable inside the block
printf("%d\n", blocks); /...
5
votes
Accepted
pset1 (mario, more) - problem with unwanted leading spaces
What conclusion can be drawn from these two facts?
This loop for (row = 0; row <= height; row++) will generate height + 1 lines of output (0 through height inclusive)
The first output line (ie row ...
4
votes
Accepted
Mario Pyramid - Check50 - Unexpected end of input
Before you post a question, you should search to see if your question or a similar one had already been asked, in which case yours is. Check 50 returns unexpected end of input
I suggest that you try ...
4
votes
Accepted
Output on Mario
I found a small but fatal glitch in your code.
Have a look on you first loop in output part
for (tower_height = 0; tower_height <= 23; tower_height ++)
A moment before this line in your code, you ...
4
votes
Do do/while loops only take one line?
The syntax for do-while loop goes like this
do
{
//do something here
} while(test_condition);
It is better to use braces {} every time you use loops. Although loops work even without their use, ...
4
votes
Accepted
Check50 tests fail with expected output, but not " ##\n"
You are printing one extra space character each row.
4
votes
Accepted
Pset1 : the mario question. I don't understand the logic of my own solution, it just doesn't make sense (found it by randomly playing around)
The value of s is increasing but the number of spaces it prints will be decreasing because you are inside the outer loop.
Take your program and add some debug print statements like this:
#include &...
4
votes
Why do I get an "undefined identifier" error even though the variable is defined in my code?
In C all variable names have to be declared before they are used. If you try to use the name of a variable or a function that hasn't been declared you will get an "undeclared identifier" error.
You ...
4
votes
What's wrong with this code?
This line causes it: for (spaces = height - rows; spaces <= height; --spaces).
While spaces is less than height, print a space and make spaces smaller. It is an infinite loop.
4
votes
any idea how to fix Mario more comfortable problem "expected output"
check50 is expecting the last # on a line to be followed by the newline. It is complaining about the trailing spaces.
3
votes
do while loop not working?
Your condition is flawed. If x is greater than 0 OR x is less than 23, the loop will keep going. x > 0 includes all positive numbers, and x < 23 includes all negative numbers in addition to ...
3
votes
mario.c-printing of pyramid tower
Running the program: check50 should only be used to check your program before submitting it. To test your program while you're working on it, first run make to compile the program, then run mario to ...
3
votes
Accepted
Having Trouble tackling corner cases for Mario
You've declared your integer height inside the curly braces, so it is no longer in scope (no longer in existence) once you reach the end of the curly brace. I'm assuming you've also declared it ...
3
votes
Accepted
Stuck on PSet1: I have the correct output, but Check50 says it's wrong
check50 is not wrong! Please check this question for more information about check50.
Make sure you're in the same directory as mario.c and this is the command you run to check your program with ...
3
votes
Accepted
C syntax errors like "expected expression"
It's a misplaced curly brace.
do
{
int num = GetInt();
}
while( int num < 0 || int num > 23 );
You want to enclose the do statement in curly braces, but keep the while condition outside....
3
votes
How to Convert Integers to Spaces/Hashes?
If you use printf(" ") and printf("#") they will print one after another, when you need to go to the next line, just printf("\n")
3
votes
What's wrong with my code for mario?
On lines 15 and 16, you are declaring two variables and initializing them to an empty space.
int spaces =
int hashes =
This is very bad coding practice. Also, lines 23 - 27 have no function yet ...
3
votes
Accepted
Infinite loop when validating input as integer
From the comments above, it seems that you may have solved this already by using GetInt() from the cs50 library (and you should use it of course). But just if you're curious about why that happened, ...
3
votes
Do do/while loops only take one line?
This error is because of the missing braces '{}'.
Languages like python compile the code based on the indenting. However, C requires braces around do-while to compile correctly. Your code doesn't ...
3
votes
fatal error: 'stio.h' file not found (pset1)
Change it to
#include <stdio.h>
You've got a typo.
3
votes
Accepted
Why is my `mario` pyramid height restriction not working?
The while condition in a do while loop is the condition that causes the loop to repeat.
do
{
//this
}
while (this is true)
Can you see why yours is incorrect? You have used the opposite ...
3
votes
So Close on Mario Pyramid
the pseudocode for Mario
for height of pyramid
for (calculate nr. of spaces at height)
print ' '
for (calculate nr. of hashes at height)
print '#'
print a newline
I'd defer ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
mario × 478pset1 × 354
check50 × 35
cs50x × 31
c × 24
pyramid × 21
mario.less × 20
pset6 × 19
error × 15
python × 14
less × 13
for-loop × 10
spaces × 10
compilation-error × 7
lesscomfortable × 7
hashes × 7
help × 6
loop × 6
hacker1 × 6
cs50x2019 × 6
morecomfortable × 6
do-while × 6
mario.more × 6
cs50-ide × 5
cs50-pset1 × 5