Questions tagged [c]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
3
votes
2answers
33k views

How to solve “control may reach end of non void function” error

When I try to compile my code, I get an error message that says "control may reach end of non void function." What does this message mean and how can I avoid this error? Here is the function that's ...
0
votes
1answer
937 views

Debugging Webserver in C

I have an error in my server.c file for PSET6 but have no idea how to find it. I am trying to use GDB and it does not seem to be very useful. I would love some help learning how to better debug this ...
0
votes
2answers
416 views

Developing JPEGS for pset4's recover troubleshooting

I am currently working on cs50's pset4 recover. I have managed to compile the program. However, when run, the images are corrupt and apparently, according to image viewer, are not jpeg files, because ...
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
3answers
156 views

Greedy hangs after prompting for user input

I'm a bit stumped at what I'm missing in my Greedy solution. The program keeps getting hung up right after the prompt for user input. Check50 doesn't give me much information to work from. What is ...
3
votes
2answers
43k views

How do I share a variable between source files in C with extern?

I know that global variables in C sometimes have the extern keyword. What is an extern variable? What is the declaration like? What is its scope? This is related to sharing variables across source ...
0
votes
2answers
153 views

C data types and format specifiers

I was playing around with data types and format specifiers. Compiling the first snippet of code gives no errors but when I try to use unsigned shorts (or shorts in general) I get an error on line 12: ...
0
votes
0answers
245 views

Guys getting problem with cat.exe

Hey friends thakyou for your help in advance I am having problem with my parse and lookup function. check50 is returning all fine except this :disappointed: Requesting cat.exe returns error code 501 ...
0
votes
1answer
434 views

cs50 pset4 recover.c error: munmap_chunk(): invalid pointer

I have been working on this pset for a while, but I was not able to solve my problem yet. When I compile my recover.c program, it does so without any errors. Although my program creates all images ...
2
votes
2answers
280 views

pset4 recover: recovered images seems to still be corrupted

My code compiles and runs without any errors. Images are generated, but the images are incomplete, here's an example of 000.jpg: https://i.imgur.com/Ovs2Xv8.png. I can't really find what's wrong in my ...
2
votes
1answer
886 views

What's the purpose of the 'salt' string? Isn't it contained in the hashed string anyway?

When checking the manual entry for man crypt, I read: The returned value points to the encrypted password, a series of 13 printable ASCII characters (the first two characters represent the salt ...
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
vote
2answers
928 views

How can I swap two values and return two integers?

I wanted to write a function that swaps two values, but I'm not sure how to return 2 integers. This code doesn't work, as after swapping the values x is still one and y is still 2: void swap(int in_1,...
1
vote
1answer
634 views

pset5 speller.c with hashtable errors and seg fault

this is my code so far for pset5. I would appreciate giving me hints about my erros. I also get a segmentation fault. thanks. when I implemented load and check only, it seemed to load the text and ...
0
votes
2answers
505 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
213 views

check function in speller pset5, not quite understanding the apostrophe

I am working on the check() function of dictionary.c. I am using it to test cat.txt: A cat is not a caterpillar. It says everything is correctly spelled except "not" When I check the hashtable ...
0
votes
1answer
17 views

this code generates wrong results

I have some issues with this code it just prints the very first part of the image right and the rest of it just a gray screen can anyone help please. #include <stdio.h> #include <stdlib.h> ...
0
votes
1answer
81 views

Pointer passed as argument, then suddenly goes null

In the main method I declare a character pointer pCharacter. I pass this variable to the setCharacter method and assign it an address and a variable gets assigned to that address. From what I ...
0
votes
1answer
145 views

Memory leaks in Speller

My program passes all tests except the valgrind check. I tried to find the cause of errors, but valgrind is too 'obscure' for me yet, I don't know what to do. I guess some memory isn't freed, but I ...
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
1answer
284 views

Credit Card Test Confusion

I am supposed to find if cc numbers are valid based on these rules: Multiply every other digit by 2, starting with the number’s second-to-last digit, and then add those products' digits together. ...