Hey guys,
I recently started the cs50x course online and try to learn c because I haven't got any programming courses in school atm.
I don't want anyone here to solve the courses homework for me but I'm stuck with an error I don't really get...
The task was to get an integer from 1-23 from the user and then to build a pyramide like this:
height: 8
##
###
####
#####
######
#######
########
#########
So I wrote this code:
But I get this goddamn error:Code:#include <stdio.h> #include <cs50.h> int main() { printf("Please enter the pyramid's height:\n"); int height = GetInt(); while (height < 1 || height > 23) { printf("Please enter a positive Integer not bigger than 23:\n"); height = GetInt(); } for(int height2 = height , int b = 2 , int c = 6 ; height2 > 0 ; height2-- , b++ , c--) { for(int leerzeichen = (height (+1 -b));leerzeichen > 0;leerzeichen--) { printf(" "); } for(int rauten = (height (+1 - c)); rauten > 0; rauten--) { printf("#"); } printf("\n"); } }
~/workspace/pset1 $ make mario
clang -ggdb3 -O0 -std=c11 -Wall -Werror -Wshadow mario.c -lcs50 -lm -o mario
mario.c:15:32: error: expected identifier or '('
for(int height2 = height , int b = 2 , int c = 6 ; height2 > 0 ; height2-- , b++ , c--)
^
mario.c:15:32: error: expected ';' in 'for' statement specifier
mario.c:15:32: error: expected expression
mario.c:15:68: error: expected ')'
for(int height2 = height , int b = 2 , int c = 6 ; height2 > 0 ; height2-- , b++ , c--)
^
~/workspace $ make mario
make: *** No rule to make target `mario'. Stop.
~/workspace $ cd pset1
~/workspace/pset1 $ make mario
clang -ggdb3 -O0 -std=c11 -Wall -Werror -Wshadow mario.c -lcs50 -lm -o mario
mario.c:15:32: error: expected identifier or '('
for(int height2 = height , int b = 2 , int c = 6 ; height2 > 0 ; height2-- , b++ , c--)
^
mario.c:15:32: error: expected ';' in 'for' statement specifier
mario.c:15:32: error: expected expression
mario.c:15:68: error: expected ')'
for(int height2 = height , int b = 2 , int c = 6 ; height2 > 0 ; height2-- , b++ , c--)
^
mario.c:15:8: note: to match this '('
for(int height2 = height , int b = 2 , int c = 6 ; height2 > 0 ; height2-- , b++ , c--)
^
mario.c:15:64: error: relational comparison result unused [-Werror,-Wunused-comparison]
for(int height2 = height , int b = 2 , int c = 6 ; height2 > 0 ; height2-- , b++ , c--)
~~~~~~~~^~~
mario.c:15:70: error: use of undeclared identifier 'height2'; did you mean 'height'?
for(int height2 = height , int b = 2 , int c = 6 ; height2 > 0 ; height2-- , b++ , c--)
^~~~~~~
height
mario.c:7:9: note: 'height' declared here
int height = GetInt();
^
mario.c:15:82: error: use of undeclared identifier 'b'
for(int height2 = height , int b = 2 , int c = 6 ; height2 > 0 ; height2-- , b++ , c--)
^
mario.c:15:88: error: use of undeclared identifier 'c'
for(int height2 = height , int b = 2 , int c = 6 ; height2 > 0 ; height2-- , b++ , c--)
^
8 errors generated.
make: *** [mario] Error 1
It would be great if you could help me, because I really don't know
what the hell I did wrong
Lovely greetings from Germany,
Polarsturm (Johannes)