I'm in week 2 of cs50 and am currently working on the Readabilty problem. I've written a function named count_letters under main and have declared it at the top of the programm. However when I attempt to compile through make readability I recieve this error message:

/home/ubuntu/readability/readability.c:11: undefined reference to 'count_letters'
clang-7: error: linker command failed with exit code 1 (use -v to see invocation)
<builtin>: recipe for target 'readability' failed
make: *** [readability] Error 1`

I've gone back through the lectures and shorts as well as several online tutorials on making functions to make sure I'm not missing anything and help50just tells me that I could have forgotten to link the library that count_letters is defined in. However, as I mentioned above, the function in declared in readability.c. Does anyone know what the problem could be?

Here is my code:

//include standard libraries
#include <stdio.h>
#include <cs50.h>
#include <string.h>
int count_letters(string a);//function prototype`

int main(void)
    string text = get_string("Text:\n");//gets text input

    int NL = count_letters(text);//counts letters of text

    printf("%s\n", text);//prints text
    printf("%i\n", NL);//prints number of letters


int count__letters(string a)
    int nl = 0;//noumber of letters in string

    int la = 0;

    for(int i = 0;la == strlen(a); i++)
        if(a[i] >= 'A' && a[i] <= 'Z' )//if the current character is a capital letter
            nl++;//add 1 to  number of letters
        if( a[i] >= 'a' && a[i] <= 'z')//if the current character is a lowercase letter
     return nl;// return number of letters

I'm sorry if the formatting is off, I'm new to this.

  • Can't tell anything without seeing the code. Usually, it's a missing or incorrect function signature or it's placement.
    – Cliff B
    Commented Apr 16, 2020 at 16:03
  • I've added my code. Sorry for not including it from the beginning!
    – Renée
    Commented Apr 17, 2020 at 6:22

1 Answer 1


wow, talk about subtle errors! Simply put, the compiler can't find the function because the function with that __exact__ name isn't there!

It's a typo! How many underscores are there??? ;-)

If this answers your question, please click on the check mark to accept. Let's keep up on forum maintenance. ;-)

  • THANK YOU!!! I'm dyslexic and I wouldn't have found this otherwise. I'm happy to know that I at least understood the theory properly!
    – Renée
    Commented Apr 17, 2020 at 9:18

You must log in to answer this question.

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