Questions tagged [c]

The tag has no usage guidance.

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

reading a file into a struct in c

i'm new in c programming and i want to learn read file into a person struct then printing all informations ( no, name, lastname ) in ascending manner. Can anybody help me?
0
votes
2answers
12 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
18 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
22 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
32 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
13 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
27 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
29 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
22 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
17 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
35 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
10 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
26 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
145 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
14 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
17 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 ...
0
votes
2answers
49 views

Speller.c, get correct result on my machine, wrong on check50

Good day, I am struggling with speller.c. When I run the program on my machine I get the correct result compared to the keys but then when I use check50 to check I get all wrong. I have narrowed the ...
0
votes
2answers
28 views

Check50 accepts all but last 2 tests. pset1/credit

I've been trying to fix this on my own for a bit but I wasn't able to find an answer online. My credit program passes all check50 test's except for the last two (identifies 4111111111111113 as INVALID ...
0
votes
1answer
63 views

My do-while loop does not work

do { number = get_long_long("What is your credit card number? "); } while((number < 1000000000000) || (number >= 10000000000000000)); This loop is not accepting inputs. I do not ...
0
votes
2answers
34 views

What modification do I need to shorten my code?

I have come up with the following code to solve caesar.c of pset2. It passes all check50 tests. However, it fails to detect when a string input is not a number. The way I understand it, I have to ...
0
votes
1answer
22 views

Why is my if else statement not working?

Here's my Code: #include<stdio.h> #include<cs50.h> int main (void) { string a= get_string("Enter a name\n"); string b= get_string("Enter Class\n"); ...
0
votes
1answer
55 views

I don't understand the comments from check50 on my lab 1 submission. could anyone help please?

This is my code #include <cs50.h> #include <stdio.h> int main(void) { // TODO: Prompt for start size int s; do { s= get_int("Start size: "); } ...
0
votes
1answer
33 views

pset4 Blur calculation does not work properly

for some reason I can't get my calculation for the blur value running. The pictures are really odd and contain crazy colors. Any ideas to why this could be the case? I compared it already to working ...
0
votes
1answer
40 views

Mario less, struggling with nested FOR loop

hello I have got my code to work but don't understand logic, I found a flow cart for how nested for loops work and with that I was able to mix things around until I got it to output correctly but ...
0
votes
1answer
15 views

How can i arrange the output in decending order In this program? [closed]

#include <stdio.h> int main() { int n,i; printf("Enter a number: "); scanf("%d",&n); for (i=0; i<=n; ++i) { if (i%(7*13*19)==0) { ...
0
votes
1answer
17 views

Why is my get_positive_int code not working? (I seem to do everything right!)

Here's my code (written in C), I was trying to program this for a long time, and even when I just tried to copy the code directly from the video lecture, it's wrong! Please help me. Here's my code: #...
0
votes
1answer
6 views

Caesar - ASCII to char conversion problem

Going through the CS50 exercise Caesar, and I'm still very new to C. My code to validate the key is all working, but as I try to convert from plaintext to the cipher text I keep getting caught up with ...
0
votes
1answer
22 views

pset4 recover creates 50 images but bytes don't match up

My code creates the 50 files, all of them starting with the correct JPEG signature, however the rest of the bytes don't match up. In other words, first 4 bytes are correct, the following bytes are ...
0
votes
0answers
9 views

Pset4_ Blur: (more comfortable)Problem, I think there is a small bug, but I can't find it

I was working on my code(sorry for it being so long), then I kept getting the same error and I don't understand why :) blur correctly filters middle pixel :) blur correctly filters pixel on edge :) ...
0
votes
1answer
33 views

Pset3 Tideman: Why is my sort_pairs function not working?

I'm green on all the criteria before sort_pair. Here's my code so far: // Sort pairs in decreasing order by strength of victory void sort_pairs(void) { // TODO // Create array of strengths of ...
-1
votes
2answers
24 views

while (n<1) --— Why?

Week 1 - mario exercice. Into the program below , I do not understand why while (n<1) As width is a positive value, n shouldn't be >1 ? -----------------------------------------------------------...
0
votes
1answer
23 views

String to Char in C

How can I convert a String to a Char in C? Please help. I am unable to do that and I need it urgently. I need it for readability.
0
votes
0answers
20 views

