[ 3 / biz / cgl / ck / diy / fa / g / ic / jp / lit / sci / tg / vr ] [ index / top / reports / report a bug ] [ 4plebs / archived.moe / rbt ]

Maintenance is complete! We got more disk space.
Become a Patron!

/g/ - Technology

View post   

[ Toggle deleted replies ]
File: 10 KB, 216x233, download.png [View same] [iqdb] [saucenao] [google] [report]
63380813 No.63380813 [Reply] [Original] [archived.moe] [rbt]

Why is C so hard and frustrating to grasp?


>> No.63380825

What are you having trouble with?

>> No.63380830

dont worry anon, just practise. You'll get there.

>> No.63380833

C is easy, stop being a brainlet.

>> No.63380853
File: 2.61 MB, 4125x2400, 1509848518053.png [View same] [iqdb] [saucenao] [google] [report]

Get a solid foundation in maths first + SICP then learning a language won't really be a problem.

>> No.63380866

>Racism isn't a problem, just stop being black.

>> No.63380878

>Get a solid foundation in maths + SICP
I tried reading SICP, I had to quit out of boredom

>> No.63380896

>Why is C so hard and frustrating to grasp?
Just how is that even possible, C is bare metal it does not even handle strings.

>> No.63380908

> False equivalency explains everything!

>> No.63380943

>Differential calculus is easy, just stop having genetically dispositioned inferior intelligence

>> No.63380974

Because you need to stop thinking like a human in strings, characters, decimals, and floats and start thinking like a machine with memory addresses and bytes.

>> No.63381013

Now that is... better. Not good, just better.

>> No.63381045
File: 146 KB, 388x400, 1509815205928-g.gif [View same] [iqdb] [saucenao] [google] [report]

pointers are numbers (almost always the native integer size) that just happen to correspond to another number in memory.
that number could be a char, an int, the first element of an array, or a struct, it doesn't matter, c's types will manage that for you.
pointer arithmetic is literally just one idea: adding an integer to a pointer gives you the pointer + the integer * the size of the type pointed to by the pointer.
i.e. for an int pointer on a platform with 4 byte ints, adding 1 to it will give you whatever it was + 4.
this only works with ints, subtracting two pointers will still give you the right value.

>> No.63381062

Don't just read shit.Use your imagination and do your own projects at your own pace.

>> No.63381095

Pointers only represent where a variable is stored in memory.
Their value is literally an address that says "this variable is stored here".

>> No.63381134

since we have so many C geniuses in this thread, anyone want to explain this shit to me?


>declare variable `err` of type patch_error
>assign some blank function to it that takes a bunch of variables
>check its output on the next line

where the fuck is the actual function that is run on line 529? how can you run a blank function?

>> No.63381152

He's not assigning the function, you flaming mongoloid.

He is calling the function, ergo err is assigned the return value from that call.

>> No.63381164

look at the function header. it's being passed in.
congratulations - you unlocked pointers

>> No.63381170

>where the fuck is the actual function that is run on line 529? how can you run a blank function?
It's a function pointer.

>> No.63381198

Ikr, I still cant make an autorun or a program without the use of an IDE
Fucking C, and they say its good for beginners

>> No.63381205

>Posting sci meme list
>Doesn't even include discrete maths
While anyone who doesn't know calculus is a dumb pajeet, discrete mathematics is a lot more important.

>> No.63381211
File: 260 KB, 639x639, 1510739455226.jpg [View same] [iqdb] [saucenao] [google] [report]

nigga i had more trouble with shit like C# than i did C, it's easy

>> No.63381234

o I see it. they called it "func". It was blue and a really generic name so I thought that was a special C keyword.

>> No.63381235

Try the triple ref video from computerphile.

>> No.63381247

> Doesn't even know about function pointers

This is why brainlets should be prohibited from programming in any serious language. Keep to your pythons and your basics.

>> No.63381269

How the fuck can you not understand pointers. If you understand how array indices work you know how pointers work. Because a pointer is literally an index on your memory.

Only difference is pointer arithmetic.

>> No.63381343
File: 6 KB, 248x247, 1480652820697.jpg [View same] [iqdb] [saucenao] [google] [report]

>tfw too stupid for programming
>tfw too stupid for math

>> No.63381382

>I had trouble with thing which is thing plus other thing than I had with just the other thing
You dont say

>> No.63381441
File: 57 KB, 919x720, meirl.jpg [View same] [iqdb] [saucenao] [google] [report]

>tfw too much of a brainlet to find a pdf version of "Logic: The Laws of Truth".
Does anyone have it? I can't seem to find it.

>> No.63381489

>Why is C so hard and frustrating to grasp?
It's not, it's just frustrating to use, since it is incomplete and half-assed.
And that aura of incomplete and half-assed infected the programmers using C and it shows in the tools, the ecosystem and the resulting software.

>> No.63381526

>too dumb for c
maybe go program with rust or sepples.

>> No.63381546
File: 35 KB, 621x960, 1502476979423.jpg [View same] [iqdb] [saucenao] [google] [report]

americans don't learn this at school

>> No.63381558

if you know how numbers work you know how pointers work. they are just numbers pointing at a memory address. it's the most simple concept ever yet people become drooling retards when they hear the word pointer

>> No.63381563


>> No.63381575

