5 votes
Accepted

Segmentation fault in Substitution - Problem Set 2

Think about what this code is doing; int main(int argc, string argv[]) { int n = strlen(argv[1]); If there's no argument, then argv[1] doesn't exist. Trying to access it generates a seg fault. ...
Cliff B's user avatar
  • 68.7k
3 votes

Pset2 - Receiving different outputs each time I run my code- Vigenere.c

When encrypt[n] is declared, it doesn't allow for the end of string marker at the end. Also, the end of string marker is never added to the string, so when it is printed at the end of the program, ...
Cliff B's user avatar
  • 68.7k
2 votes
Accepted

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

There are a number of problems with this code. Let's deal with your question first. The code is constructed as a nested pair of loops. The outer for loop will loop over the length of the plain text ...
Cliff B's user avatar
  • 68.7k
2 votes

Getting initials from a name

You want hints? Except for the first initial, what character is always before every initial? There are a lot of library functions out there, some that you should look at now, like tolower(), ...
Cliff B's user avatar
  • 68.7k
1 vote
Accepted

Caesar Pset2 Handles non-numeric key :(

First of all, the code MUST check for lack of a key, i.e., a valid number of parameters by checking the value of argc FIRST!!! Right now, the code is trying to use argv[1] before checking the value of ...
Cliff B's user avatar
  • 68.7k
1 vote
Accepted

Counting words pset2 Readability

I'd test exactly for a space (ie text[i] == ' ') rather than isblank and adding 1 at the end is expected, since if you have text like "Hello there", you'll count 1 space but there are 2 words. Just ...
curiouskiwi's user avatar
  • 18.7k
1 vote

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

I would recommend you to do this problem set in one for loop. You can just loop through the plaintext. Using nested loops will make the problem more complicates than you think. It's because you only ...
Jn Wu's user avatar
  • 55
1 vote

I am not sure about the error message

Without seeing the actual error message or the related code, this is a problem: printf("%c", toupper(s[(int)(' ')]i++)); There is one placeholder in the format string, the %s, but the value to be ...
Cliff B's user avatar
  • 68.7k
1 vote
Accepted

Pset 2 - vegenere

The good news is that you got the concept right. J needs to be reset at a certain point. The problem with that lies here: if (j >= strlen(k) - 1) Why - 1??? There is an additional problem ...
Cliff B's user avatar
  • 68.7k
1 vote
Accepted

vigenere error:expected prompt for input, found none

Use <, not <=, in your loop. For i being strlen(argv[1]), argv[1][i] is '\0', which is not alphabetic, so you leave the function (and end the programme).
Blauelf's user avatar
  • 20.9k
1 vote
Accepted

pset2//caesar- relational operator result unused error

First to the error: i<len,k>=0 uses the comma operator, which evaluates its left side, discards the result, and evaluates to its right side. So i<len,k>=0 is the same as k>=0, the value ...
Blauelf's user avatar
  • 20.9k
1 vote

Hello, I am getting this error in Vigenere cipher (pset2), please help!

According to the spec, the key should only be advanced when it is used. Considering that, when you print a special character (non-alphabetical), as well as making sure that it is printed unchanged, ...
Steve Bunting's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible