Questions tagged [pset2]

The problem set for Week 2 continues with the C programming language used in problem set 1.

Filter by
Sorted by
Tagged with
7
votes
4answers
6k views

What's the point of the modulo operation in the Caesar cipher formula?

According to the problem set specification, the formula for encrypting a message using the Caesar cipher is: ci = (pi + k) % 26 I don't get why you need to do modulo 26. What does it even do here?
5
votes
3answers
6k views

How to handle the lack of argv[1] in caesar?

I think my program handles lack of argv[1] correctly, yet it fails check50's test. here my code: if ( argc != 2 ) printf ("usage : ./caesar + key \n"); return 1;
5
votes
1answer
1k views

PSET2: CRACK vs POINTERS

SPOILERS (maybe) Hi, I have just started working on crack. I have no previous experience, at least not too much but I'm trying to grasp the logic behind this and it seems my biggest issue for this is ...
4
votes
2answers
2k views

How to handle “lack of argv[1]”

I have my code set up so that if argc doesn't equal 2 the main function will return 1. Per the specs I thought. But I keep getting the error that I didn't "handle lack of argv[1]". if (argc != 2) ...
4
votes
3answers
835 views

What does if (s != NULL) do?

According to the lecture in Week 2 and the walkthrough video "String", to make sure that the user gives us a valid string we use this condition: if (s != NULL) { //code } ...
3
votes
4answers
2k views

Pset2 Readabilty: Why are my grade levels calculating incorrectly?

For Pset2: Readability, I'm writing a program in C that prompts the user for text input, analyzes how many letters, words, and sentences are in the text entered by the user, and calculates the grade ...
3
votes
1answer
474 views

Pset2 Vigenere 'szz' instead of 'rby'

I fail one test case, and just the one portion of it. Expecting the following on standard out — xoqmd, rby gflkp!\n ... but received the following on standard out instead — xoqmd, szz gflkp! rby =\...
3
votes
1answer
6k views

C's DES based crypt function?

How do I use c's DES based crypt function in my crack program in pset 2
3
votes
1answer
1k views

Why doesn't caesar pass check50 even though the output is correct?

I have solved caesar, but check50 is not recognizing my results as correct. :) caesar.c exists :) caesar.c compiles :( encrypts "a" as "b" using 1 as key \ expected output, but not "b" :( encrypts ...
3
votes
1answer
342 views

pset2 Crack - Looping through fgets

I'm trying to loop through a text file (seven lines in the file, with aaaa, aaab, aaac, etc listed) with password guesses for pset2 Crack. I am able to open the file, and iterate through the lines. ...
3
votes
1answer
839 views

PSET 2 - Can Crack be implemented for 5 characters in a more efficient way?

Okay, so I've finished the crack problem, and it runs, but since the pset2 now tells us the passwords can be upto 5 characters long, it takes about 48 minutes to get the password match for "zzzzz". ...
2
votes
1answer
4k views

What does “ 'GetString' is deprecated” mean? How do I fix it?

I have encountered a really confusing error that deals with the "GetString();" function. I tried to google what does this error message mean but haven't had any luck finding a solution. I don't think ...
2
votes
2answers
445 views

pset2 crack segmentation fault

Program compiles, but I just can't figure out how to go trough each string length generating process without segmentation fault. I could really use some pointers please! #define _XOPEN_SOURCE #...
2
votes
1answer
347 views

Why does my vigenere not pass check50 although it gives the correct output?

When checking vigenere.c with check50, I get the following :) vigenere.c exists :) vigenere.c compiles :( encrypts "a" as "a" using "a" as keyword \ expected output, but not "a" :( encrypts "world,...
2
votes
2answers
2k views

code: string initial = toupper(name[0]); Getting an error

I am currently in pset2 and working on initials. I have been trying to implement the code string initial = toupper(name[0]); It gives an error saying incompatible integer to pointer conversion ...
2
votes
1answer
367 views

Ascii Becomes Negative?

So I'm I just started pest 2 and it was pretty smooth until I found a horrible bug in my code. Essentially the code works fine when the entire plain text string is in upper case, but it gives me a ...
2
votes
1answer
122 views

Caesar code only works correctly when I add a random printf statement

My Caesar code seems to be working correctly in this form: #include <cs50.h> #include <stdio.h> #include <string.h> // validates that the key is only numbers int validate_key(...
2
votes
2answers
390 views

Code Seems to Work but check50 says otherwise (pset2)

my code seems to work but check50 seems to disagree and has given me the following: :( encrypts "a" as "b" using 1 as key expected "ciphertext: b\n", not "ciphertext: b\x..." :( encrypts "barfoo" as "...
2
votes
1answer
3k views

pset2 vigenere error “incompatible integer to pointer conversion”

This is the error I get: vigenere.c:34:34: error: incompatible integer to pointer conversion passing 'char' to parameter of type 'const char *'; take the address with & [-Werror,-Wint-...
2
votes
1answer
314 views

Pset2 - Readability: How to round a .5 number depending on the 2nd digit after the decimal point

I have written a solution for readability from pset2 but I'm having problems with one of the points: :( handles single sentence with multiple words expected "Grade 7\n", not "Grade 8\n". So I ...
2
votes
1answer
293 views

HELP HELP with pset2 crack password dont work

i'm trying to make pset2 crack but having so much problems and my head is about to explode. Here is my code my first error is on line 41, I never get to pass a value to the key for crypt. I'm very ...
2
votes
2answers
226 views

PSET2, crack.c Did this problem fall out of the sky from week 115? Am I overthinking this?

This is the spec: Specification Design and implement a program, crack, that cracks passwords. Implement your program in a file called crack.c in a directory called crack. Your ...
2
votes
1answer
99 views

error in initials.c when I use my own functions

I have solved the initials program in 2 different ways. In the third way, there is a bug which I am not able to clear, please help me finding it out. code: #include<stdio.h> #include<ctype....
2
votes
2answers
651 views

pset2 initials compiles and outputs correct but errors

I'm having trouble with pset2 initials.c My program compiles and passes each output test, however after each test I get "wasn't expecting "Please enter your name:" The problem states that we are to ...
2
votes
1answer
247 views

Expression result unused in Vigenere

I am getting this error: expression result unused and I don't know what that means. I use the code it's pointing to (green underline), just like I do in my Caesar cipher which works: The other posts ...
2
votes
1answer
622 views

Failing one test case with check50 on pset2 - encrypts “say” to “szz” instead of “rby”

encrypts "world, say hello!" as "xoqmd, rby gflkp!" using "baz" as keyword # Checks 0 Running... clang -o vigenere vigenere.c -lcs50 -lm. ✔ 1 Expecting an exit code of 0. ✔ 2 Running... ...
2
votes
1answer
81 views

pset2/crack/(Memory issue)

If I run this code for the first time it gives me the desired output. But on the second run, I don't get the desired output. It seems like memory is not given free. #include <stdio.h> #include &...
2
votes
1answer
201 views

pset2 Initials Design Improvements

I was hoping you might be able to help me improve the design of my code. I've solved the initials problem, and it passes check50 on both normal and hacker edition (the hacker edition was incidental), ...
1
vote
1answer
2k views

Not able to understand what I need to do in pset2 (crack.c)

I have completed all problems in psets 0, 1, 2 comfortably except for the last problem. Crack.c (more comfortable version). I read the cs50 crack.c page and I also watched the walk through twice but ...
1
vote
1answer
3k views

Implicit declaration of function 'topper' is invalid in C99

I am currently working on pset2 in CS50 and am having trouble with initials.c The compiler does not recognise 'toupper', and I use '#include ' at the top. I just updated everything, so this seems to ...
1
vote
2answers
766 views

pset2 (vigenere) - Check50 error problems

I'm stuck on an issue with my code. After completing my code and making sure it works as should, I run check50 and this is what I get; jharvard@appliance (~/Dropbox/pset2): check50 2014/x/pset2/...
1
vote
3answers
4k views

Segmentation fault (core dumped) in caesar

After starting caesar with an additional argument and providing the sentence that needs to be encrypted, the Terminal shows this response: jharvard@appliance (~/Dropbox/pset2): ./caesar 1 abcdef ...
1
vote
1answer
2k views

Crack - launching and crypt function

I'm on the crack challenge from pset2 and I don't understand how to compile the program. When I use clang -ggdb3 -O0 -std=c11 -Wall -Werror -Wshadow crack.c -lcrypt -lcs50 -lm -o crack as ...
1
vote
3answers
64 views

Too much whitespace in vigenere.c, style50 error in pset2

The Program has no errrors when checking with check50 but when i check vigenere.c with style50 by: style50 2015.fall.pset2.vigenere vigenere.c it gives the following error: :( 84:20 Too much ...
1
vote
1answer
200 views

This should be right (Caesar)

After spending pretty much a whole day on this, I have gotten it to work fine, it does all that was demanded but when submitted, I am still getting 1/5 on correctness. :( someone tell me if I left ...
1
vote
1answer
3k views

pset2: Crack takes a lot of time

I take an average of 20 minutes to crack the password and some people are saying it can be done in less than 30 seconds, I have been trying to find out why my code takes that much time but I can't. #...
1
vote
1answer
60 views

vigenere sometimes prints extra characters at the end of ciphertext in an unpredictable pattern

Check50 yields 2 error messages (the rest is correct): :( encrypts "a" as "a" using "a" as keyword output not valid ASCII text :( encrypts "world!$?" as "xoqmd!$?" using "baz" as keyword output not ...
1
vote
4answers
156 views

Cs50's vigerene encrypting problem

My code complies well but encrypts the text in the wrong way.Could someone help me find the problem? any help will be appreciated here is my code: #include <stdio.h> #include <cs50.h> #...
1
vote
2answers
295 views

Unexpected outputs - initials.c

it's nice to be here! In initials.c in pset2, I am able to extract and capitalize (if necessary) the first letter of the inputted name string, iterate through the string and extract and capitalize ...
1
vote
1answer
4k views

string comparison & crack.c

I've been working on the pset2 hacker problem and decided to decompose a problem by creating subtasks. Anyway, the first part was to simply compare two crypted strings (at the moment, just one letter ...
1
vote
1answer
3k views

Vigenere cipher coding drama!

your help is appreciated and please feel free to critique my coding approach. My concern is, not only that the code isn't working, but that I maybe complicating this more than it needs to be. Working ...
1
vote
2answers
7k views

“Expected Expression” error on else function in caesar.c

I am working on pset2, caesar.c, and I am currently getting the error message below: caesar2.c:32:9: error: expected expression else if (islower(plaintext[i])); ^ caesar2.c:38:9: error: expected ...
1
vote
4answers
772 views

Vigenere Cipher Doesn't Work Properly

I have been trying for way too long to make my Vigenere cipher work, but now I am so confused I don't even know what I am doing. I need some guidance in what it is that I am doing wrong. When I ran ...
1
vote
1answer
77 views

What is the logical difference between if (isupper(text[i]) == true) and if (isupper(text[i]))?

In my original code I had this: if (isupper(text[i]) == true) { int j = (int) text[i] % 65; int k = (j + key) % 26; char l = (char) k + 65; ...
1
vote
1answer
462 views

cs50/pset2/vigenere: Code works but check50 rejects 2 item

check50 message: https://cs50.me/checks/c053757544cd74cafb77554759754b8ee4ee37a8 The code doesn't encrypts "a" as "a" using "a" as keyword. It adds a wierd character in the end and I don't know why. ...
1
vote
2answers
216 views

Easiest method to organize code

I'm just finished the entire cs50 course (yay), except the final project, and I'm ready to start submitting all of my psets. Before I submit, I'm going to proofread all my code and simplify/style it ...
1
vote
2answers
836 views

Cs50 problem set 2 Initials

everyone! I have one problem with code initials. It correctly runs but after check50 I've got some issues , among them- ***\ expected output, but not " \u0000\n"***that I can't fix.Help me,please) #...
1
vote
1answer
437 views

Pset 2 Caesar doesnt output spaces correctly and more :(

Really having a hard time doing this caesar problem my cipher text is not taking spaces to account and when I type in ./caesar by itself it gives me a message like this: caesar.c:10:18: runtime ...
1
vote
2answers
129 views

vigenere.c key just wraps around … if there is space in plain text it seems to ignore that key and move on to next

int main(int argc, string argv[]) { string k; k = argv[1]; if(argc == 2) { for(int i=0,j=strlen(k); i<j; i++) { if( isdigit(k[i])) { ...
1
vote
1answer
139 views

Vigenere -Isalpha only checking first char of key

When checking the command line argument in Vigenere.c to see if it contains any non-alphabetic characters, I can't get my for loop to iterate past the first character. I have read all of the posts on ...

1
2 3 4 5
25