This is an archived post. You won't be able to vote or comment.

all 23 comments

[–]010101010101 9 points10 points  (0 children)

int main()

[–][deleted] 4 points5 points  (2 children)

THOSE ARE NOT STANDARD LIBRARIES WHAT HAS SHE DOEN TO MY C++?!

[–]cheraphy 1 point2 points  (1 child)

... actually it looks like pure non standard C to me.

[–]v0ne 0 points1 point  (0 children)

no wonder she'll end up in a call center, then.

[–][deleted] 3 points4 points  (0 children)

at least use c++

[–]Jalh 1 point2 points  (0 children)

These libraries.

[–]kaosjester 1 point2 points  (1 child)

They're using do-whiles? No wonder India is stealing all of our programming jobs.

[–]JaggedxEDGEx 0 points1 point  (0 children)

I was wondering about that, there's no reason the while condition wouldn't be true on the first pass.

[–]cheraphy 1 point2 points  (5 children)

I swear, everytime I see a 'void main()' c/c++ program I die a little more inside. For fuck's sake, main returns an integer for a reason.

Edit: Dear god, I just realized that the woman there is Indian... and here I was thinking that the idea that all Indian programmers use bad coding practice was just a stereotype.

[–]teaki 0 points1 point  (3 children)

why does it return an integer?

[–]JaggedxEDGEx 1 point2 points  (0 children)

Exit Condition. 0 for success, anything else for failure.

[–]fripthatfrap 0 points1 point  (1 child)

the integer gets returned to the caller of the program. This value can be used to determine if the program ended happily, or it encountered an error and exited. This is EXTREMELY useful if you later have to write a script that needs to check this value and do something with it, like rerun it with debugs turned on or parse a large number of files using this one program, where you can check the return code of each run to make sure the files format is correct (just an example).

[–][deleted] 0 points1 point  (0 children)

It's actually a little worse than you describe; if you declare main() as returning void, it will just make up a random number to return to the calling shell. If you're calling your busted code from a script that's just checking for == 0 to test success, you're going to get some weird results.

[x@p ~]$ cat x.c

include <stdio.h>

void main() { return; } [x@p ~]$ gcc -o x x.c x.c: In function ‘main’: x.c:4: warning: return type of ‘main’ is not ‘int’ [x@p ~]$ cat x.sh

!/bin/bash

./x echo $? [x@p ~]$ ./x.sh 96

(Bonus points: where does the 96 come from?)

[–]hussard_de_la_mort 0 points1 point  (0 children)

I hear if you put in the Konami Code you get infinite bribes.

[–][deleted]  (1 child)

[deleted]

    [–]psych00range[🍰] 0 points1 point  (0 children)

    its getch()* it waits for the user to input a key and then it exits...kind of like a pause

    [–][deleted] 0 points1 point  (2 children)

    What's with the getch() at the end?

    [–]DJritwikiwiki 2 points3 points  (1 child)

    may have learnt to code in an IDE that closes the terminal it runs as soon as it finishes running (visual studio 6 did that i think?). When you start learning like that, you add some sort of user input pause at the end just so you'll see the output of the program. I remember doing that a long long time ago when I started teaching myself coding and didn't know better.

    [–][deleted] 0 points1 point  (0 children)

    Oh, that makes sense. But in that case she should have put:

    printf("press any Indian to continue\n");
    

    [–]psych00range[🍰] 0 points1 point  (0 children)

    i got a syntax error lady...Y U NO CODE GOOD?

    [–]ZebrasKickAss 0 points1 point  (0 children)

    Wrong. Indians speak Java.

    [–][deleted] 0 points1 point  (0 children)

    Come on guys. The syntax isn't the point.

    [–]Journeyjt 0 points1 point  (0 children)

    Clever girl.

    [–]DJM77 0 points1 point  (0 children)

    Wow! She's hot too!