Help, doe not working - cash [duplicate]

Can someone please help me, as much as I think it should give the least amount of coins needed but it is not.
0
votes
1answer
35 views

Code not working - cash

Can someone please help me, as far as I think this code should give back the number of coins needed but it is not working.
0
votes
1answer
14 views

Seg fault (storing file pointer as NULL initially maybe?)

// img file pointer FILE* img = NULL; char* file_name = NULL; int file_count = 0; int bytes_written = 512; // repeat until end of memory card while (bytes_written == 512) // ...
0
votes
2answers
34 views

Blur look correct but check50 says its not?

See my check50 results here // Blur image void blur(int height, int width, RGBTRIPLE image[height][width]) { RGBTRIPLE tmp_image[height][width]; for (int y = 0; y < height; y++) ...
0
votes
1answer
15 views

reflect for cs50. Trying to reflect an image, but only the first row pixels is swaped

So, my task is to reflect image pixel by pixel to make a mirror image. Here is my original code for the function void reflect(int height, int width, RGBTRIPLE image[height][width]) { int tempr, tempg, ...
0
votes
1answer
19 views

how can I rewind the fread() funtion as byte

is there a way to fread() the same bytes you just had read? fread(buffer, 512, 1, inptr); if (header(buffer) == true) { //execute these lines do { //execute these lines } ...
0
votes
1answer
36 views

Pset 4 Filter(less) Blur

I'm having an issue with the counter variable of my code. I wrote a printf to see if it returns 4, 6, or 9. Which is what it should do, if my IF conditions are correct. Unfortunately it does not ...
0
votes
1answer
108 views

pset3 tideman lock_pairs: why does “lock_pairs locks all pairs when no cycles” fail?

My code fails at check50 but I can't understand why. It that seems my code actually finds cycles, but also produces false-positives (I guess). check50 output for the lock_pairs function: :( lock_pairs ...
0
votes
1answer
13 views

I finally got my code to work but now I can't submit it can anyone tell why?

tps://i.stack.imgur.com/SvfAI.png
0
votes
1answer
59 views

pset1 credit: I am unable to identify what's wrong in the logic of my code?

Kindly tell me what mistake have I made in this program? pset1 Credit: (my code) https://pastebin.pl/view/5646dbf1
0
votes
1answer
66 views

pset3 tideman cs502020 locked pairs error

I am new to coding and I am trying to solve the locked pairs part of the Tideman problem. Currently, I am receiving the following two errors: :) lock_pairs locks all pairs when no cycles :( lock_pairs ...
0
votes
1answer
18 views

What is the purpose of subtracting 1 while inside a increment? [closed]

I am confused about the code below ++counts[number-1]; What is the purpose of subtracting 1 in this code? The entire code: #include <iostream> #include <iomanip> #include <ctime> #...
0
votes
2answers
47 views

Check50 all green but my own tests fail

I completed Runoff with 100% pass in check50 but when i do my own tests i get wrong winners. I checked everything to the best of my abilities but i just can't find the problem and it's driving me ...
0
votes
1answer
107 views

cs50 array initializer must be an initializer list

i have started coding in c but i keep getting errors i don,t know how to solve maybe it is because i am used to coding in php language but i hope anybody can help me #include <stdio.h> #include &...
0
votes
1answer
10 views

Strange CL output

I was testing my code to see if the command line argument's characters are digits but after plugging a random argument that was a mix of letters and numbers, I obtained a strange output. See what you ...
0
votes
1answer
25 views

Pset 2 - Readability -> Wrong grade

I'm having problems with the Pset 2 problem: readability. The goal of exercise is to implement a program that computes the approximate grade level needed to comprehend some text using the Coleman-Liau ...
0
votes
1answer
61 views

Error: function definition is not allow here What error is this?

main.c:10:24: error: function definition is not allowed here int read( int a[9][9]){ ^ main.c:36:24: error: function definition is not allowed here void show(int a[9][9]){ ^ main.c:58:24: error: ...
1
vote
2answers
78 views

pset2 - readability - grades slightly off

I have a problem that I have not been able to diagnose on my own or by perusing this stack overflow. The the tests are here. All of the index values are correct except for the grade seven sentence ...

1
2 3 4 5
11