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 ...
user avatar
  • 64.2k
1 vote

still needing help with mario

I think you have it the other way around, you are getting the correct number of lines (height n) but the wrong combination of characters per line. Your code generates 4 a's and 2 #'s for each line. ...
user avatar
  • 1,415
1 vote
Accepted

Why does this become an infinite loop?

The infinite loop lies here: while(j < rows) { printf("#"); (i++); } The loop depends on the value of j being updated and eventually not less than rows. Since j is never changed ...
user avatar
  • 64.2k
1 vote

pset1 cash less, problem using for loops

Normal practice is to use a for loop when the number of passes is well defined, either by a hard coded value or by a value contained in a variable. When the number of passes is based on a condition or ...
user avatar
  • 64.2k
1 vote
Accepted

pset1 cash less, problem using for loops

You need a semicolon immediately after each for loop. Otherwise, all the statements until the next semicolon are considered the body of that for loop. The compiler will complain if you put a semicolon ...
user avatar
  • 165
1 vote
Accepted

My for loop in vigenere will not execute

Is this strlen(plainText - 1) really what you want? You want one less than the length of plainText. This is subracting 1 from plainText and calling strlen on the result. Methinks it always returns 0, ...
user avatar
1 vote

Decreasing For Loops

let's read what the loop says, "run while the condition is true, ie while h is less or equal to zero" which obviously is not fulfilled. a for does not care if you increase or decrease the index, it is ...
user avatar
  • 5,172
1 vote
Accepted

PSET2 Caesar Bug in Uppercase Case For Loop

I've been trying to step through the code to duplicate what happens with no success, but I have a couple ideas. First, look at the following: if (plain [i] >= 66 || plain[i] <=90) //case for ...
user avatar
  • 64.2k
1 vote
Accepted

for cicle itrations

Here's a problem: sizeof(name). name is a pointer, sizeof(a pointer) is 8. You probably want the length of name. (Think strlen included in string.h).
user avatar
1 vote
Accepted

won function does not seem to return true (even though it should)

Why do you loop till j < d - 1 not j < d? For board 3*3, you miss board[0][2] so should return false for board[1][0]. However, I do not understand why you are stack in an infinite loop. You ...
user avatar
  • 1,139

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