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
0
votes
2answers
19k views

How to Wrap Around Array Indexes?

I have the Vigenere encryption portion working properly, but can't seem to figure out how to wrap around argv[1] indexes. My first for loop declared two ints, i and j, and incremented each int with ...
0
votes
3answers
6k views

Initials (Pset2) Problem

I started "well" this particular pset. It's about "initials". The code is alright it takes the first initial. The problem resides in the fact that just one name cannot be accepted, it has to be better ...
0
votes
1answer
2k views

How to Handle "rejects "Hax0r2" as keyword" in Vigenere?

So I made my Vigenere program and it passes all the tests except for the last one about not accepting keys with non-alphas. Now, I have a check in my program to stop this, and when it detects a non-...
0
votes
3answers
2k views

Why does isdigit(argv[1]) return segmentation fault?

Rewriting my question, because I've finally figured out which function was returning segfault, but I still don't understand why. The first part of my code: #include <stdio.h> #include <cs50....
0
votes
3answers
2k views

Segmentation Fault and Returning 1

If I declare int key before my if (argc != 2), I get a segmentation fault (core dumped) message when I run the program with only one command-line argument. However if I declared int key after the if ...
0
votes
1answer
1k views

Incompatible pointer types error vignere

Can anyone explain this error? Here is my code: int main(int argc, string argv[]) { // code snipped int c = strlen(argv); // code snipped Here is the error: vig.c:15:20: error: incompatible ...
0
votes
2answers
1k views

cs50 caesar: expected output, not a prompt for input

[hid code behind edit link per academic honesty rules] check50 2016.caesar caesar.c :) caesar.c exists :) caesar.c compiles :( encrypts "a" as "b" using 1 as key \ expected output, not a prompt ...
0
votes
1answer
290 views

Problem with caesar wrap

I am having trouble with my Caesar code wrapping around the alphabet on large number keys. For one example, I would insert message barfoo with a key of 25 and have an output not what would be expected....
0
votes
1answer
402 views

Pset2 Initials First letter only spam result

I have tried to write this out in myriad different ways but no matter what, entering any string results in the first letter being capitalized and printed ad infinitum until i kill the terminal. i have ...
0
votes
2answers
2k views

Can someone explain me the point of the "int k = atoi((argv[1]);"?

I know that the answer seems obvious but I will explain further the reason for my question: in my program I only used for the key int k = GetInt() without the argv, argc etc. and the program seems to ...
0
votes
1answer
1k views

What does "expected output, not an exit code of 1" mean from check50? [duplicate]

When I write check50 2014/x/pset2/caesar caesar.c in the command line or the terminal this is what happens: :) caesar.c exists :) caesar.c compiles :) encrypts "a" as "b" using 1 as key :) encrypts "...
0
votes
1answer
994 views

Is ROT26 reference in pset2 a joke?

