2 votes

Can't compile readability in cs50 IDE

I found that when following the instructions to create readability, the newly created tab "readability.c" has a red dot, and when clicked, it prompted me to save. Once saved, it should work. Hope ...
user avatar
2 votes
Accepted

Failure in Readability code

Pretty sure you meant isalnum. But shouldn't it be isalpha?
user avatar
  • 20.7k
2 votes
Accepted

Pset2 Readability test fail "complex single sentence" Grade 9 instead of Grade 8

What is happening there, is that you did your word count asuming that the next caracter would be alphabetical, here: al = isalpha(text[i + 1]);, but in this case, the next caracter are quotation marks ...
user avatar
  • 1,561
2 votes
Accepted

pset1 problem set 2 readability

One of the hidden lessons of this pset is to teach the impact of integers and floats on calculations. Look at the following code: float l = (100 * n_let) / n_words; Each of the 3 numbers involved in ...
user avatar
  • 64.1k
1 vote
Accepted

Incompatible pointer to integer conversion passing 'int on functions

You are not saving the value from your functions. What you're doing is the you call the function then the function counts the sentences and returns the count but your not assigning that return value ...
user avatar
  • 711
1 vote

cs50 question. Pset2 Readability

You have to add } at the end, and in the middle before float l = 100 / words * letters; to close out the for loop.
user avatar
1 vote
Accepted

Copying an array (string) to new array after light mutating (pset2 readability)

It just so happens that the memory allocated to letter_box here char *letter_box = (char*)malloc(strlen(text+1)); is all nulls (ie \0). Since the if loop will not change any non-alpha character (...
user avatar
1 vote

pset2 readability. cannot compile although int is declared and code is complete. could someone please look into?

The variables that you create in the for loops only exist within that for loop. You can use the result of a certain iteration of a for loop by eg: including an if function within the for loop to pick ...
user avatar
  • 21
1 vote
Accepted

pset2 readability. cannot compile although int is declared and code is complete. could someone please look into?

It's a scope problem: When you declare a variable inside a 'for' loop or a function, it only will be available until the loop/function ends. For example in your for loop: for(int i=0;text[i]!='\0';i++)...
user avatar
  • 1,561
1 vote
Accepted

Why is my (readability.c) file in ~/.c9/metadata/environment/readability/ instead of ~/readability?

Press Ctrl+S (Windows) or Command + S (MacOS) to save the file. It will let you choose which directory you want to use.
user avatar
1 vote

Readability assignment, getting "Segmentation fault" message

Have a look at your evaluation condition for your loop: i += 1, n The net result of this condition is simply that i will get incremented by 1 each loop. The comma operator has the lowest precedence ...
user avatar
  • 940
1 vote
Accepted

Readability CS50 Not counting the spaces

string input = get_string("Text:"); //getting input from the user int len = strlen(input); //determining the length of the string int space = 0; //declaring a variable to count whitespaces ...
user avatar
1 vote

Pset 2 - Readability -> Wrong grade

There are several problems. First, the word count is off by 1. Hint: is the code actually reading the end of string marker? Second, and most important, look at the calculations: float L = ...
user avatar
  • 64.1k
1 vote
Accepted

pset 2 Readability Segmentation Fault

the issue is the condition you wrote inside the for loop for i (s[i] != 0 || s[i] != 1 ). you need to set a limit for i (when will the for loop terminate ? = when will the i stop increasing by 1?). ...
user avatar
  • 109
1 vote
Accepted

What am I missing ? (pset2, readability)

the reason that your program is not working is because you are decrementing words with each question mark and exclamation point. If you remove words--; from your program, it works correctly! By the ...
user avatar
  • 165
1 vote
Accepted

Fatal error "segmentation fault" when trying to run program

isalpha() expects a char, not a char *. You could dereference str using str[0], str[1] and so on. You can figure out which line of code is causing the segmentation fault by first clicking to the left ...
user avatar
  • 165
1 vote

Week 2 Readability Letter Count

Hint: The function isalpha(), along with it's cousins like isspace() and ispunct(), etc., are your friends. ;-)
user avatar
  • 64.1k
1 vote
Accepted

Someone familiarized with pset2's Readability. I'm stuck here

Syntax error. You just need to change it to the correct syntax. do { ... } while(isalpha(n)); The isalpha() function takes a parameter (inside the parentheses). That's what will be checked ...
user avatar
  • 64.1k
1 vote

Readability counting letters advice

First, there's no semicolon after return. But, that's a moot point. The return statement will cause the program to terminate immediately. It needs to be the last line in the program, before the last ...
user avatar
  • 64.1k
1 vote

Readability counting letters advice

I am unfamiliar with the exact problem you are working on, but one thing I see right away is that your for loop doesn't go anywhere - you say for(int i = 0; i > 0; i++) but then don't have ...
user avatar
1 vote

Pset 2 Readability

count_letters is a function. count_letters("Some text") is an int. You've got the %i flag in your printf statement, so you need an int as the second argument. That's why it's not compiling. ...
user avatar
  • 709
1 vote

Readability check50 error

Did you notice that your code includes a colon after the word grade but check50 results don't? ;-) The lesson here is that program specs are to be followed exactly and precisely. Close or similar ...
user avatar
  • 64.1k
1 vote

PSET2 Readability - tests no passing

From man ispunct: ispunct() checks for any printable character which is not a space or an alphanumeric character. This if (ispunct(txt[i])) will be true for a whole host of characters that are not .,...
user avatar
1 vote

Why doesnt this code function?

The code doesn't work because num_letters is 0. The for loop will never run. In fact, it won't compile either because i and len are not created/defined before attempting to use them.
user avatar
  • 64.1k
1 vote

Can't compile readability in cs50 IDE

Experiencing the same issue. I've tried instructions verbatim several times and receiving "make: *** No rule to make target 'readability'. Stop I've tried deleting, and starting over, but no luck.
user avatar
1 vote

PSET2 Readability, most of my code works as expected, but one passage provided below

isalnum has no place here. isalpha checks for letters. Shouldn't matter as we have no digits. The word count is overcomplicated. Per problem specification, anything separated by spaces should be ...
user avatar
  • 20.7k
1 vote
Accepted

Readability program printing the whole sequence of a counted letter/number/word, rather than just the sum

The printf executes for every i because it is inside the for loop. If it should only execute when the for loop is complete, it needs to be outside the block (ie after the closing }).
user avatar
1 vote
Accepted

CS50 Readability - Inconsistency in results

First, L and S should be floating point variables, using type float or double (either would work here). Then, the computation should be using floating point division. Integer division truncates the ...
user avatar
  • 20.7k
1 vote
Accepted

pset2 Readability variables not updating

Do you see anything wrong here? for (int i = 0; i > strlen(text); i++) Will this for loop ever run? Is the test valid?
user avatar
  • 64.1k
1 vote

pset6 (readability) score just 31% upon submitting eventhough program outputs are fine

Do you know the name of the package instead of using sent_tokenize? thanks
user avatar

Only top scored, non community-wiki answers of a minimum length are eligible