[Solved] Every time I start the project always just writes that ” THIS IS NOT VALID” even if the numbers that I give are right [closed]

You are casting (bool) valid_triangel the address of the function instead of calling it. This will always be non-NULL and the corresponding true branch of the if condition will be executed irregardless of input. (non-issue) I don’t have cs50.h installed so I wrote a quick get_double() to test your code. Removed the declaration of valid_tringel() … Read more

[Solved] Program keeps returning Segmentation Fault [closed]

(1) isalpha(argv[1]) is wrong. This function expects a single character, but you are passing a pointer-to-string. That will certainly not give you any kind of expected result, and it’s probably Undefined Behaviour into the bargain. You either need to loop and check each character, use a more high-level library function to check the entire string, … Read more

[Solved] Tideman CS50 C++ Sort function [closed]

This is taking the pairs by value: void swap (pair a, pair b) // a is a copy of pairs[i] and b is a copy of pairs[j] The change you make to a and b inside the function will be discarded when the function exits. a and b are local to the function only. Take … Read more

[Solved] Tideman CS50 C++ Sort function [closed]

This article provides a solution to the Tideman CS50 C++ Sort function. The Tideman Sort function is a sorting algorithm used to sort a list of elements in order of preference. It is a variation of the bubble sort algorithm and is used to rank candidates in an election. This article provides a step-by-step guide … Read more

[Solved] Vigenere Cipher Black Hawk Down

I think your calculation is wrong: You currently have encryptedLetter = (letter – firstLetterOffset) + key[position % keyLength] % 26 + firstLetterOffset by check the C operator precedence table we notice that % is evaluated before – or +, meaning that your code actually mean : encryptedLetter = (letter – firstLetterOffset) + ( key[position % … Read more

[Solved] I have a segmentation fault and am unsure about what is wrong with my code

The problem is obvious now you’ve said on which line the code crashes. Consider these lines… char *word = NULL; int i = 0; //index FILE *dictionaryTextFile; dictionaryTextFile = fopen(dictionary, “r”); //scan for word while(fscanf(dictionaryTextFile, “%s”, word) != EOF) You’ve got 2 problems there. Firstly, you don’t check that the call to fopen worked. You … Read more

[Solved] Re-prompting a user until he/she enters a positive integer value greater than 1

You can solve this by reading a string first, and then extracting any number: #include <stdio.h> int main(void) { int length = 0; char input[100]; while(length <= 0) { printf(“Enter length: “); fflush(stdout); if(fgets(input, sizeof input, stdin) != NULL) { if(sscanf(input, “%d”, &length) != 1) { length = 0; } } } printf(“length = %d\n”, … Read more

[Solved] What Does “Error: Variable is used unitialized Whenever “if” Condition is False” mean? [closed]

You’re getting this warning because there are code paths where key is not set and subsequently used. The isupper and islower functions are not opposites, e.g. a false return value from one doesn’t imply a true return value from the other. For example, c contains the character ‘0’, both isupper and islower will return false. … Read more

[Solved] Usage of uint_8, uint_16 and uint_32

In your 3 cases, before the printf statement, the 4 first bytes of the arr array (in hexadecimal format) are: FF D8 FF E0, which corresponds to 255 216 255 224. Here are explanations of each case: arr[0] has uint8_t type, so its 1-byte value is 0xFF, so printf(“%i”, arr[0]); prints 255, which corresponds to … Read more