0

I'm receiving the error:

/usr/bin/ld: /tmp/readability-1786f7.o: in function main': /workspaces/109105972/readability/readability.c:19: undefined reference to count_letters' clang: error: linker command failed with exit code 1 (use -v to see invocation) make: *** [: readability] Error 1

when trying to use the make readability command. I've been struggling with this for hours mostly rewriting the function code in various ways. I've also looked at similar questions regarding this and have updated my vs code with "update50" and checked function "int count_letters(string text)" for grammatical errors even going so far as copy pasting it more than once.

My code:

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


int main(void)
{
// Declare functions

int count_letters(string text);
int count_letters(string);

// Get text from user

    string text = get_string("Text: ");

// implement function count_letters

    int cl = count_letters(text);
    printf("%i", cl);

//Function performance count_letters

int count_letters(string text);
{
    int l = 0;

    for (int i = 0; text[i] != '\0'; i++)
    {
        if (isalpha(i))
        {
            l++;
        }
    }
    return l;
}
}

1 Answer 1

0

I spent 6hr struggling with this only to realize that the function "int count_letters(string text)" is inside the body of main. By moving the last } and placing it on the line above the function closing the body of main before creating the function the program works now.

You must log in to answer this question.

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