Timeline for PSET1, credit.c compiles just fine, runs just fine. But when I use check50 everything goes to hell. Would love fresh eyes to look at my code
Current License: CC BY-SA 3.0
11 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Nov 19, 2017 at 14:47 | vote | accept | phindex | ||
Nov 19, 2017 at 14:46 | answer | added | phindex | timeline score: 0 | |
Nov 14, 2017 at 18:38 | comment | added | KV88 | Hi, I have the same problem that my code gave correct results when I check each number myself but check50 failed. It seems to have grab the wrong version of my file but it is weird because I only have 1 credit.c and one credit file in the current directory when I ran check50. I am a complete newbie in CS. Anyone has any suggestion for me? THank you! Here is my code: link | |
Nov 5, 2017 at 3:18 | comment | added | Cliff B | Could one of you please post an "answer" and phindex, please accept it? Otherwise it'll sit in the unanswered question pool forever. | |
Oct 19, 2017 at 12:16 | comment | added | phindex | @Blauelf Ahh! Thank you so much! | |
Oct 19, 2017 at 12:09 | comment | added | Blauelf |
It has correct checksum, but 10 is in none of the ranges. The if-elseif chain needs a final else. Even though there are no checks, the specifications limit the valid digit counts for the different types, any card with a different length should be rejected, for example using if (cc / 10 == 4 && (digits == 13 || digits == 16)) { printf("VISA\n"); } else ... (obviously requires having the digit count first).
|
|
Oct 19, 2017 at 12:04 | history | edited | phindex | CC BY-SA 3.0 |
deleted 1185 characters in body
|
Oct 19, 2017 at 12:03 | comment | added | phindex | @Blauelf I'm an idiot. Sorry to have wasted your time. I assumed that I could check50 any file that I was working on. But every time I ran it, it was grabbing my old version! So now it passes check50 with no problems... despite the 42 and the 1000000000000008 anomalies. And now I'm confused in a whole new way... I'm looking at my code, and for the life of me I can't see how 1000000000000008 results in no output at all! | |
Oct 19, 2017 at 11:47 | comment | added | Blauelf |
Code and check50 output don't match. Is that really the same code? Maybe you forgot to save before running check50 , or are in a different file/directory? Also, what if credit card number has correct checksum but is not a credit card? Take for example 42 (VISA?), or 1000000000000008 (no output)
|
|
Oct 19, 2017 at 11:42 | history | edited | phindex | CC BY-SA 3.0 |
deleted 6 characters in body
|
Oct 19, 2017 at 11:31 | history | asked | phindex | CC BY-SA 3.0 |