Questions tagged [c]

The tag has no usage guidance.

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

Pset4: Resize: Unsupported image format

Why am I only getting unsupported image format when trying to resize clue.bmp. I have tried with small,large and smiley and these all seem to be working. The image is being resized correctly but the ...
0
votes
1answer
75 views

I am getting an unexpected sizeof() error

I am using a BIT filed varibale in a struct to Modify the size of the data type. I need this struct to be exactly equals 1. According to my calculations it is equal to 10 but when I use the sizeof() ...
0
votes
1answer
30 views

pset4/recover: i see files but not all of it and nothing in it

when i run the cod i can see the files but when i open it i can't see any pictures and also not all of the 50 files showed only 21. #include <stdio.h> #include <stdint.h> int main(void) {...
0
votes
1answer
3k views

I am getting a weird implicit declaration in C

I am using this function usleep() which is suppose to stop any operation for several seconds. Any way I get this error while trying to compile my code stream.c:28:4: error: implicit declaration of ...
0
votes
0answers
287 views

segmentation fault 11

I've been googling trying to fix this segmentation fault for about 3 hours now but so far no luck. I get no output (file written) either Help would be greatly appreciated. Sorry if I typed words wrong,...
0
votes
1answer
32 views

Error in my final project

So I am working on my final project and when I try to compile I get this error : mpg.c:169:1: error: expected '}' ^ mpg.c:133:2: note: to match this '{' { ^ mpg.c:169:1: error: expected '}' ^ mpg.c:...
0
votes
1answer
238 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
150 views

pset3: sort -- Selection Sort Implementation

I have been working away at my implementation of Insertion Sort for this problem set, and I've run into a predicament. I have gotten the sort function almost functional, however I'm sure we all know ...
0
votes
1answer
768 views

What does a command line argument stored in char* argv[] yields when assigning to another char*???

#inlcude <stdio.h> #inlcude <stdlib.h> int main (int argc, char* argv[]) { if (argc != 3) { return 1; } char* inf = argv[1]; char* outf = argv[2]; ...
1
vote
1answer
100 views

What does the R in RUSAGE stand for?

Came across this function and couldn't intuitively define the implied name. No search on stack quickly returned the answer.
0
votes
1answer
162 views

speller.c - understanding the checking part

This post is not about some issue I have with my own code but rather to understand the logic of the course's code. In this code, which is a segment of the file speller.c, I cannot understand why ...
1
vote
1answer
91 views

Pset4 recover.c Still getting a Seg fault

I changed the code from the first time I asked this question, so I decided to make a new thread. Sorry if this is not a good idea. Anyway, I'm still getting a Seg fault here. And even if that ...
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 ...
0
votes
1answer
30 views

Every move I do in CS50: pset3 is illegal...does anyone know why?

Hi please see code on this link: http://pastebin.com/wJy0PWZ7 Every move is illegal and I don't know why... Thanks
1
vote
1answer
41 views

recover.c encounters seg fault after 1024 bytes

In pset4, recover.c, my program finds the start of the jpegs at 1024 bytes. After that, it encounters a seg fault and I don't see why. Here's my code: #include <stdio.h> #include <stdlib.h&...
0
votes
1answer
334 views

vertical resize

I'm really sorry for doing this again, but I really need to understand how to do this correctly. I'll post both my horizontal resize code and my vertical resize code. The former is working correctly,...
0
votes
1answer
39 views

PSET6 parse function writing random character to strings

UPDATE: The issue was resolved thanks to the comment below. I'm working on the parse() function and seem to have random results with it. So far I wasn't able to launch the Web Server from my IDE as I ...
0
votes
1answer
587 views

vertical resize for resize.c

I'm editing the post. I found some code on this side that's using the same pseudocode from Zamyla, so I thought I'd try to understand it and use it in my own program, but I'm having problems. It'd ...
0
votes
1answer
161 views

Help needed with pset4 resize.c

The code compiles, but the image file is now of an invalid or unsupported type. What did I do wrong here? And if my calculation for the padding and image-size is wrong, let me know about that as ...
0
votes
2answers
155 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
2answers
434 views

How to copy a string in pset2? strcpy results in segfault

This program takes a string from the user and returns the string in title case (i.e. "foo bar baz" -> "Foo Bar Baz"). This is for the first problem of set #2. It usually is bad form to mutate your ...
0
votes
1answer
66 views

vigenere cipher logic error

#include <stdio.h> #include <cs50.h> #include <ctype.h> #include <string.h> int main(int argc, string argv[]) { int k, j, i = 0, ch, pos; bool alpha = true; string ...
0
votes
2answers
39 views

double free or corruption in Pset6 server.c

I get a double free or corruption error message on my server.c, although I am not freeing any thing in my functions. I also tested my functions and they are all working properly supposedly. Can any ...
0
votes
1answer
196 views

CS50 PSET2 Check 50 Hello world trouble. Caesar cipher segmentation fault and encipher the plaintext

Scroll down for edited question about Check50 hello world! The Segmentation fault and encipher plaintext question has been answered. Accidentally the first Pastbin has been overwritten. In case ...
0
votes
2answers
117 views

Pset 4: resize correctly, header info perfectly match, but can't pass the 1x1 pixel check

I've tried many numbers, the code correctly resize the image, and the header info perfectly match. But it can't pass the check when the image is 1x1 pixel. I've spent two week on this pset and I am so ...
0
votes
1answer
36 views

Pset2 initials.c Prints out the same character to often

Here is the code http://pastebin.com/Abk8GY3m. When the program prompts me for the name. It gives me the correct output. For example Robert Vicino gives the output RV. I compared it with the cs50 ...
0
votes
2answers
7k views

Subscripted value is not an array

I am using exactly the same code as at HowStuffWorks to create a bubbling sorting. But I cannot compile code as I get the following error message: sorting.c:29:22: error: subscripted value is not an ...
0
votes
1answer
58 views

Recover: While loop repeats but does'nt add variable

My code: //create space save info from card unsigned char buffer[512]; int jpgCount = 0; char title[7]; do { if (buffer[0] == 0xff && buffer[1] == 0xd8 && buffer[2] == 0xff) { ...
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"...
1
vote
1answer
267 views

Debugger not working properly for pset4?

I'm working on pset4 and trying to do the following: Allow us to suggest that you also run copy within GDB while answering these questions as follows: Click Debug atop CS50 IDE, which ...
0
votes
1answer
50 views

What does it mean when a program doesn't end?

So I'm working on recover for pset 4, and when I run the current version of the program, nothing happens and it doesn't seem to even end. //declare outptr; FILE* outptr = NULL; //define the ...
0
votes
1answer
1k views

char* and read-only memory

Take a function that creates a char* and does something with it. void print_hello_twice() { char* hello = "hello"; printf(hello); printf(hello); } This is a silly pointles example, but I ...
0
votes
1answer
87 views

Why do I have a strange black line on the top of my picture in large.bmp, pset4?(

I would very appreciate your help. //variables for original width and height int originalWid = bi.biWidth; int originalHei = bi.biHeight; //update width and height bi.biWidth = scale * ...
0
votes
1answer
82 views

CS50 Format Specifiers in c

What are the format specifiers used in the CS50 version of C? (I understand that CS50 uses other format specifiers than the standard C version)
0
votes
1answer
1k views

How to cut down on trie load time (pset5)?

I've already completed pset5 and optimized it as best I can, but, as I've decided to store the dictionary in a trie, the load time is really high, at around 0.10. Here's how I implemented load(): ...
0
votes
1answer
633 views

Use of functions and variable declarations outside main() on pset1 greedy

I have completed greedy from pset1 and I still doubts about the variable declarations and the function position. What is the difference if they are declared inside or outside the main function? #...
1
vote
1answer
109 views

What to do with the ASCII key & math?

I'm having a hard time understanding what to do with the ASCII keys & math formula. I understand that you move your plaintext over by the K amount, however, I'm not sure how to write this in code. ...
0
votes
1answer
132 views

Loading hello.php from hello.html causes Error 500 (Internal Server Error)

My server seems to be working fine, except when I submit form in hello.html and load hello.php. It results in Error 500 (Internal Server Error). Also, when I use check50 it results in 'Unexpected end ...
0
votes
1answer
165 views

Why is this code behaving weird? (pset1: greedy)

It is correct for every input except "4.2". The output should be 18, but my code is giving it to be 22 and I have absolutely no idea why this is happening. #include<cs50.h> #include<stdio.h&...
0
votes
2answers
194 views

What is wrong with this mario pset1?

#include <stdio.h> #include <cs50.h> int main (void) { int n; do { printf("Height: "); n = GetInt(); if (n == 0) { return 0; ...
0
votes
1answer
207 views

vigenere cs50 problem: "world, say hello!"

I'm almost finished with the ´vigenereproblem set incs50` but have one problem my brain can't find the solutions for, anyone have any ideas? check50 2015.fall.pset2.vigenere vigenere.c: :) vigenere.c ...
0
votes
1answer
43 views

Problem with implementing a Variable Scope

I was going through (Week 2> Section>Variables and Scope) when I wrote this piece of code : ` int set_int(int x); void set_array(int array[4]); int main(void) { int a = 10; a = set_int(a); ...
0
votes
1answer
183 views

length of argv always change to 1?

why the length of argv changed here to 1 always in the last line ?? #include <cs50.h> #include <stdio.h> #include <string.h> #include <ctype.h> int main(int argc, string argv[...
0
votes
1answer
164 views

what is wrong with scanf in the program written bellow, Why it is not asking for value when input is not an integer?

#include<stdio.h> #include<stdlib.h> //#include<cs50.h> int main(void){ int minutes; printf("minutes:"); int c=scanf("%d",&minutes);//if input here is character then second ...
0
votes
1answer
77 views

What's wrong with my recursive binary search function? [duplicate]

I've spent hours on this, have tried multiple configurations based on code I can find online, but am getting no where. Any input would be appreciated. I'm trying to make a recursive, binary search ...
0
votes
1answer
128 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
164 views

In pset6 server.c, does using realloc() reset the file pointer for fread()?

The following was my load() function for pset6 server.c bool load(FILE* file, BYTE** content, size_t* length) { size_t count = 0; BYTE* file_char = malloc(sizeof(BYTE)); while (...
0
votes
1answer
185 views

Mario pyramid loop arithmetic question

So I've got the program up and running, I'm just trying to understand exactly why it is performing correctly. I'm confused on this: for (rows = 0; rows < height; rows++) { for (spaces = (...
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
757 views

pset4 recover "File size limit exceed"

This is what I've created to solve recover. When I run it, the IDE gives an error that File size limit exceeded. Please check this code and tell me what part of it is wrong. What I am exactly doing: ...