Questions tagged [c]

The tag has no usage guidance.

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

PS5 speller memory trouble

I have a strange problem with the below code for PS5 speller. I have can match the requested output, it is fast enough, that is all good. However I am having a persistent valgrind issue where I am ...
user avatar
0 votes
0 answers
5 views

Gcc problem - C lang - visual studio code

I recently got into the CS50 course and they begin to work on the C lang, so when I tried to write the same tags and run it on the Terminal it give me ( Gcc is no recognized). Please can anyone helpe ...
user avatar
0 votes
0 answers
17 views

how to prevent input type from being definite type?

i am including cs50 library in my circle calculator so i can get get input from user about operation(circumference/area/volume)then radius,so i want to make sure that first input is number from 1 to 3 ...
user avatar
0 votes
0 answers
10 views

Using CS50's tools on local Windows machine with MSYS2

I am taking CS50's Introduction to Computer Science Course, currently on week "3" - Algorithms. My machine is running windows 10 with MSYS2 for providing the linux like tools. I have tried ...
user avatar
0 votes
0 answers
12 views

edges(pset4) i need feedback and help on my code?

can anyone suggest anything to fix my code cause all i get for output is a black screen. im doing cs50 problem set 4 and im stuck on edges filter. RGBTRIPLE copy[height][width]; copy[height][width] = ...
user avatar
0 votes
0 answers
15 views

I'm having problems using cs50 library

The error i'm getting is (hello.c:2:10: fatal error: cs50.h: No such file or directory 2 | #include <cs50.h> | ^~~~~~~~ compilation terminated. make: *** [: hello] Error 1) I am very ...
user avatar
  • 1
0 votes
0 answers
14 views

Pset3 Tideman, I dont understand why the locked_pairs doesn’t work :(

the last few days I worked very hard on the Pset3. I worked out pretty much all of the functions in the tideman problem. But I just can’t get the locked_pairs function done. I try to fix it but with ...
user avatar
0 votes
0 answers
23 views

How do I return my array of chars in a function to a string in main()

I'm having difficulty implementing the two sections of code for the caesar pset. Individually I have made both my main() and my rotating algorithm caesar() work, but am having trouble combining them, ...
user avatar
0 votes
0 answers
13 views

Code prints correct answer but check50 show errors (Tideman week 3 problem set)

My answer is correct when I ran the code according to the sample test. So I ran checkcs50, but it came back with sorting and locking errors, even though my code is able to print the correct winner. ...
user avatar
0 votes
0 answers
6 views

How can i allocate memory in the heap without loosing data?

I am writing a text game and my task is to create a function that allocates space in memory for a new game item and returns a reference to it. The task says that the name and description parameters ...
user avatar
0 votes
0 answers
13 views

Valgrind Error Conditional jump or move depends on uninitialised value(s)

I am not sure what it means can someone help please ==3324559== 1 errors in context 1 of 10: ==3324559== Conditional jump or move depends on uninitialised value(s) ==3324559== at 0x400C76: ...
user avatar
  • 1
0 votes
1 answer
89 views

Cant get Codespace to work

Im up to the "Hello" module, week 1. Ive never programmed before so setting up copespace has been quite frustrating. I cannot get it to work. Can someone please help me? I want to get ...
user avatar
1 vote
1 answer
42 views

VS code malfunction

On this morning when I open my vs code I found this suddenly pop out. I ignore it and start coding. Afterward I found that I can save my codes, so I code it in notepad and I save it to vs code using ...
user avatar
0 votes
0 answers
19 views

Solve this c Problem

Implement a function in C to check whether the number is Armstrong or not. A positive integer is called an Armstrong number (of order n) if abcd... = a^n + b^n + c^n + d^n + ... where n is the number ...
user avatar
  • 1
0 votes
1 answer
27 views

Undefined reference to main, why? (C)

getting undefined reference to main but not sure why. The code is the same as the guy in the lecture but it seems to not work while his does? im very new, and very stupid..
user avatar
0 votes
2 answers
160 views

CS50 Plurality Check50 "print_winner function did not print winner of election"

I'm having issues with the plurality assignment for week 3. Even though it works during my testing check50 is saying it doesn't print the winner of the election. I'll acknowledge my code could ...
user avatar
0 votes
1 answer
25 views

Function returns not working for CS50 readability.c

In CS50 we now have to make multiple functions (I guess they want us to get used to objective-oriented programming for the python part later) and return the value to the main function. When I execute ...
user avatar
0 votes
1 answer
167 views

Why are the CS50 header and Make aren't working?

yesterday I installed Ubuntu on my Windows 10 PC so I can install the CS50 library and use Make as well and I have been trying to diagnose the problem since, when I add #include <cs50.h> to my C ...
user avatar
  • 1
0 votes
0 answers
6 views

this is just some part of my code ... I keep getting an error saying needs an expression ..... my assignment is due in 4 hours T_T

printf(" | Coffee | Coffee | Packaged | With | Serving \n"); printf(" | Type | Grind Size | Bag Weight | Cream | Temprature \n"); ...
user avatar
1 vote
0 answers
21 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 ...
user avatar
0 votes
0 answers
132 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 ...
user avatar
0 votes
1 answer
108 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 ...
user avatar
0 votes
0 answers
56 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 ...
user avatar
  • 3
0 votes
1 answer
15 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 ...
user avatar
0 votes
0 answers
66 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, ...
user avatar
  • 1
0 votes
1 answer
26 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. ...
user avatar
0 votes
1 answer
36 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"...
user avatar
0 votes
0 answers
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> #...
user avatar
0 votes
1 answer
27 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 // ...
user avatar
  • 7
0 votes
1 answer
26 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 ...
user avatar
  • 101
0 votes
0 answers
25 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 ...
user avatar
  • 1
0 votes
1 answer
117 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 < ...
user avatar
0 votes
0 answers
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 ...
user avatar
  • 1
0 votes
1 answer
52 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,...
user avatar
0 votes
2 answers
18 views

for- loop stop if output A

on pset2/caesar and only when ciphertext[i] = A or a for loop stopped ????
user avatar
0 votes
0 answers
16 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]....
user avatar
0 votes
1 answer
71 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 <...
user avatar
1 vote
1 answer
20 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(...
user avatar
0 votes
0 answers
27 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 ...
user avatar
0 votes
1 answer
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?
user avatar
  • 3
1 vote
1 answer
36 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-...
user avatar
1 vote
1 answer
45 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 ...
user avatar
  • 13
0 votes
1 answer
42 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 -...
user avatar
  • 1
0 votes
1 answer
14 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][...
user avatar
0 votes
1 answer
21 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, ...
user avatar
0 votes
1 answer
69 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&...
user avatar
0 votes
1 answer
44 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 ...
user avatar
0 votes
1 answer
21 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?
user avatar
  • 3
1 vote
1 answer
54 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++)...
user avatar
0 votes
1 answer
37 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 ...
user avatar

1
2 3 4 5
12