Skip to main content
3 votes
Accepted

trail of strange characters after printing character array

Uhhuh. I see that it is doing a nice job of encoding and storing the encoded characters in an array. But have you also stored the end of string marker '\0' at the end of the string? printf will ...
Cliff B's user avatar
  • 69k
2 votes
Accepted

Pset1 How to print variable to make sure input is correct?

When you say return dollars, your program gives an output = "dollars" and ends itself. The line of code after returning dollars is not even read. Just remove the return statement and try ...
Himanshi's user avatar
  • 401
2 votes
Accepted

I have written this code for vigenere and it is giving 02 errors

The problem is that argv is an array of strings, and you try to use it as a single string. See this line: if (!isalpha (argv[1][i])) and this: if (isupper (argv[j])) Can you spot the difference?
ChrisG's user avatar
  • 7,396
1 vote

printf printing an @ after a string

From man printf s If no l modifier is present: The const char * argument is expected to be a pointer to an array of character type (pointer to a string). Characters from the array are written up to (...
DinoCoderSaurus's user avatar
1 vote
Accepted

Numbers with printf -- sanity check

It's not a floating point problem, it's an integer problem. ;-) Look at this line: int l = 65 / 14 * 100; It contains all integers. Additionally, consider the precedence of operations - what ...
Cliff B's user avatar
  • 69k
1 vote
Accepted

Tideman, my tests work but check50 says there is an error

Your old code was going through the first n pairs, where n is the number of candidates, then checking if one of the winners of those pairs is the total winner. You can't assume that with n candidates, ...
Llenk's user avatar
  • 744
1 vote
Accepted

speller- tried using printf to debug -printf not working

This will (hopefully) explain this specific problem in main and perhaps the overriding problem. The output buffer is not "flushed" until a new line (or explicit flush). The answer provided here ...
DinoCoderSaurus's user avatar
1 vote
Accepted

Help in linked datastructure

You seem to ignore the value of found. Just disables the duplicate check. You don't have a loop for printing elements, and you seem to use ptr before initialisation. I would expect a loop very ...
Blauelf's user avatar
  • 21k
1 vote
Accepted

Why removing a printf function messes up with my code? CS50 pset1 cash greedy challenge

Could it be the missing line break? The output of printf("Your input: $ %.2f", a); printf(", which amounts to %i total.\n", cents); or equivalently printf("Your input: $ %.2f, which amounts to %i ...
Blauelf's user avatar
  • 21k
1 vote
Accepted

addition operation difference using printf in c

In the first case, you use a char variable, which in our case is an signed char by default, supporting values from -128 to 127. The result of your computation does not fit in, so it wraps around, ...
Blauelf's user avatar
  • 21k
1 vote
Accepted

Printing a character times a variable

Nope, can't do it that way. If you want to print multiple copies of a char based on a var's value, think for loop. If this answers your question, please click on the check mark to accept. Let's ...
Cliff B's user avatar
  • 69k
1 vote
Accepted

The question mark (????) example | Mario

The i is just a loop counter, and has nothing to do with the character printed. In C, char is an 8-bit integer (well, not 8 bit per standard, but 8 bit in every existing and relevant system), by ...
Blauelf's user avatar
  • 21k
1 vote
Accepted

Pset2 Crack - Including printf causes passwords I am generating to change

The problem was hiding somewhere else: // Create pword w/ max of 5 chars char pword[6]; pword[5] = '\0'; That means that the first 4 chars are whatever random garbage is in them when the char array ...
Cliff B's user avatar
  • 69k
1 vote
Accepted

Puzzled by Pset3 - find less confortable- sorting output

Whenever an unexpected value, particularly 0, suddenly appears in the sorted list and the largest value disappears, look for code that goes beyond the end of the array. This is a somewhat common ...
Cliff B's user avatar
  • 69k

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