Hot answers tagged

2 votes
Accepted

pset2 caesar, argv[1]

It's always the problems that hide in plain sight that get us! ;-) isdigit() is working exactly as expected. If a character is a digit, it returns a non-zero (not necessarily 1, try printing the ...
  • 64.7k
1 vote

Caesar segmentation fault

In other words, the isdigit() function (and all of it's issomething() cousins) takes a single char as input. If you pass it a string, it chokes and generates a seg fault. Otherwise, @MARS gave a ...
  • 64.7k
1 vote
Accepted

Segmentation fault: Pset 2 Caeser isdigit

The actual problem isn't in the isdigit statement. It's in the for statement. for(int i = 0, n = (strlen(argv[1])); i < n; i++) If there is no parameter, then argv[1] doesn't exist. So, strlen ...
  • 64.7k
1 vote
Accepted

PSET2 Caesar - Stuck at 'isdigit' step: Do I need to learn about pointers, or is something else going on?

Its a simple and common issue with new programmers. ;-) Yes, argv[] is an array of strings. So, argv[1] is a string. Now, say that argv[1] contains the string "cat". Then argv[1][0] ...
  • 64.7k
1 vote

pset2 (ceasar) - isdigit function not working correctly returns "expected expression" error

It seems correct because it is. The 'expected expression' error is almost always because of misplaced, missing or extra curly braces or parentheses. Is it possible that you're editing one version of ...
  • 64.7k
1 vote
Accepted

Caesar: Validating the key - stuck

argv[] is a list of arguments introduced from the comand line. If you want to itterate through ever char in a particular argument you can do it by: argv[x][i] where x is the argument number and 'i' ...
  • 1,561
1 vote
Accepted

pset2 how to use ctype.h functions

isalpha() takes a single character. When you try to jam a complete string down its throat, it chokes and coughs up a seg fault. You need to loop through the string and test each char individually. If ...

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