Questions tagged [c]

The tag has no usage guidance.

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

Pset2: Vigenere Cipher, wrong output

In the following code there is no compiling error, but it does something wrong, as it gives me a wrong output. What it is supposed to do is: when the key is 'a' and the plaintext is 'a', output 'a', ...
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
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
1answer
65 views

Pset1 Creating and Changing Directory Does Nothing

For the first problem set, I attempted to create and change the directory with the following commands: $ mkdir ~/pset1 $ cd ~/pset1 $ mkdir ~/pset1/hello $ cd ~/pset1/hello Despite doing these ...
0
votes
1answer
104 views

pset2 How to get rid of spaces in the end of the milo banana_ _ _ _ (input)?

How to get rid of spaces in the end of the input? My code works perfectly with _ _ milla_ _ _ banana But I have issues with the case if _ _ _ milla_ _ banana_ _ _ when I have spaces in the end How ...
0
votes
2answers
25 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
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
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
72 views

pset2 vigenere. My code handles text inconsistently

I've got it working nearly perfectly. It works if the text is in lowercase, but I see that it's not working quite right when using uppercase. In check50 it only fails with lowercase: encrypts "BaRFoo"...
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
81 views

Recursive Binary Search Exit Code Errors

I wrote the following recursive binary search function. No matter which exit codes I use (e.g., true, false, 1, 0, -1, "Swedish Chef"), I fail at least two of the checks I need to pass. The code ...
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
107 views

Game Of Fifteen Won Function

my won function for Game of Fifteen does not exit. check50 says it timed out waiting for the program to exit. My other functions for game of fifteen seem fine. Help would be appreciated! bool won(...
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
26 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
18 views

Find hex values inside a string in C?

I have a long string "given_string", and I'm trying to find hex values within that string. Here's a simplified example: /* Find a sub-string in a given string: */ char * given_string = &...
0
votes
3answers
136 views

FIFTEEN works perfectly but doesn't pass Check50

My program works perfectly. Though, my Check50 says that my program only compiles and runs, nothing else. I think this has to do with my draw function, but I can't spot the mistake Can anyone help me ...
0
votes
1answer
115 views

Problem with my credit.c code

My credit.c code keeps inserting huge numbers in my array for seemingly no apparent reason. For example the user enters 45231 for the credit card number, the beginning of the array is fine and ...
2
votes
4answers
932 views

How can I get the cs50.h to run in Visual Studio Code?

I downloaded both the cs50.c and cs50.h files from GitHub and put them in the folder where all the header files are. VSC even recognizes the #include <cs50.h> in the code but I get the error in ...
1
vote
2answers
1k views

pset3 (runoff) keep getting print_winner error when using check50

I keep getting these errors when running check50 on my runoff program: print_winner prints name when someone has a majority print_winner did not print winner of election print_winner returns ...
0
votes
2answers
519 views

While Loop in C only executing once and then stopping

I have created a function in C that tests if an integer in between a range of 100 (min) and 500 (max) - The function calls on another function called "getInt()" which tests whether the integer is ...
0
votes
1answer
27 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
120 views

incompatible pointer types passing 'string' (aka 'char *') to parameter of type 'string *' (aka 'char **')

Im writing a funtion that takes string as a argument and gives back a integer. This function counts lenght of a string entered at the command line argument. I get an error :" incompatible pointer ...
0
votes
1answer
347 views

Pset5 speller: how can I navigate through the Trie and free the nodes?

so I am stuck on this PSET5 speller for a quite while now, trying different approaches, looking at available information in CS50, shorts, pset problem explanation and I couldn't get to free all the ...
0
votes
2answers
139 views

Why isn't my block on pset1 turning into a staircase?

I am currently working on pset1 Mario, less comfortable. I am running my c to turn the hashtags into a staircase, but when I run the code, it is only a block. What is wrong with my code? Thank you all ...
0
votes
2answers
124 views

How to submit a Pset without appliance?

I want to submit the source code for problem set 1 . But I don't have the cs50 appliance . So what should I do?
0
votes
3answers
177 views

pset1 mario. can't fix errors, please help!

I can't understand what's wrong with the code. I've changed it many times, but errors are always similar.Can anyone please check the code and tell what's wrong?
0
votes
1answer
84 views

I have trouble enciphering in Vigenere Cipher CS50 pset2

I have issues incrementing the index of the key and wrapping the key to the beginning. I have tried what I know, I have watched the videos several times and I have been at this for 3 days. What am I ...
0
votes
1answer
3k views

difference between char ** and char *[] in C

what is the difference between char **str and char *str[] in C? int main(void){ char **str = (char **)malloc(5 * sizeof(char*)); char *str2[5]; str[1] = "hello"; str2[1] = "hello"; ...
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
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
1answer
97 views

I'm getting a Segmentation Fault when running recover.c

Seems like others also had the same problem of a Segmentation Fault when trying to do solve this, but I'm not going to look at those. I already liked at another person's code while I was stuck trying ...
2
votes
1answer
1k views

C Preprocessor Output: What is <built-in>

I wrote one of the most simple programs I could imagine: int main (void) { int a; } As you can see, there are no include files. The purpose is to understand a little bit more about the ...
0
votes
1answer
127 views

I am stuck on CS50 vigenere

Hi please see the link for the code I am working with. I think the layout is correct but cannot seem to find the correct algorithm to solve this problem. https://github.com/ionakathryn/cs50-pset2/...
0
votes
1answer
225 views

pset4 increment pointer of type RGBTRIPLE by BYTE

In pset4, resizing an image, I decided to try out pointers and memory allocation to learn more about it, but I've run into an issue with my approach... I've created a pointer and allocated memory for ...
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
2answers
839 views

Segmentation fault: cannot replace character in string

string increment(string s, int loc) { char c = s[loc]; c += 1; s[loc] = c; return s; } increment("A", 0); returns Segmentation fault at s[loc]=c;and I have no idea why. Is there a specific ...
0
votes
1answer
16 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
33 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
231 views

How do I load words in speller that are mixed letters and numbers?

I'm struggling with pset 6 (quite difficult logical and implementation wise, but I like this level of difficulty and this challenge). I'm implementing load and I just found out that I'm 34 words off ...
1
vote
2answers
988 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
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
1k views

Pset3: Tideman - sort_pairs error!

I have difficulty to understand what should the output of the function sort_pairs() should be!, What I understand is I should take the unsorted pairs[] and sort it. For example, this is pairs[] ...
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
58 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
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
1answer
60 views

PSET5 speller memory leak and dictionary not unloaded

I have been looking at this for about 5 days now and I can´t find where I am leaking memory or if I have any problems with my code logic. Everything compiles and Valgrind output is below. I am ...
2
votes
3answers
786 views

jpg's fourth byte

Reviewing my code after successfully recovering the images in pset4, I see a part I just copied (from Zamyla's video) without understanding. Mainly, the following: (block[3] & 0xf0) == 0xe0 I ...
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 &...

1
2 3 4 5
11