you're not too stupid for math. your school probably just does what all schools do: confusing you with superbly shitty math classes. ignore what you "learned" in school and do some of the meme courses on youtube. you will understand it in no time. math generally is pretty easy - mathtards just love inventing complicated sounding names for super easy concepts.

>> No.63381591

usually libgen.io has everything in multiple formats as well.

>> No.63381626


>> No.63381721

It is good to understand how the machine works.

It is good to start, but not "good for beginners" in the sense of being easy, it is one of the hardest languages to learn.

But if you get to understand C, you actually understand programming, with other easier languages you usually just become a code monkey that does stuff but doesn't understand them.

>> No.63381732 [DELETED] 

Because you're white

>> No.63381773

If so why every OS has security holes?

>> No.63381812

A lot of people have trouble with pointers at first. Just move on and keep trying to write small programs that manipulate them. Pactice will cement anything you want to learn.

>> No.63381852

C# is C with diabetes and a health regimen. So no shit

>> No.63381883

because building complex systems with many interacting parts is hard for humans? I'm impressed that modern OS don't have more holes

>> No.63381945

Why do people fall for this meme?

>> No.63382036

This, this to the highest degree, holy shit.

I thought I was a fucking idiot in Math, that my brain just wasn't "built" for it. I had a shitty math education in school and my fundamentals were never really cemented, so I nearly abandoned programming in college because of it.

I grew up a little bit and started applying myself. Looked up videos online from people who actually knew how to teach and all of a sudden, I'm not acing Math classes left and right.

After you get past a certain hill, the difficult just plateaus. You see that it isn't as big and scary as you thought.

>> No.63382048

>I'm now* acing math classes left and right

>> No.63382318

care to tell more about your trip? what stuff did you see and such?
I'm interested.

>> No.63383900


>> No.63383933

Because C is a very simple, very fast and horribly outdated programming language.
Using C for critical software is fucking moronic.

>> No.63383978

>it is one of the hardest languages to learn.
Why so, it's pretty simple.
People who say they don't understand C but know other languages in fact don't understand either. They only pretend to understand something but write code by copypasting examples and are clueless about what's actually going on. If you can't handle C, you better pull out or remain codemonkey forever.

>> No.63384011

>pointers are numbers
wrong! stopped reading right there

>> No.63384020

t.transgender rustfag shill

>> No.63384069

you can hate C even if you're not a rustitor

>> No.63384073

int a = 12;
printf("%llu\n", &a);
I wonder what happens

>> No.63384083

don't you have a neovagina to stretch?

>> No.63384237

undefined behavior happens, don't you know C at all?

>> No.63385319

this is legit the worst explanation of pointers I have ever hard

>> No.63385435

Pointers are basically the memory address of some data. One of the basic reasons why they're used is because functions are passed copies of the arguments, not the variables themselves, and thereby trying to edit them just changes the copy which is used in the function, not the actual variable. In order to change the actual variable you provide a pointer which points to the memory location. This is why scanf needs pointers, but not printf. Another usage is that sometimes the memory address is smaller than the data itself. In this case it can be used for performance reasons.

>> No.63385456

I'm not even sure how I'm supposed to follow this graph

>> No.63385494

So for example if you had a variable a and a function b, just passing a to b as an argument won't help.

int a = 0;
int b(a) {
a = 1;
printf("%d", a); // This prints 0.

Instead you provide a pointer to memory location where the data is kept.

int a = 0;
int b(a) {
&a = 1;
printf("%d", a); // This prints 1.

>> No.63385513

Another use case is if the data in a is larger than the memory address of a. In this case it'd often be faster to use a pointer pointing to a than a itself, because you're shuttling around less data.

>> No.63385540

well meme'd friend, only math you need to know is discrete math for most of programming

>> No.63385563

Higher-level languages do stuff like this for you automatically, but since C is a low-level systems programming language built for speed and being close to the hardware you're expected to do this stuff yourself. Another thing you're expected to do yourself is garbage collection, essentially deleting things from memory when no longer needed. Although high-er level languages do this automatically, C expects you to do it yourself. I'd suggest using Rust instead where the speediness and close-to-the-metal nature of C is not required.

>> No.63386081

>int a = 0;
>int b(a) {
>&a = 1;
>printf("%d", a); // This prints 1.
should be
int a = 0;
int b(int* a) {
*a = 1;
printf("%d", a); // This prints 1.

disregarding the fact that nested functions aren't allowed.

>> No.63386559

I want a meme course where do I find

>> No.63388364

Because without memes /gee/ wouldn't exist

>> No.63389004


>> No.63389148

You don't understand pointers not because you're a fool, it's because you're approaching a black-box.

A lot of C guides try to create an abstraction, but really you should learn assembly and use a debugger to
learn about the memory segments and virtual memory of a program, learn what's actually fucking there,
then pointers will be a breeze, infact C will be too, since C gives you full access to the program's virtual

Understanding stack frames is key to knowing about recursion also, this is why knowing low-level is the best
to actually get "programming". If you're using Linux, use gdb, if not, get on Linux and learn C. C should be learned
under a unix or unix-like environment.

But seriously, learn assembly first, it's not that hard, don't just learn the instruction set only either this is wrong,
learn how it works, if you don't, you'll never be competent at C.

Name (leave empty)
Comment (leave empty)
Password [?]Password used for file deletion.