Questions tagged [caesar]

Caesar Cipher, one of the assignments in Problem Set 2.

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

Caesar problem. Keep getting error of segmentation

The follow part of code worked perfectly, while I declared variables key_num and plaintext within if{}, but since I declared them outside (cause I need to use these vars later) I get the "...
0
votes
1answer
18 views

Why is it asking me to declare (s) when is has been declared already?

#include <stdio.h> #include <cs50.h> #include <math.h> #include <string.h> #include <ctype.h> bool is_valid_key(string s); int main(int argc, string argv[]) { if (...
0
votes
1answer
23 views

I believe my code is right but it's not giving output and pops segmentation fault

This is my code for Caesar Pset2. The code must be doing right but it's broken somehow. #include <stdio.h> #include <math.h> #include <string.h> #include <ctype.h> #include <...
0
votes
1answer
27 views

Question on pset2 caesar - segmentation

I am really stuck on pset2 Caesar. I can compile it, but when I try to enter valid command line argument, it keeps on saying that I have a Segmentation fault. That seems to mean that I access memory ...
1
vote
1answer
24 views

Unable to confirm user input is a number using isdigit in c

My code is attempting to; take user input from the command line; check if the input is a whole number; confirm positively if so; confirm negatively if not; however all numbers return a negative ...
0
votes
1answer
22 views

Is argv[] changing my input?

I'm having trouble running my program, so I tried to look at it in debugger program. Is this screenshot telling me that argv1, shown on the right as **argv, is being recorded at a '.', and not the ...
0
votes
1answer
48 views

Caesar works as intended but check50 says it doesn't

I've tested all the possibilities where check50 says my code isn't working as intended and I always get the expected result. I can't seem to figure out what I did wrong. Here's check50: :) caesar.c ...
0
votes
1answer
32 views

Hello everyone, i have a problem with my code for caesar

So when i run the following code in the caesar.c that is located in the caesar folder, it seems to run only for the very first character of the given plaintext and then the next characters are missing....
0
votes
1answer
42 views

Implementation problem

#include <stdio.h> #include <ctype.h> #include <cs50.h> #include <string.h> #include <math.h> #include <stdlib.h> int main(int count, string input[]) { // ...
0
votes
1answer
39 views

Indexing problem

when debugging, the inner-most if condition never entered. Whether the char is upper-text or lower text. I 'm using the same methodology in both cases. // testing if the char upper text if ...
0
votes
1answer
44 views

caesar pset2 "expected expression and use of undeclared identifier" error

When compiling this code getting mutltiple errors any idee why is the couse of these errors thanks. #include <cs50.h> #include <stdio.h> #include <ctype.h> #include <string.h> #...
0
votes
1answer
37 views

incompatible integer to pointer conversion initializing 'char *' with an expression of type 'int'

