Questions tagged [c]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
1answer
50 views

CS50 PSet 4 Recover, Segmentation Fault

My code compiles, but whenever I run Check50, I get a segmentation fault error for each category. Would definitely appreciate any help identifying where the problem can be fixed! #include <stdio.h&...
0
votes
1answer
141 views

pset2 substitution

I was trying to do substitiution on two loops but i had some issues. i found onle loop solution here https://stackoverflow.com/questions/61767483/free-invalid-pointer-aborted-core-dumped-cs50 but now ...
0
votes
1answer
92 views

PSET4 Recover - Can't Read Card

Having a problem with Recover. The debugger shows that "buffer" is always 0000. Tried everything I could think of here. Any ideas? #include <stdio.h> #include <stdlib.h> #include <...
1
vote
2answers
1k views

passing argument 1 of ‘strlen’ from incompatible pointer type

How to make this working? How to properly find the length of these 8 listings? Whenever I execute it gives me following error. *passing argument 1 of ‘strlen’ from incompatible pointer type * #...
0
votes
2answers
245 views

CS50 pset3 plurality program gives error for print_winner function (did not print both winners of election)

I have finished the plurality program for pset3 of cs50, but upon running check50 on my code, I receive the following error directed towards the print_winner function: :) plurality.c exists :) ...
0
votes
1answer
78 views

Pset3 Runoff - Printing All Candidates

Could use some help with Runoff. If I do a simple clear winner (all voters vote for the same person as first choice) it prints out the winner just fine. But if I do the test input that the problem ...
0
votes
1answer
23 views

What's in the bool function parenthesis?

hope everyone is staying safe. I just want to understand what's inside the parenthesis of the vote function in pset3 - Tideman: bool vote(int rank, string name, int ranks[]) What does it mean to ...
0
votes
0answers
52 views

I am having trouble with the 2020 pset4 Recover assignment and even though my code compiles, it doesnt work, its not recovering the images

EDIT: I posted this 17 days ago please help. Heres my code and it wud be great if someone cud help A.S.A.P. thankyou! #include <stdio.h> #include <stdlib.h> #include<stdint.h> #...
0
votes
1answer
80 views

PSET 3 Plurality - Program works but also returns invalid vote?

For those who don't know, this pset is for calculating votes in an election. We were told to code the two functions vote and print_winner, and not to touch any of the other code. The program seems ...
0
votes
1answer
94 views

pset3 runoff print_winner check50 error

So I have seen this issue mentioned here before and the others have suggested that printing a newline after the name is the solution. However, my code does print a newline and in my tests, I'm getting ...
0
votes
1answer
111 views

CS50x Problem Set 4 Blur Function Issue. Does not work on 3x3 or 4x4 image

For some reason, my CS50 pset4 blur function is not returning the proper pixel values for a 3x3 or a 4x4 image. It passes the other check50 tests. I looked at the check50 output, and my code gets the ...
0
votes
2answers
59 views

When printing mario problem the second triangle appears below the first one

#include <stdio.h> #include <cs50.h> int main(void) { //This do while loop checks if user entered number 1-8 int x; do { x = get_int("Height: "); } while ...
0
votes
0answers
32 views

PSET4/filter: Help me see/understand RGB values of individuals pixels in BMP files

Before working on filters in problem set 4, I wanted to make sure I understood the basics. I have downloaded yard.bmp (attached here) and am trying to do simple operations (e.g. use pointers, extract ...
0
votes
2answers
140 views

Caesar doesnt pass “non-numeric key” check

I've read all the other answers I can find about people having a similar problem, but mine doesn't seem to be the same issue. Everyone says to use isdigit first, then use atoi, which is what I've ...
0
votes
1answer
57 views

My code for Caesar gets segmentation error when executed, but in debugger it works fine

I'm getting a segmentation error as soon as I execute this program. I've run it through the debugger and it works fine and outputs the correct ciphertext. There's gotta be something going on in the ...
0
votes
1answer
37 views

Confusion about comparing strings and int/char

This question concerns variables, pointers and addresses as addressed in Lecture 4. I understand that strings are not "real" in the way that integers and characters are, and are just defined as "...
1
vote
1answer
63 views

CS50 Tideman sort_pairs does not work correctly

I have checked my code with a few example and all of them returned the right answer. But when using check50, it tells me that my sort_pairs does not work correctly. Please help me :)! #include <...
0
votes
1answer
118 views

