Questions tagged [c]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
0answers
6 views

Lab 4 not altering output file - using solution word for word

I have looked at all the solutions here on the exchange. I have two issues. Firstly: const int HEADER_SIZE = 44; This does not work for me in the context of initializing a header array. I either have ...
0
votes
0answers
12 views

get_string() C function not working

I just began CS50 and was trying to copy some of the examples done on the lecture video. I use opensuse tumbleweed(also a little new to it) and I had installed the cs50 c library just as the ...
0
votes
1answer
20 views

How do I get rid of the "expression result unused" error?

I am trying to get it to where if input "n" and "x" are the same number it will display "years = 0" if not it will run else statement. Instead it was running both the if ...
0
votes
0answers
17 views

PSET1 Credit error mistake

Hope this finds you well. I am having a little bit of trouble with PSET 1s credit problem, the code compiles fine but when running check50 it gives me a few errors. I tested one of the errors, where ...
0
votes
1answer
13 views

What is the problem with my get_int for the lab 1 question population in C?

when i make the code and i type ./population, the question asked is start size:, and when i type in an x value that is 9 or more, the question keeps reprompting and I keep looking through and I don't ...
0
votes
0answers
13 views

lock_pairs did not correctly lock all non-cyclical pairs

this is my code within the lock_pairs function for the tideman problem in pset3. I've looked through it numerous times and I can't find anything wrong with it. However, when I run it through check50, ...
0
votes
1answer
23 views

pset4 filter edge corner pixel problem

When I run check50 I am failing for checking the corner pixel as well as 3x3 and 4x4 image. No matter how long I stare at my code I just can't see the problem. Any help is greatly appreciated. ...
0
votes
1answer
16 views

Why the pixels are not rendering correctly in recover problem?

I am working on recover problem and suffice to say I am just a beginner. Here is my code: #include <stdio.h> #include <stdlib.h> #include "stdint.h" #include "stdbool.h"...
0
votes
0answers
16 views

C code wont run. can you help? telephone directory

can you please help me figure out why my code won't run. I do not understand the errors. please help. its suppose to be a working telephone directory #include<stdio.h> #include<stdlib.h> #...
0
votes
1answer
25 views

I have no idea why my speller in pset5 is giving the wrong amount of misspelled words

I am not sure where my mistake is, I keep getting too many misspelled words. This is the link to check 50 I run on the code: https://submit.cs50.io/check50/ce552ed87b7d99ac966d9ba7a897bda34bf0a794 // ...
0
votes
1answer
15 views

Plurality exercise - error messages

I am trying to do the Plurality exercise for problem set 3, but when I type this to test it, I get errors even though I believe my program looks correct. check50 cs50/problems/2021/x/plurality I get ...
0
votes
0answers
18 views

CS50 PSET3 Tideman Help!

I'm having a little trouble with the add_pairs function because the pairs array refuses to store numbers. I used printf to corroborate the values that were being recorded, and the i and j ints don't ...
0
votes
1answer
14 views

Helping with Valgrind "Conditional jump or move depends on uninitialised value(s)" in simple C code

