Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

[C]: printf / scanf functions are evil

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!

Name: Anonymous 2009-10-20 12:39

>>40
Hangboo?

Name: Anonymous 2009-10-20 13:47

>>38
Has never reversed any Korean protocol or executable. Return to the board whence you came, please.

Name: Anonymous 2009-10-20 14:56

>>42
Koreans have their own executable formats?

Name: Anonymous 2009-10-20 15:20

>>43
yes they come in 7.62 and 5.56 millimeter sizes in a variety of lengths

Name: Anonymous 2009-10-20 15:26

>>42
Yeahh, Japanese protocols and code are so much better!!

Name: Anonymous 2009-10-20 15:37

>>39
this

Name: Anonymous 2009-10-20 16:18

>>44
back to /k/, please

Name: Anonymous 2009-10-20 16:28

>>47
coders and guns
go together like
beer and breakfast
son

Name: Anonymous 2009-10-20 16:46

>>48
back to /howToBeAHaxxor/, esr

Name: Anonymous 2009-10-20 16:53

>>49
Say that to my Heckler and Koch MR556 in person and see what happens.

Name: Anonymous 2009-10-20 18:04

>>50
Are you serious? gtfo

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.

Name: Anonymous 2009-10-20 19:09

>>51
 ____  _____ _   _ ___ ____ 
|  _ \| ____| \ | |_ _/ ___|
| |_) |  _| |  \| || |\___ \
|  __/| |___| |\  || | ___) |
|_|   |_____|_| \_|___|____/

Name: Anonymous 2009-10-20 19:36

>>53
______________
< U MENA PENIS >
 --------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

Name: UMH memesmith !gNlkr4vCuc 2009-10-20 19:48

>>54
ffff

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.

Name: Anonymous 2009-10-20 20:13

>>54-56
Failed attempt at … I hardly know where to start. A life, I guess.

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.

Name: Anonymous 2009-10-22 11:22

WILL SOME ONE JUST FUCKING FIX OP'S PROGRAM?!

Name: Anonymous 2009-10-22 11:24

>>59
No

Name: Anonymous 2009-10-22 12:48

>>59
Hi OP

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: ")))

Name: Anonymous 2009-10-22 13:52

>>62
Now do it with (let).

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!"

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

Name: Anonymous 2009-10-22 17:31

>>59
# Sure thing bro
say<>+<>

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

Name: Anonymous 2009-10-25 20:46

>>66
Invalid perl code :(

Name: Anonymous 2009-10-25 21:00

>>66
This only works if you hit ctrl+D after typing in the numbers.

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%

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.

Name: Anonymous 2009-10-26 22:26

>>70
Hook me up with the QBasic interpreter

Name: Anonymous 2009-10-27 0:34

Name: Anonymous 2009-10-27 7:49


(defmacro twice (f x)
 `(,f ,@`(,x ,x)))

(twice + (read))

Name: Anonymous 2009-10-27 11:39

>>74
And people say Perl has too many punctuation marks.

Name: Anonymous 2009-10-27 12:15

>> 75 eh, there's not much shit in the standard readtable

Name: Anonymous 2009-10-27 16:03

>>75
eval "eval \"eval \\\"print \\\\\"Sure, whatever\\\\\"\\\"\"";

Name: Anonymous 2009-10-27 16:08

>>77
EVAL MY ANUS

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"

Name: Anonymous 2009-10-27 17:02

fix show

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List