[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
>int main() >return 0 What did he mean by this?
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 33
Thread images: 4
File: CPlusPlus.jpg (36 KB, 433x455) Image search: [Google]
CPlusPlus.jpg
36 KB, 433x455
>int main()
>return 0

What did he mean by this?
>>
>>55169829
He meant the program had finished successfully with no errors. Otherwise that program returned a non-zero value.
>>
>>55169829
the function main expects a return value of type integer when it finishes execution. return 0 basically means everything happened as expected, and is a value that you can check to make sure it did. anything other than 0 probably means something bad happened.
>>
>>55169829
Return 0 as the result to the calling program.
>>
main:
mov ax 4c00h
int 21h


what did he mean by this?
>>
>>55170143
Some system call
>>
>>55170143
    movl $1, %eax
movl $0, %ebx
int $0x80



what did he mean by this?
>>
>>55170159
See >>55170151
>>
>>55170166
>>55170151
>please explain what this code does
>it uhhhhhh like it does something
>>
>>55170176
>"what did he mean by this" = "please explain"
no, take your silly memes back to /b/
>>
>>55170182
Your response is meaningless either way. If you treat it as a proper question, you have to reply properly. If you treat it as a worthless meme, then there is no need to respond.
>>
>>55170192
If my response is meaningless, then your response to my response is meta-meaningless.
>>
>>55170199
meta is a lie
>>
>>55170159

wtf? Why did you initialise your soundblaster? Or am I reading this wrong...

http://www.ctyme.com/intr/int-80.htm
>>
File: 1454910853343.gif (3 MB, 400x225) Image search: [Google]
1454910853343.gif
3 MB, 400x225
Does anyone here use return as a substitute for global scoping?
>>
>>55170255
>http://www.ctyme.com/intr/int-80.htm
>Int 80 - Linux - SYSTEM CALLS
>Why did you initialise your soundblaster?

>Or am I reading this wrong
what did he mean by this?
>>
>>55170279
>what did he mean by this?
what did he mean by this?
>>
>>55170276
You can't use return as a substitute for global scoping, so no, no one here does that.
>>
Tying to learn C++

Do a lot of Ruby and JS right now.

I just bought "The C++ Programming Language 4th Edition"

Did I make the right choice?
>>
>>55170305
what did he mean by this?
>>
File: 1464394607057.gif (2 MB, 450x450) Image search: [Google]
1464394607057.gif
2 MB, 450x450
>>55170313
what did you mean by this?
>>
>>55170323
i don't know

what did she mean by that?
>>
File: 02099d01f4.jpg (69 KB, 631x435) Image search: [Google]
02099d01f4.jpg
69 KB, 631x435
>>55170329
>>55170323
>>55170313
>>55170285
>>55170279
>>55170159
>>55170143
>>55169829
>>
>>55170288
I do all the time in python

def kfkkfkfkfkf():
name = 'fag'
print("you'er a fag")
return fag
def jfjfjjfjfjfjjfjfjfj():
name = kfkkfkfkfkf()
print(name)
jfjfjjfjfjfjjfjfjfj()
>>
People in this thread say if main returns anything but 0, it's not good and means something went wrong.
But:
It will always return 0 because you wrote return 0;

How can it return anything else?
>>
>>55170376
Your code is broken, and even if was not, it doesn't demonstrate return as a substitute for global scoping.
>>
>>55170384
Cosmic rays flipping the bits
>>
>>55170384
Memory corruption on levels unheard of
>>
>>55170384
If during the execution of your program you want to notify whoever started your program that something went wrong, for example, you wanted to write a configuration, file to disk but was denied by OS, you return a non-zero value from main. If you yourself don't return that value, no one will for you (apart from some very specific cases).

So, to answer your question, this program always returns 0 because the programmer decided that nothing can go wrong in it.
>>
>>55170438
He should return 5 because he's lol so random
>>
>>55170645
That's actually more acceptable that returning 5 as a result of min function. At least you can document it and it won't fuck up anything for user who reads documentation.
>>
$ cat retval.cpp
int main() {
return 69;
}
$ g++ retval.cpp
$ ./a.out
$ echo $?
69


???????????????????
>>
>>55170859
Ah, the good old 69 - mount error.
Thread replies: 33
Thread images: 4

banner
banner
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y] [Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.