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 help50
just 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
{
nl++;
}
}
return nl;// return number of letters
}
I'm sorry if the formatting is off, I'm new to this.