So right now my code seems to me like it doesnt have issues, it looks like this: int i; char hello[] = "Hello World!"; char * str = malloc(strlen(hello)+1); for(i = 0; i < ...
0
votes
0answers
9 views

pset4 blur, tried this method, I can't figure out what is the problem with my code

It compiles, and passes the check for pixels in the corner, but fails every other test, before I added the logic for the corners and edges it passed the test for the middle pixels also. I can't ...
0
votes
1answer
27 views

Use of undeclared identifier 'num'

I dont really know where im wrong. it gives me "use of undeclared identifier 'num'" i allready tried to solve it but i have no clue of what is going on #include <stdio.h> int maxc = 0,...
0
votes
2answers
18 views

for- loop stop if output A

on pset2/caesar and only when ciphertext[i] = A or a for loop stopped ????
0
votes
0answers
13 views

Pset3: Tideman - Sort_pairs

Check50 says that my sort_pairs function is wrong, but with the tests I've used, everything is alright. Here's the code: void sort_pairs(void) { int biggest_strength_of_victory = preferences[pairs[0]....
0
votes
1answer
23 views

How to convert an unsigned char to a string?

I'm needing to collect byte by byte of an unsigned char and convert it to a string, how can I do that? I've tried everything but it didn't work. My example code: #include <stdio.h> #include <...
1
vote
1answer
17 views

Mario problem: Program got stuck at user input

// ** Below is the code of mario pset1, its taking input of width multiple times and not executing step after input// #include <cs50.h> #include <stdio.h> #include <math.h> int main(...
0
votes
0answers
22 views

Why do Escape Sequences in C work differently when I compile code by using GCC?

Why do Escape Sequences in C work differently when I compile code by using GCC? For example, Input: #include <stdio.h> int main(void){ printf("Hello world\n"); } Output in CS50 ...
0
votes
1answer
21 views

How does the CS50 IDE recognize C functions in advance?

I notice that functions like printf() and toupper() appear in blue without the relevant #include statements in files with names ending in .c. What is happening under the hood to make this happen?
1
vote
1answer
31 views

'stadio.h' file not found

#include <stadio.h> int main(void) { printf("hello, world"); } when i type make hello clang -ggdb3 -O0 -std=c11 -Wall -Werror -Wextra -Wno-sign-compare -Wno-unused-parameter -Wno-...
1
vote
1answer
34 views

Unable to confirm user input is a number using isdigit in c

My code is attempting to; take user input from the command line; check if the input is a whole number; confirm positively if so; confirm negatively if not; however all numbers return a negative ...
0
votes
1answer
12 views

error : function definition not allowed here pls help

i got this error message pls help $ make triangle clang -ggdb3 -O0 -std=c11 -Wall -Werror -Wextra -Wno-sign-compare -Wno-unused-parameter -Wno-unused-variable -Wshadow triangle.c -lcrypt -lcs50 -...
0
votes
1answer
13 views

pset2//caesar : strspn result

I'm struggling to understand : (argc != 2 || argv[1][strspn(argv[1], "1234567890")]) It works, but I'm trying to understand what's going on inside the if evaluation, and the value argv[1][...
0
votes
1answer
18 views

function output?

I can't get this function to output the desired value of 0.07. #include <stdio.h> #include <cs50.h> #include <math.h> float i = 1.32; float quar_val = 0.25; int func(float val, ...
0
votes
0answers
21 views

CS50 Speller: valgrind test says that bytes are still reachable in 3 blocks

I'm currently at the CS50's pset5, and am working on the "Speller" problem. I managed to do all functions and don't have any compile or runtime errors. When using check50, though, I receive ...
0
votes
1answer
53 views

pset4 filter blur less got stuck

i have been working on blur and it works just fine as i run it. but when i run check50 i get this : :( blur correctly filters middle pixel expected "127 140 149\n", not "145 160 169\n&...
0
votes
1answer
37 views

credit pset1 cs50 sum while loop

I was doing the credit problem with the visa test card in the page: 4003600000000014 It passed that test, however in other tests it doesn't pass. I think it's a matter of the sum that it can't compute ...
0
votes
0answers
11 views

Cannot Compile CS50 Library

I've been running into this problem lately. Here's one of my code: #include <cs50.h> #include <stdio.h> #include <string.h> // ... for (int i = 0; i < voter_count; i++) { ...
0
votes
0answers
9 views

Library = Collection of functions?

do I understand it right, that in that library there are only a collection of functions inside that i can use?
0
votes
1answer
17 views

Why is an Array longer then the input?

why we can access more information than the lenght of the array? I thought that after the Null (0) the array ends. Why we can access position 40?
1
vote
1answer
44 views

CS50 - PSET 4 - Filter - Edges

//Pixel buffer RGBTRIPLE pixelBuffer[height][width]; //Iterates on every pixel and calculates Gx and Gy for (int i = 0; i < height; i++) { for (int j = 0; j < width; j++)...
0
votes
0answers
6 views

Error with calculating Egdes in Pset4 Filter (More) Detect Edge problem

// Detect edges RGBTRIPLE new_pixel(int i, int j, int height, int width, RGBTRIPLE image[height][width]) { int redx; int bluex; int greenx; int redy; int bluey; int greeny; ...
0
votes
1answer
35 views

PSET4 RECOVERY does not recover images correctly

I have started working on PSET 4 RECOVERY. My program compiles successfully, it goes through the first 3 tests no problem, but for the love of me I cannot seem to find the problem. It just does not ...
0
votes
3answers
19 views

Error retrieving return values ​from a function

I am currently studying coding in C language and I have doubts about the return of functions, what I am trying to do is the following: Call the number () function and pass 3 values ​​of the integer ...
0
votes
1answer
25 views

Recover PSET4 Corrupt images

i was working on pset4 recover and my code finds all the image, but everytime it writes to the image the image got corrupted, and i cant find the issue, checked the debugger and it seems going the way ...
0
votes
1answer
25 views

Help to finish my problem - Check50 - Pset4 - Filter Less

I am coding the sepia filter, it is already working, but it does not pass the check50. I think of according to the check50 report, that there is some problem of precision in the calculations, but I ...
0
votes
1answer
60 views

pset4 - (Filter Less ) - Doubts with malloc()

I'm performing the problem set from pset4 to the (filter less) part. I wish to use malloc() to my advantage to speed up image filtering and maybe check50 will accept my solution to the problem. I ...
1
vote
1answer
50 views

Recover - segmentation fault and other general problems

Hey guys so I've hit a bit of a wall with Recover, when I run my program I get segmentation fault but I also don't know how to end off one jpeg when another header pops up? In essence, I'm not sure ...
1
vote
1answer
65 views

Lecture 5 Linked Lists: What's going on under the hood?

Sheepishly I must admit I am having difficulty understanding how Linked Lists are implemented. Spent an hour and a half just on this part. The following partial code is from the lecture (comments ...
0
votes
1answer
80 views

PSET3 Tideman - What to do with the lock_pairs function?

Can someone please help me with the lock_pairs section of the problem? The lock_pairs function is killing me. I get that you have to compare the pairs to each other and then return false or true in ...
0
votes
1answer
35 views

PSET 1 Credit Card Checksum doesn't add up

I'm having my issues finding the right answer as this is non code related. The checksum says: "If the total’s last digit is 0, the number is valid!" This is a credit card number that is ...
0
votes
1answer
24 views

question on Week 1 lecture

I just have a small question. David showed how to compile the source code "Hello.c" file using the make command to make the executable machine code file "Hello" in the lecture. I ...
0
votes
1answer
73 views

Credit (Pset1) - Checksum problem

so I have a problem with the Credit exercise from pset1. I updated my code today after realizing that I didn't split up the digits of the product of the current digit in the card number and 2 and ...
0
votes
1answer
13 views

Command debug not found

when I try to run the command debug debug ./scores the message that returns is that : Command 'debug' not found
0
votes
2answers
46 views

stuck on readability pset2

Hi I am stuck on readability and am not sure what i am doing wrong $ ./readability Text: one fish. two fish. red fish. blue fish 8 3 42 13 Grade 13 and my code: #include <stdio.h> #include <...
0
votes
1answer
649 views

Lab 8 // Resetting button colors not working properly

I am doing the lab 8 trivia question and I am try to reset all the colors of the buttons when you press another from the rest. I am not sure how to do it. I have the function for resetting the colors ...
0
votes
1answer
25 views

PSet3 Tideman , error with updating ranks array

bool vote(int rank, string name, int ranks[]) { for (int i = 0; i < candidate_count; i++) { if (strcmp(name, candidates[i]) == 0) { ranks[rank] = name; ...
0
votes
1answer
23 views

I have included all the libraries, yet it shows errors (pset2)

This is my code: #include <stdio.h> #include <cs50.h> #include <stdlib.h> #include <string.h> #include <ctype.h> int main (int argc, string ...

1
2 3 4 5
12