I keep getting this error when I try to compile my program: incompatible integer to pointer conversion initializing 'char *' with an expression of type 'int' { if (argc != 2) { printf(&...
0
votes
1answer
28 views

For loop proccing too many times

In the code below I check whether or not the string is or isn't a digit. To do that I iterate through every single value entered in the argv[1]. Unfortunately when the entered key is larger than one ...
0
votes
1answer
27 views

Program won't print out enciphered text

So under "Peeking under the hood" they asked to ignore the key the user provided and instead prompt the user for a plaintext and move each character by 1. when I run my program, and input &...
0
votes
1answer
41 views

How do I check that every character of an array is a digit and only print out the string if all the chars are digits?

So, in Caesar when validating the key they asked to check if all the characters in the command line argument provided are digits and only printout "Success" and the digits as an integer if ...
0
votes
1answer
18 views

Logical error in Caesar of Pset 2

The logical error is occurring when i try to shift each character of the plaintext by 1 string plaintext= get_string("plaintext: "); //aplplying key for(int j=0,m=strlen(plaintext);...
0
votes
1answer
20 views

Error in Caesar of Pset2 while validating entered key

My question is regarding the step of 'Validating the Key' in Caesar of Pset2 , while checking whether the key given by user consists of digits. Here is my code : #include <stdio.h> #include <...
0
votes
3answers
33 views

:( handles lack of argv[1] failed to execute program due to segmentation fault

if (argv[1] == NULL) { printf("Usage: ./caesar key\n"); return(1); } this is the solution before the program received the first statement validate null
0
votes
2answers
56 views

Caesar segmentation fault

I prematurely submitted my code without including the if() statements that check if the second command line argument was a digit (if not it would produce an error message). My code was running ...
0
votes
1answer
40 views

Help with Either Command Line Argument or Arrays for Problem set 2 Caesar

I am on Problem Set 2: Caesar. Right now I'm trying to write code that first checks if the second command line argument is a int and if it does prints the integer. I got my program to compile after ...
0
votes
2answers
48 views

Caesar Error:Invalid operands to binary expression ('string' (aka 'char *') and 'int') int c = ((int)text + argv[1]) % 26

There are a few errors in my code, but the one I really don't understand is `caesar.c:25:42: error: invalid operands to binary expression ('string' (aka 'char *') and 'int') int c = ((int)...
0
votes
2answers
98 views

Caesar : Extra random characters at the end of a char ciphertext array

I'm having a problem with an output. Sometimes output adds an extra characters, different each time the code runs. For example, when I use key "1" and write "a", it displays "...
0
votes
1answer
71 views

error: use of undeclared identifier 'argv' in Caesar

I dont know why this is wrong because it always says Caesar.c:17:13: error: use of undeclared identifier 'argv' even though it works for the ones before. #include <cs50.h> #include <stdio.h&...
0
votes
1answer
25 views

Having Trouble using StrCpy with Command Line argument for Problem Set 2 Caesar. Trouble with Array

Hello I'm still fairly raw at this coding thing so i'm sure im making rookie mistakes. I'm doing Problem Set 2 caesar and I've hit a wall and haven't been able to move forward. What I have been trying ...
0
votes
1answer
29 views

pset 3 caesar - output looks fine but check50 returns errors

PS2 caesar to output ciphertext works fine, and outputs all texts as expected - however check50 returns poor score. //Code is: #include <stdio.h> #include <cs50.h> #include <string.h>...
0
votes
1answer
37 views

PSET2, Caesar (less)

My code to assess whether the command-line argument consists solely of digits compiles but doesn't work properly, and I can't figure out exactly what the problem is. Even if I enter an integer-only ...
0
votes
1answer
26 views

Expected output and output are the same, yet the program somehow isn't correct. Caesar

This is my code: for(int i = 0, len = strlen(plaintext); i < len; i++) { char c = plaintext[i]; if (isalpha(c)) { char p = 'A'; if (islower(c)) { p =...
0
votes
1answer
44 views

Why doesn't my Caesar code work?

#include <cs50.h> #include <stdio.h> #include <ctype.h> #include <string.h> #include <stdlib.h> #include <math.h> bool string_validity(string s); int main(int ...
0
votes
1answer
18 views

Caesar scoping. variable len not defined, yet it works

The code is following: #include <stdio.h> #include <cs50.h> #include <math.h> #include <string.h> #include <stdlib.h> #include <ctype.h> bool key_validity(string s)...
0
votes
1answer
39 views

:( handles lack of key failed to execute program due to segmentation fault

The following piece of code I've written for pset2/caesar produces a "segmentation error" when there is a lack of key (when no command-line argument is provided). I don't know which line or ...
0
votes
1answer
49 views

I'm stuck at PSet 2 Caesar Cipher: The alphabets don't follow my modulo 26. It goes beyond it, printing non-alphabetic characters

The crux is at the last part where I've commented "CONVERT PLAINTEXT TO CIPHERTEXT" The variable asciiValue holds the, well, the asciiValue of the enciphered character. As you can see, I've ...
0
votes
0answers
38 views

pset2/caesar handles lack of key failed to execute program due to segmentation fault [duplicate]

#include <cs50.h> #include <math.h> #include <stdio.h> #include <string.h> int key(string input); int main(int argc, string argv[]) { int l = strlen(argv[1]); int ...
0
votes
1answer
24 views

Why is it that I keep getting segmentation fault? (Problem set 2 - Caesar)

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

CS50 Pset 2 Caesar: :( handles non-numeric key timed out while waiting for program to exit

My code seems to compile fine but when I try checkcs50, it says: :( handles non-numeric key timed out while waiting for program to exit, what do you think the problem is? #include <stdio.h> #...
0
votes
2answers
19 views

PSET 2 Caesar: Permission denied problem

I'm having trouble running my code because of a permission denial...Could someone please help me? THanks :) Here's my code: #include <stdio.h> #include <ctype.h> #include <cs50.h> #...
0
votes
1answer
21 views

How to print the output in Caesar(Pset2)?

here's my code #include <stdio.h> #include <cs50.h> #include <ctype.h> #include <string.h> #include <stdlib.h> int main(int argc, string argv[]) { // prints Usage : ...
0
votes
1answer
33 views

Why do I get a segmentation fault? CS50 PSet2 - Caesar

Here is my code. #include <stdio.h> #include <math.h> #include <cs50.h> #include <string.h> #include <stdlib.h> int i = 0; int k = 0; string ciphertext; int main(int ...
1
vote
2answers
84 views

I truly confused on why ceaser won't work,

#include <stdio.h> #include <cs50.h> #include <math.h> #include <string.h> #include <ctype.h> #include <stdlib.h> //atoi ? bool is_valid_key( string s); // ...
0
votes
1answer
27 views

I've been trying to submit ceaser and it won't compile can someone help?

#include <stdio.h> #include <cs50.h> #include <math.h> #include <string.h> #include <ctype.h> #include <stdlib.h> //atoi ? bool is_valid_key( string s); // ...
0
votes
1answer
36 views

Getting a "seg fault" on Caesar, Pset2

This is my code for Ceasar (pset2) of cs50. Whenever I try to make the program, I get a control may reach end of non-void function Could you help me with this? #include <stdio.h> #include <...
0
votes
1answer
59 views

Caesar prints out the desired output but fails the check50

I managed to write the code for caesar and it presents the desired values as output. However, when I execute check50, apart from a smiley on all other points, this is what I get: :( handles non-...
0
votes
1answer
41 views

caesar pset 2 non-numeric key error even when it works well when i try it myself

Here is my code which works well even with non-numeric key. #include <stdio.h> #include <cs50.h> #include <stdlib.h> #include <ctype.h> #include <string.h> bool key_check(...
0
votes
1answer
25 views

Caesar Code Complies when I think it shouldn't

One of the lines of my code is this - if (isupper(plaintext[j])) { int cap_end = (plaintext[j] - (int) 'A' + atoi(argv[1]))%26 + (int) 'A'; printf("%c", (char) cap_end)...
0
votes
1answer
45 views

Errors in Caesar pset2 and Wrong Output

I am almost finished with Caesar only a couple of issues persist which I am unable to overcome Here is my code - #include <stdio.h> #include <cs50.h> #include <stdlib.h> #include <...
0
votes
1answer
57 views

Trying to implement itoa function in pset2 caesar

While working on Caesar i realized i needed a function to convert an int to a string and searched online. The first one I came across was the itoa function but it turned out it wasn't a standard ...
0
votes
1answer
28 views

Segmentation Error while Using if Statement for Pset2 Caesar

I have been working on Caesar for some time now and tried to use different loops but I am getting Segmentation Errors. #include <stdio.h> #include <cs50.h> #include <stdlib.h> #...
0
votes
2answers
71 views

Caesar pset2 How to Reprompt user for Command Line Argument?

I have started working on Caesar and I am stuck with how to repromt user for a command line argument incase they input some wrong values. Here is the code i wrote and I can't find any apparent errors #...
0
votes
1answer
56 views

why am i getting a non numeric key error? cs50 caesar

i have been trying to do this for a month and i am finaly down to my last error message when i run my check 50.the error message is :( handles non-numeric key timed out while waiting for program to ...
0
votes
1answer
32 views

Having trouble identifying non-decimal digit in Caesar PSET 2

I'm working on Caesar from Problem Set 2. I have done the first step to check for a single command line argument, but I'm stuck on how to check the argument to see if any characters are non - decimal ...
0
votes
1answer
98 views

Why is it a segmentation fault when argc is 1 only i.e if I input "./caesar" only? It contains some other errors as well given in screenshot

My program perfectly encrypts texts if user gives a key or enters a wrong key such as an alphabet. But if argc is 1, then I incur a segmentation fault. I also incur a few other problems when I apply ...

1
2 3 4 5
9