When I was reading the pset2, I found this line. Incidentally, a Caesar cipher with a key of 13 is generally called ROT13 (cf. http://en.wikipedia.org/wiki/ROT13). In the real world, though, it’s ...
0
votes
1answer
232 views

Segmentation fault in Substitution - Problem Set 2

I have finally finished writing my code for the Substitution question in Problem Set 2, but Check50 tells me that my code has a segmentation fault when there is a lack of key. My code is as follows: #...
0
votes
3answers
212 views

cs50 pset2 caesar check50

This is very frustrating. Have written this code 4 different ways and can not figure it out. First problem :( encrypts "a" as "b" using 1 as key expected "ciphertext: b\n", not "Ciphertext \nb...",...
0
votes
2answers
2k views

pset2 caesar converting from ascii to alphabetical

#include <stdio.h> #include <cs50.h> #include <stdlib.h> #include <string.h> #include <ctype.h> int main(int argc, string argv[]) { if (argc == 2) { int ...
0
votes
1answer
259 views

extra characters in Vigenere pset2 2016

I am working on the Vigenere pset and seem to be getting the correct encryption but the output has nonsense characters added to it. For example: :( encrypts "a" as "a" using "a" as keyword \ ...
0
votes
2answers
40 views

Matematical knowledge

I just saw the Short about RSA, and I'm confused about the mathematics involved there, is it critical to solve the pset for this part, and if so, where can I learn about it
0
votes
1answer
521 views

PSET 2 - Vigenere: How do I wrap around my key to the plaintext?

Having some trouble with pset2 vigenere. Here is my code: #include <stdio.h> #include <cs50.h> #include <string.h> #include <ctype.h> int main(int argc, string argv[]) { ...
0
votes
1answer
411 views

pset2 initials isblank

Ok so I am stuck on pset2 initials. My code successfully prints out the first letter. I want to print out the ith character, I'm checking for a space with isblank() with an if statement which if true ...
0
votes
1answer
573 views

Pset 2 Initialise: "result of comparison against a string literal is unspecified"

I've been having this persistent issue that's taken me a day of googling and referencing and still have no idea what's up. Essentially, the code below (which is hopefully commented well enough to make ...
0
votes
1answer
256 views

My caesar output has no spaces

I have little bug in my program with spaces; when the user writes "world, say hello" the output is correct but without spaces. I tried to use: if (isblank(n)) { text = n + ' '; } but that didn't ...
0
votes
1answer
2k views

pset2 vigenere help [closed]

OK, I have tried everything, but there still seems to be something wrong with my code for vigenere cipher. I mean I can't get it to loop through the keyword when the word is longer than it. I swear I ...
0
votes
1answer
49 views

What does argc and argv have to do with cryptography? Why are we learning about these arguments?

I understand what these arguments do--take inputs before the program starts to in some way influence the program. But they seem to have been shoe-horned into the lecture. David moves on from this ...
0
votes
2answers
80 views

PSET2 Vigenere: Output bug, keyword loop going over strlen of key

I am having an issue specifically with the second for loop (under "//iterate over key inputs" comment). The counter j is going over the strlen of argv[1], and thus feeding a wrong input to my shift ...
0
votes
1answer
124 views

why do we use remainder 26 (%26)?

Why do we keep using the %26 in pset2 when working with Caesar and Vignere? I'm having trouble understanding why it would be helpful to know what the remainder is after dividing by 26?
0
votes
1answer
181 views

check50 not approving my code but it looks like it's working

Check50 is telling me that none of the expected ciphers are working, however running each of them appears to give the exact same output it expects. I cannot see where the failure is coming from. ...
0
votes
2answers
78 views

Pset 2 Vigenere Increment Problem

My Code: int main(int argc,string argv[]) { // Checks if the program got an agrument if (argc != 2) { printf("Pls dn't spuk teh prgoram"); return 1; } else { ...
0
votes
1answer
81 views

Why does the if else conditional give me a segmentation fault

int main(int argc, string argv[]) { string keyword = argv[1]; if (argc != 2) { printf("Please reenter with a cipher keyword); return 1; } if (isalpha(keyword)) ...
0
votes
1answer
94 views

Vigenere Segmentation understanding

I'm currently working on 'Vigenere' on the CS50 online course and i came across this issue that i totally believe comes down to problem in my understanding. please find my code below... // INCLUDE ...
0
votes
1answer
226 views

pset2 crack - values are equal but the program claims equality is false

As you can tell by the code (pasted below), my program is supposed to get the hash as a command line argument, and then prompt the user for a "guess" as to what the plaintext password might be. It ...
0
votes
1answer
320 views

Dues style matter for p-set 1?

In weak 2 we learn how problem sets are evaluated: Scope, Correctness, Design and Style. So, is the code submitted for pset 1 also evaluated like this? And, if so, should I change the style to improve ...
0
votes
2answers
165 views

pset 2 initials (less); "expected prompt for input, not output of..."

I've implemented the code for pset 2 initials (less) and it seems to be working, however, when I test it I get an error I'm struggling to understand. Any help would be greatly appreciated. Below is ...
0
votes
1answer
52 views

Pset2 Vigenère cipher solution Segmentation fault

My solution to this problem is as follow: #include <stdio.h> #include <cs50.h> #include <ctype.h> #include <string.h> #include <stdlib.h> int main(int argc, string argv[...
0
votes
1answer
83 views

Identifying a blank space in a string (Pset2)

I'm trying to figure out how to know if there is a space in a string. Since in lecture it was said that in C a blank is "\0", I figured that comparing the array item with it could work. For example, ...
0
votes
1answer
53 views

why does this code not ask for a string?

#include <stdio.h> #include <cs50.h> #include <ctype.h> #include <stdlib.h> #include <string.h> int main(int argc, string argv[]) { if ( argc > 1 || argc < 1 ) ...
0
votes
1answer
87 views

pset 2 vigenere at a loss

I think I just need a good set of eyes to look at this and tell me where I went wrong. It works for "Meet me at the park at eleven am" but fails a few of the check 50s. I believe it has something to ...
0
votes
1answer
271 views

Pset2: Initializer list problem

So, while working on the "initials" problem this kind of error appeared after I thought I've finished with my code. error: array initializer must be an initializer list I'm posting my whole code ...
0
votes
1answer
215 views

I just finished pset2 caesar. I get a segmentation fault if argc is other than 2

I can't figure out why i'm getting a segmentation fault. As far as I understand if there is other than argc = 2 the program should simply print the right usage and return 1. What can be causing this? ...
0
votes
1answer
2k views

PSET 2 Caesar help

Please help me, I have gotten this far but when I run the code it does not work as anticipated. I don't understand why my arc !=2 is not working. also when i do ./ caesar 3 and type "hello" it prints ...
0
votes
1answer
258 views

Vigenere fails "world, say hello" with "baz" and "BaRFoo" with "BaZ"

After many hours of tinkering and research, I still don't grasp why my vigenere code fails check50 on these two accounts: 1) encrypts "world, say hello!" as "xoqmd, rby gflkp!" using "baz" as keyword ...
0
votes
2answers
535 views

pset2 (Hail, Caesar) - How to refine my code

i'm new to this and CS50. int main(int argc, string argv[]) { if (argc <= 1 || argc > 2) { printf("Open program with a key!!!\n"); return 1; } int k = atoi(argv[1]); ...
0
votes
2answers
338 views

pset2 Vigenere Modulo

I'm don't understand how to use modulo to shift my characters. When I type 'Z', I get a '[' instead of 'A'. I read elsewhere that I need to shift the key AND the inputed text - yes? for (int i = 0, ...
0
votes
1answer
223 views

pset2 initializing segmentation fault

PGM compiles, but when I run it and type my name I'm getting a segmentation fault. Any help is greatly appreciated! Thanks!! My code: int main(void) { // Prompts and retreves user input. ...
0
votes
1answer
1k views

Vigenere cipher: how to loop the key

Please help me with my code below. I cannot seem to get the argv[1] (the key) to loop around plaintext. For example, if I my key is "bacon", and the plaintext is "Meet me at the park", I only get "...
0
votes
2answers
679 views

initialize doesnt capitalize

This is my code for initialize....what did I do wrong and what can i do to fix it. #include <stdio.h> #include <cs50.h> #include <ctype.h> #include <string.h> #include <...
0
votes
2answers
360 views

Initialize Glitch

My initialize code glitches when i compile it. It asks me for my name and then it prints it out without initializing it. (its also worth pointing out that it capitilized the first letter of my first ...
0
votes
1answer
277 views

compilation error multi-character character constant in caesar

The code is: string plaintext = GetString(); for (int i = 0, n = strlen(plaintext); i < n; i++) { printf("%c", plaintext[i]); if ((isalpha(plaintext[i])) && (isupper(...
0
votes
2answers
1k views

How to take an int as a command-line argument?

I'm a bit confused on the caesar cipher problem. The problem says the program must take a single argument being a non-negative integer. Here is how I tried to write the main function to take an ...
0
votes
1answer
185 views

Gradebook issue

So far i have submitted PSET0, PSET1, PSET2, PSET3. I have submitted both standard and hacker editions. I have following grades so far: PSET0....................1.0 PSET1 PSET2...............
0
votes
2answers
756 views

How to wrap around the jth element in vigenere cipher efficiently?

I have seen a lot of solutions to this but still didn't found the efficient solution for wrapping around for the non-alphabet character in the text to be encrypted. What I did was jth position (...

1 2 3
4
5
25