Quantcast
[ 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?

Help!

>> No.63380825

What are you having trouble with?

>> No.63380830

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

>> No.63380833

>>63380813
C is easy, stop being a brainlet.

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

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

>> No.63380866

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

>> No.63380878

>>63380825
Pointers
>>63380830
Thanks
>>63380833
:(
>>63380853
>Get a solid foundation in maths + SICP
I tried reading SICP, I had to quit out of boredom

>> No.63380896

>>63380813
>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

>>63380866
> False equivalency explains everything!

>> No.63380943

>>63380908
>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

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

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

>>63380878
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

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

>> No.63381095

>>63380878
>Pointers
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?

https://github.com/libretro/RetroArch/blob/master/tasks/task_patch.c#L526

>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

>>63381134
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

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

>> No.63381170

>>63381134
>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

>>63380813
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

>>63380853
>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]
63381211

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

>> No.63381234

>>63381152
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

>>63380878
Try the triple ref video from computerphile.

>> No.63381247

>>63381134
> 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

>>63380878
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]
63381343

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

>> No.63381382

>>63381211
>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]
63381441

>>63380853
>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

>>63380813
>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

>>63380813
>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]
63381546

>>63380853
americans don't learn this at school

>> No.63381558

>>63381269
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

>>63380813
>rtfm

>> No.63381575

>>63381343
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

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

>> No.63381626

>>63381198
Use
The
CLI

>> No.63381721

>>63381198
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] 

>>63380813
Because you're white

>> No.63381773

>>63380833
If so why every OS has security holes?

>> No.63381812

>>63380878
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

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

>> No.63381883

>>63381773
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

>>63380878
>SICP
Why do people fall for this meme?

>> No.63382036

>>63381575
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

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

>> No.63382318

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

>> No.63383900

>>63380833
/thread

>> No.63383933

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

>> No.63383978

>>63381721
>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

>>63381045
>pointers are numbers
wrong! stopped reading right there

>> No.63384020

>>63383933
t.transgender rustfag shill

>> No.63384069

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

>> No.63384073

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

>> No.63384083

>>63384069
don't you have a neovagina to stretch?

>> No.63384237

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

>> No.63385319

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

>> No.63385435

>>63380878
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

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

>> No.63385494

>>63385435
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;
}
b(a)
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;
}
b(a)
printf("%d", a); // This prints 1.

>> No.63385513

>>63385494
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

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

>> No.63385563

>>63385513
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

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

disregarding the fact that nested functions aren't allowed.

>> No.63386559

>>63382036
I want a meme course where do I find

>> No.63388364

>>63381945
Because without memes /gee/ wouldn't exist

>> No.63389004

>>63386559
bump.

>> No.63389148

>>63380878
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
memory.

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)
Name
E-mail
Subject
Comment
Password [?]Password used for file deletion.
reCAPTCHA
Action