Reputation: 25
I am trying to assign the return value of int leftPyramid(void);
to a variable left
so I can use printf
to print the pattern.
#include <stdio.h>
#include <cs50.h>
int leftPyramid(void);
int main(void){
int left;
The following is the code for int leftPyramid(void);
it creates the following pattern:
#
##
###
####
int leftPyramid(void);{
for (int i = 1; i<=num_rows; i++){
for(int j=1; j<=num_rows-i; j++){
printf(" ");
}
for(int k= 1; k<=i; k++){
printf("#");
}
printf("\n");
}
}
The following line is causing the error but I can't figure why.
left = int leftPyramid(void); //this line seems to be the problem.
int num_rows = get_int("height: \n");
printf("%d", left);
Upvotes: 1
Views: 1032
Reputation: 26703
This is the prototype of your function:
int leftPyramid(void);
in order to call it you need
left = leftPyramid();
When you fixed that you will notice the problem mentioned by Carcigenicate in the comment, i.e. you will have to return something meangingful from your function. Sadly I have no idea what that could be, but it is not part of your question.
Upvotes: 1