What's the point of function arguments when you can just use pointers?

what's the point of function arguments when you can just use pointers?

int *ip

int func2(void)
{
int y = 2;
ip = &y
return *ip;
}

int main(void)
{
int x = 44;
ip = &x;
fun2();
return 0;
}

Attached: 1508729826113.jpg (600x600, 57K)

Other urls found in this thread:

what.thedailywtf.com/topic/15001/enlightened
se.rit.edu/~tabeec/RIT_441/Resources_files/How To Write Unmaintainable Code.pdf
en.wikipedia.org/wiki/Structured_programming
twitter.com/NSFWRedditVideo

is this bait?

no serious question. i understand why main would need args but why would anything else need args?

Because then it's harder to follow what's going on in your code and debug.

>Whats the point of scoping when you can just make everything global and create better names
>Why are functions even a thing when you can just copy paste

what's the point of functions when you can just use goto

what's the point of function arguments when you can just use globals?

Wasn't there a machine that bugged out and would give people massive amounts of radiation doses, and when they did a code analysis they found thousands of global variables?

is there anything wrong with making variables global? like making a global pointer? i mean security wise is that not good?

The problem with global variables is that since every function has access to these, it becomes increasingly hard to figure out which functions actually read and write these variables.

To understand how the application works, you pretty much have to take into account every function which modifies the global state. That can be done, but as the application grows it will get harder to the point of being virtually impossible (or at least a complete waste of time).

If you don't rely on global variables, you can pass state around between different functions as needed. That way you stand a much better chance of understanding what each function does, as you don't need to take the global state into account.

making variables global or not has little to do with security.
it's just a question of structuring your code in such a way as to eliminate potential unexpected behaviour and errors.

lol im just going to start using void pointers for everything.

Attached: jWr67J8.png (991x806, 111K)

This
When I was learning C++ I only knew basic so goto was easier for me to understand at the time

H1Bs at work did this. We still haven't recovered.

what is the point of C if you can use assembly

Attached: ggg.png (991x806, 145K)

Functions should be black boxes wherever possible to aid in abstraction and, given a point in code, the ability to understand how you got there.

why not just obfuscate everything and create such a complex monstrosity that only you can understand it thus gauranteeing yourself job security?

I guess he mean that in a large codebase, would be useless to do

Hehe(&value){
value++
}

Int a;
Hehe(a);

Because it is crearly seen you need to modify that variable.
But hence, then, why constants exist?

>this code gave me cancer

Evas_Object*

Write a recursive function.

fucking kek

I'm baffled that someone would even ask this fucking stupid a question let alone actually be serious about it. Have you never written a program larger than that code snippet you posted or are you just absolutely dumb?
>brainlet wojak attachment
Oh, nevermind. I get it now. Fuck off back to a video game board, will you?

What's the point of for when you can just use while and increment?

>someone doesn't know a thing? Baffling!
How about you fuck off to your competitive cock sucking competitions at Berkeley.

>I can't answer his question b/c I'm secretly a brainlet too – hold on maybe if I make fun of him enough everyone else will think that I know the answer.
>dur brainlet wojak /v/ you don't write enterprise java like me

Attached: 1524709885324.jpg (1171x936, 87K)

I hate neo/g/
you fags are worse than cancer

>Commit:
>Save the stack from fragmentation
>+void * StdObj1;
>+void * StdObj2;
>+void ** StdObjSwitch;
>Years later
>"omg nobody can figure this out, std keeps crashing after we changed it???"

Attached: 1503993162566.png (485x443, 64K)

Aside from what others mention, it disables certain optimizations and cripples APIs.
Imagine you wanted to embed CPython into an application of yours and wanted to have one interpreter per tab/buffer. You can't because you can not handle interpreter instances, instead the PyInit function creates a hidden global.

what.thedailywtf.com/topic/15001/enlightened
In fact, everyone who tries to do polymorphism and dynamic dispatch in a language that doesn't support it has it coming.

What's the point of while when you can just use for?

Because after a while you yourself won't be able to understand your own code.

It's convenience just as for/while loops are merely different writing styles for
0 #startofaloop
loop Code
if(expr) JumpTo 0

makes it faster to write code, that's all it is. Otherwise you would have to fuck arround a lot more = more errors.

>A calls B
>B calls C
>C calls B
Now the arguments A called B with are fucked. Congrats.

And, of course, the obvious point which somehow nobody managed to mention, now that I look at it, is your approach can't be used in a multi-thread environment.

Because pajeets can’t into for loops

evas object

why not?

he he he he

se.rit.edu/~tabeec/RIT_441/Resources_files/How To Write Unmaintainable Code.pdf

if any of you want a laugh

OP clearly knows what arguments are, and any retard can see the benefits of knowing exactly what a function takes in and operates on without having to sift through the code and consult a table of global variables to see what's actually being manipulated.

This isn't a knowledge thing, this is an utter retardation thing. Doesn't matter how many frogs you samefag with.

You can't replace do-while with for sometimes.

K&R gives a simple explanation

Attached: Screenshot from 2018-05-07 01-52-36.png (946x98, 24K)

>what is reentrancy
OP is a nigger.

What's the point of types when everything is just bytes

en.wikipedia.org/wiki/Structured_programming

This is undefined behaviour.

f(g(x),g(y))

trole hard

Memory leak and/or undefined behavior

Plz don't program anything

Fucking evil

This. This guy know how it's done.

why don't you just encrypt your code and decrypt it within the build system so that if you leave the company everything is lost

>not including a crypto miner (written in the most obfuscated way, encrypted and only decrypted at runtime) in your code AFTER compiling so when you leave the company your pajeet successor gets sent to prison while a few years later after nobody cares anymore you can safely cash out and transfer to Monero
>

This is the simplest explanation I can think of.