# Tag Info

Accepted

### Pset3 Helpers.c Frequency Not Working

For "A4", this returns 440 for me. Note that C's ^ operator is bitwise XOR, not power. Also, in C, 1/12 equals 0 (integer division truncates, you could avoid this by using floating point values like ...
• 21k
Accepted

### Problem with pow() function, int frequency, helpers.c, pset3, music

(pow(2, index / 12) the issue is that both index and 12 are integers, so with integer division, the result will always be a whole number. Try using 12.0 instead of 12 to force a floating point ...
• 18.7k
Accepted

### control reaches end of non-void function

This error message means "Your function is declared as returning a value of type int, but it's possible it might return not at all". Make sure control flow always ends in a return statement. Have ...
• 21k
Accepted

### Pset3 Music - Issues with bool is_rest function

Hmmm.... Re: bools being returned - While 0 always means false, the case for true varies for different languages. Some interpret only 1 as true. In c, any non-0 number (including negatives) are ...
• 69.1k

### Returning an int always returns 0

You might try printing out the values in numer, denom and result from inside your function. I'm highly suspicious of the following line: int result = ((numer / denom) * 8); Since numer and denom ...
• 69.1k
Accepted

### Music frequency accidental and note issue

When you write 9/12, that's an integer division. Integer division results in an integer again, truncating the result. You want a floating point division instead. For that, make at least one of the ...
• 21k
Accepted

### is_rest() and duration() bugs in helpers.c of Pset3 Music

The duration problem is based in the integer division of the formula. int num8 = (numerator/denominator)/(0.125); It's doing integer division of numerator/denominator. In regular division, this ...
• 69.1k
1 vote

### Need help with Frequency in pset3. Been stuck for a while

IMPORTANT NOTE This exercise is not included in CS50x 2019. The courseware changed at the beginning of 2019; music has been retired. Which is not to say you shouldn't persevere. But as far as I know, ...
• 28.5k
1 vote

The error message usually means that you are writing something outside a function that is not allowed there. We would need at least line 90 and probably also the lines around to find the mistake in ...
• 21k
1 vote
Accepted

### pset3 music - value inf is outside the range of representable values of type 'int'

In digit = note[1];, you assign a digit character, but you meant the value associated with the digit. Similar to caesar, you can subtract '0' to convert digits '0' to '9' to numbers 0 to 9. String ...
• 21k
1 vote
Accepted

### PSET3 Music problem: \377

Wow. Such a complex implementation using almost every string function. For example, in strstr(note,"b") > 0 you already know that only one character could be 'b', so this could as well be note[1] ==...
• 21k
1 vote
Accepted

### PSET3: Music, getting this error 'expected exit code 0, not 1'

You say that your submission failed at this point: :( helpers.c compiles Log running clang -std=c11 -o is_rest is_rest.c wav.c helpers.c -lcs50 -lm... checking that program exited with status 0... ...
• 1,009
1 vote
Accepted

### music pset - semantic error

The part of this question which is easiest to understand is the part about your implementation of get_string(). The function get_string{} is supposed to return as soon as the user inputs a string. ...
• 1,009
1 vote

### Pest 3 Music frequency

accidental is an int so accidental/12 will return an int (not a float). Change that to 12.0 to force floating point division.
• 18.7k
1 vote

### please help! I've been trying to find out whats the problem in this code for a very long time now... its not even compliling .. #pset3 cs50 #music

For starters, get rid of all the spaces in the include statements inside the < brackets>. That'll leave one typo, a misspelled word, to be fixed so you can compile. Then take a deep breath and ...
• 69.1k
1 vote
Accepted

### PSET3 - MUSIC - check50 not recognising enharmonics

strcmp is the wrong tool to compare characters (and strings must end in a null terminator, which your &acc... maybe, by accident, does if there's a null byte after the variable). Just use if (acc ...
• 21k
1 vote
Accepted

### Pset3 - Music: Unused parameters and control reaches end of non-void function errors

There are a few simple issues. First, octave is being declared and then redeclared, but, amusingly, that isn't the actual problem. The real problem is that they are being declared inside of code ...
• 69.1k
1 vote
Accepted

### pset3/music/helpers.c - "no makefile found"

You're on the right track, but I suspect your file structure isn't right, or you've misinterpreted something wrong. All of the code files, *.c, *.h, the Makefile and the songs directory should be in ...
• 69.1k
1 vote
Accepted

duration always returns 392. 4 is not the same as '4'. The latter is an ASCII character of value 52. You don't need atoi to convert a single digit character, just subtract '0' like you probably ...
• 21k
1 vote
Accepted

### Why are these if-else statements not letting my program compile?

Look at the following code: if(octave == 4) { if(note[0] == 'A' && accidental == '#') answer = (440 * pow((double)2, (double)1/12)); return answer; else if(note[0] == ...
• 69.1k
1 vote
Accepted

### is my implementation of is_rest correct?

First, you confuse = assign operator and == equals operator. This is still valid (though nonsensical) C code, as = in C forms an expression, and its value is the assigned value, so it can be tested ...
• 21k
1 vote
Accepted

### Pset3 music - load of null pointer of type 'char'

One thing to check is your is_rest. If you mess up there, you might pass garbage (here: a NULL pointer) to the other functions when there's an actual rest line. A rest line is specified by an empty ...
• 21k
1 vote

### Pset3 Music - "unused parameter" and "reaching end of non-void function"

for (fraction[0] == 1) This is an incorrect use of a loop, I think it worthwhile to read thoroughly about the for loops, you have a boolean value within a for loop that is effectively not used. Maybe ...
• 5,179
1 vote
Accepted

### the code always returns 1 and also when i compile it, there is a long message

Note that switch-case in C will run any code starting with the first condition that applies. This makes it possible to have code like switch(num) { case 1: case 2: case 3: printf("...
• 21k
1 vote

### signed integer overflow

The issue with this was that I have signed char to int and havent changed anything. I asummed that if char is 4 that the int will be also 4 but it is not (its 52) so that's why my loop was giving so ...

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