Skip to main content
3 of 4
added 320 characters in body
user avatar
user avatar

Error: Expected Expression

During Problem Set i came across the error Expected Expression on the statement "string s = GetString();" Suggestions would be appreciated. The code is provided below.

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

int main(void)
{
    int s = 0; // Height
    int t = 0; // Line
    int u = 0; // Column

    do
    {
        // Gathers string.
        printf("Please provide the height of the pyramid: ");
        string s = GetString();
    }
    while (s < 1 || s > 23);

    // Selects a line.
    for (int t = 1; t <= s; t++)
    {
        // Selects a column.    
        for (int u = 1; u <= s; u++) 
        {
        // Prints character.
        if (u >= s + 1 - t)
        {
            printf("#");
        }
        else
        {
            printf(" ");
        }
        }
    }
    // Prints next line.
    printf("\n");
}
user7194