pset1 less comfortable mario

Somebody please help me I have watched the walkthrough thrice, many different videos and searched for answers on reddit and stackexchange yet i've been stuck at this for hours now and cant get through....
0
votes
1answer
256 views

pset2 readability. im getting 8 instead of 7th gread

Anyone knows why i get this error? :) readability.c exists :) readability.c compiles :( handles single sentence with multiple words expected "Grade 7\n", not "Grade 8\n" :) handles punctuation ...
0
votes
1answer
1k views

clang- error: linker command failed with exit code 1

I use the CS50 online IDE and I have the following error: ex1.c:(.text+0x1b): undefined reference to `get_int' clang-7: error: linker command failed with exit code 1 (use -v to see invocation) Code #...
0
votes
1answer
467 views

too few arguments to function call, at least argument 'format' must be specified

I run the C program and I get the following errors. 4:20: error: too few arguments to function call, at least argument 'format' must be specified int x= get_int(); /usr/include/cs50.h:82:1: note: '...
0
votes
1answer
387 views

initializer element is not a compile-time constant and expected identifier or '(' errors

I used the CS50 IDE for C on cloud9. When I run the program I get the errors 3:8: warning: **implicit declaration of function 'GetInt' is invalid in C99 [-Wimplicit-function-declaration] int x= ...
0
votes
1answer
81 views

PSET 4 Filters CS50

void reflect(int height, int width, RGBTRIPLE image[height][width]) { RGBTRIPLE temp[height][width]; for (int i = 0 ; i < height ; i++) { for (int j = 0 ; j < width ; j++...
0
votes
1answer
250 views

pset4 filter - blur - runtime error, colors off

This is my first post; I hope I get the netiquette right. :-) I've been stuck on pset4 / filters / blur for days. The code compiles. When I run it through check50, these two points are correct: :) ...
0
votes
1answer
130 views

PSET5 - Speller - Doesn't display anything past MISSPELLED WORDS

I've been debugging for quite a while now and can't seem to figure out the solution to this problem. When I use the large or small dictionary on any of the texts, the program becomes stuck at ...
0
votes
1answer
89 views

substitution issue non ascii out put

I m turning around...My code works except that the output is non ascii. Coud someone can help ? Thanks :-) #include <stdio.h> #include <cs50.h> #include <string.h> #include <math....
0
votes
1answer
48 views

Caesar 50 , no output!

I am writing code for caesar but when i am executing the program i am not getting any output and when i try to print integer values instead characters it is giving weird integer values, with this i ...
0
votes
1answer
14 views

Array initialilizer must be an intitializer list or string literal

Given this text: include include int main (void) { string text = get_string("Text: "); char num[] = text; } When this is run, it gives the error as stated in the heading of this question ...
0
votes
2answers
30 views

Why does my Switch statement in C trigger prematurely?

Was experimenting with switch statements in C. The goal is for the user to input two number values (n1 & n2) and 1 operator (operator), then using the operator on those two number values to ...
0
votes
2answers
113 views

Why can't I do “string text = get_string();”?

Why can't I do printf("Text: "); string text = get_string(); in order to get a string, text, which contains what an user inputs? I saw Doug Lloyd do something similar in this video: https://www....
0
votes
1answer
46 views

How to identify cause of Segmentation Faults?

Working on problem set 4- Recover but keep getting Segmentation Fault. Tried valgrind too, but could not figure it out. Could anyone kindly anyone look into the code and tell me where does the ...
0
votes
1answer
17 views

Why does my code keep returning 1 with the error message even though I input a digit?

I am trying to complete the Caesar excercise on pset 2. My code compiles fine however it seems to give me me the output Usage: ./caesar key even though I input an int. Any help is much appreciated on ...
1
vote
2answers
209 views

Help with blur filter for pset4! Output image is significantly darker than input

This is the output and input image that my code generates: https://imgur.com/a/mT7YqCD void blur(int height, int width, RGBTRIPLE image[height][width]) { RGBTRIPLE newImage[height][width]; ...
0
votes
1answer
36 views

Try to use += on string to stack char(s) in C

I know it sounds real stupid, but It is cuz I just lightly learned Java and Python last year... now I am try to do C properly with CS50. on week 2, there is Caesar encipher text program task. I ...
0
votes
1answer
73 views

Question for Array in C (with function e.g. set_array)

While I was doing cs50 week2. I found something hard to understand. #include<stdio.h> void set_array(int array[4]); void set_int(int x); int main(void) { int a = 10; int b[4] = {0, 1,...
1
vote
1answer
376 views

PSET2 Substitution - Output seemingly correct, fails check50 (null character?)

thank you for your help in advance! I can't wrap my head around what's wrong with my code as the output is (seemingly) correct. I suspect it has something to do with the null character. #include <...
0
votes
1answer
28 views

How to stop terminal process in CS50 Sandbox? (I've tried Ctrl-C and Ctrl-\)

I'm doing problem set 1 on the CS50 Sandbox, and have ran into some infinitely running programs. When I do ctrl-c or ctrl-\ (I am on mac and have tried both cmd and ctrl), the process still continues ...
1
vote
1answer
578 views

CS50 - Filter - Reflect Image

I am working through CS50's PSET #4, specifically filter -> reflect. I can get the image to present correctly (i.e., it is mirrored), but it is not exact enough to pass the CS50 Check. My code is as ...
0
votes
1answer
65 views

pset4 recover: 'recovered image does not match'

My program recovers the images but the recovered images are all blank and check50 says that they "don't match". All the images are 512 bytes in size. Please help me find out why this is happening. My ...
0
votes
1answer
66 views

pset4 Recover 049.jpg does not match, even though it opens correctly as an image

So, I've been struggling with this bug for a couple days now and can't seem to figure out how to fix it. I've also noticed that the final image file is WAY larger than any of the other jpg's my ...
0
votes
1answer
283 views

Readability in C passes tests on instructions page but when submitting, only 2/11 pass

I've written all of my code and tested that the letter, sentence and word output is counting correctly, which it seems to be. I even tested with all of the sentences on the instructions page and that ...
0
votes
1answer
24 views

How to swap strings?

The main problem comes when we swap strings of unknown lengths. Lets say we have two strings assigned to two variables say a, b. Now if I use a temporary string say c, and use strcpy(c,a), then use ...
0
votes
1answer
556 views

pset4 - filter - sepia: Only red value is consistently correct

So, I currently have this solution for the sepia function of the filter problem. void sepia(int height, int width, RGBTRIPLE image[height][width]) { int b, g, r; // Apply sepia algorithm to ...
0
votes
1answer
275 views

Speller Valgrind leaks bytes + error: munmap_chunk(): invalid pointer error in C

Check50 gives me the munmap_chunk: invalid pointer - it seems I am not copying something right with strcpy. Valgrind gives me: LEAK SUMMARY: still reachable: 608 bytes in 2 blocks ==2864== 56 bytes ...
0
votes
2answers
508 views

Pset2 Readability: Grade calculation wrong

I have just finished doing the Readability problem in pset 2, everything computes correctly except for the final grade. It is always around the -15 or -16 mark. Below I have added only the code I ...
0
votes
1answer
157 views

Plurality - check50 issue

Hoping for some insight on this.. code works perfectly fine, prints correctly when testing in terminal, but for some reason check50 outputs errors once it starts printing winners. Would love to find ...
0
votes
1answer
29 views

Why am I keep getting a segmentation fault in my code for speller every time I run it?

According to valgrind, it says lines 40 and 87 are creating this error. // Implements a dictionary's functionality #include <stdbool.h> #include <stdio.h> #include <stdlib.h> #...
0
votes
1answer
221 views

pset3 runoff segmentation fault problem

I am doing the 2020 version of CS50's pset3 and I am already stuck (again) at the runoff voter function. My code below resulted in segmentation fault. I don't know how to fix this though. So here's ...
0
votes
2answers
20 views

Why does this error keeps popping in my caesar code?

I am doing the caesar exercise for PSET 2 and this is my code: #include <stdio.h> #include <cs50.h> #include <stdlib.h> #include <ctype.h> #include <string.h> int main(...
0
votes
1answer
476 views

Plurality fails to compiles

I always work on Psets on my local machine and replace string with char * so I don't have to use the CS50 library in my header files. This is the only explanation I have for why my code doesn't ...

1 2
3
4 5
11