[C]: printf / scanf functions are evil
1
Name:
Anonymous
2009-10-19 20:47
I'm just starting to learn C and the first exercise made in class was to make a program that prints the sum of two integers.
This program:
#include <stdio.h>
#include <stdlib.h>
int main (void) {
int n1,n2;
printf("1st int: ");
scanf("%d",&n1);
printf("2nd int: ");
scanf("%d",&n2);
printf("Sum = %d\n",n1+n2);
return EXIT_SUCCESS;
}
I showed it to some of my older classmates and went batshit insane with it saying: DO NOT USE PRINTF AND SCANF, THEY ARE NOT FUCKING SAME and other stuff.
Will someone please input on this matter?
Thank you!
41
Name:
Anonymous
2009-10-20 12:39
42
Name:
Anonymous
2009-10-20 13:47
>>38
Has never reversed any Korean protocol or executable. Return to the board whence you came, please.
43
Name:
Anonymous
2009-10-20 14:56
>>42
Koreans have their own executable formats?
44
Name:
Anonymous
2009-10-20 15:20
>>43
yes they come in 7.62 and 5.56 millimeter sizes in a variety of lengths
45
Name:
Anonymous
2009-10-20 15:26
>>42
Yeahh, Japanese protocols and code are so much better
!!
46
Name:
Anonymous
2009-10-20 15:37
47
Name:
Anonymous
2009-10-20 16:18
48
Name:
Anonymous
2009-10-20 16:28
>>47
coders and guns
go together like
beer and breakfast
son
49
Name:
Anonymous
2009-10-20 16:46
>>48
back to
/howToBeAHaxxor/,
esr
50
Name:
Anonymous
2009-10-20 16:53
>>49
Say that to my Heckler and Koch MR556 in person and see what happens.
51
Name:
Anonymous
2009-10-20 18:04
>>50
Are you serious? gtfo
52
Name:
Meme Explainer
2009-10-20 19:08
>>51
>>50 was referring to the popular ``Say that to my face'' meme, which originated on the /v/ - Video Games - 4chan image boards.
53
Name:
Anonymous
2009-10-20 19:09
>>51
____ _____ _ _ ___ ____
| _ \| ____| \ | |_ _/ ___|
| |_) | _| | \| || |\___ \
| __/| |___| |\ || | ___) |
|_| |_____|_| \_|___|____/
54
Name:
Anonymous
2009-10-20 19:36
>>53
______________
< U MENA PENIS >
--------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
55
Name:
UMH memesmith
!gNlkr4vCuc
2009-10-20 19:48
56
Name:
Leah Culver
!1LEahRIBg.
2009-10-20 19:53
>>55
Oh shut the hell up
UMH memesmith it's out of your hands and bitching won't solve anything.
57
Name:
Anonymous
2009-10-20 20:13
>>54-56
Failed attempt at … I hardly know where to start. A life, I guess.
58
Name:
Anonymous
2009-10-20 21:10
>>57
Starting a life is a job for either a Lisp program, or a real woman with ovaries.
59
Name:
Anonymous
2009-10-22 11:22
WILL SOME ONE JUST FUCKING FIX OP'S PROGRAM?!
60
Name:
Anonymous
2009-10-22 11:24
61
Name:
Anonymous
2009-10-22 12:48
62
Name:
Anonymous
2009-10-22 13:51
;; >>59
;; Sure thing bro
(defun prompt (prompt)
(princ prompt *query-io*)
(read *query-io*))
(format t "Sum = ~a"
(+ (prompt "1st int: ")
(prompt "2nd int: ")))
63
Name:
Anonymous
2009-10-22 13:52
>>62
Now do it with
(let).
64
Name:
Anonymous
2009-10-22 15:06
>>62
CL-USER> ;; Sure thing bro
(defun prompt (prompt)
(princ prompt *query-io*)
(read *query-io*))
(format t "Sum = ~a"
(+ (prompt "1st int: ")
(prompt "2nd int: ")))
1st int: #. (loop (print (eval (read))))
(princ "I haxed your anus!")
I haxed your anus!
"I haxed your anus!"
65
Name:
Anonymous
2009-10-22 16:28
>>59
-- Sure thing bro
import System.IO
main = mapM (\p -> putStr p >> hFlush stdout >> getLine >>= readIO) ["Int 1: ", "Int 2: "] >>= print . sum
66
Name:
Anonymous
2009-10-22 17:31
>>59
# Sure thing bro
say<>+<>
67
Name:
Anonymous
2009-10-22 17:59
>>65
import System.IO
main = mapM ((>>readLn) . (>>hFlush stdout) . putStr) ["1st int: ","2nd int: "] >>= putStrLn . ("Sun = "++) . show . sum
68
Name:
Anonymous
2009-10-25 20:46
>>66
Invalid perl code
:(
69
Name:
Anonymous
2009-10-25 21:00
>>66
This only works if you hit
ctrl+D after typing in the numbers.
70
Name:
Anonymous
2009-10-25 21:32
Sure thing, bros.
10 INPUT "1st int: ", n1%
20 INPUT "2nd int: ", n2%
30 PRINT "Sum = ", n1% + n2%
71
Name:
Anonymous
2009-10-26 1:16
>>68
It works inside a
-E at least. If you're actually running it as a file you need a version declaration. :(
Or you could do it the
old way: print<>+<>,"\n"
>>69
No, lern2perl.
72
Name:
Anonymous
2009-10-26 22:26
>>70
Hook me up with the QBasic interpreter
73
Name:
Anonymous
2009-10-27 0:34
74
Name:
Anonymous
2009-10-27 7:49
(defmacro twice (f x)
`(,f ,@`(,x ,x)))
(twice + (read))
75
Name:
Anonymous
2009-10-27 11:39
>>74
And people say Perl has too many punctuation marks.
76
Name:
Anonymous
2009-10-27 12:15
>> 75 eh, there's not much shit in the standard readtable
77
Name:
Anonymous
2009-10-27 16:03
>>75
eval "eval \"eval \\\"print \\\\\"Sure, whatever\\\\\"\\\"\"";
78
Name:
Anonymous
2009-10-27 16:08
79
Name:
Anonymous
2009-10-27 16:38
>>77
compose n f
| n < 1 = f
| otherwise = f . compose (n - 1) f
main = putStrLn . compose 9 show $ "Sure, whatever"
80
Name:
Anonymous
2009-10-27 17:02
fix show
Newer Posts