[a / b / c / d / e / f / g / gif / h / hr / k / m / o / p / r / s / t / u / v / vg / vm / vmg / vr / vrpg / vst / w / wg] [i / ic] [r9k / s4s / vip] [cm / hm / lgbt / y] [3 / aco / adv / an / bant / biz / cgl / ck / co / diy / fa / fit / gd / hc / his / int / jp / lit / mlp / mu / n / news / out / po / pol / pw / qst / sci / soc / sp / tg / toy / trv / tv / vp / vt / wsg / wsr / x / xs] [Settings] [Search] [Mobile] [Home]
Board
Settings Mobile Home
/g/ - Technology

Name
Options
Comment
Verification
4chan Pass users can bypass this verification. [Learn More] [Login]
File
  • Please read the Rules and FAQ before posting.
  • You may highlight syntax and preserve whitespace by using [code] tags.

08/21/20New boards added: /vrpg/, /vmg/, /vst/ and /vm/
05/04/17New trial board added: /bant/ - International/Random
10/04/16New board for 4chan Pass users: /vip/ - Very Important Posts
[Hide] [Show All]


Janitor applications are now being accepted. Click here to apply.


[Advertise on 4chan]


File: carbon.png (145 KB, 1754x860)
145 KB
145 KB PNG
>paper test in class
>ez i'll cruise it
>grab the paper, see c program for first exercise
>yeah i'll def cook it
>>on x86_64 what would the output of this program be
>who cares about 86, you old boomer, what's the fucking difference, it's just a c program, your days are over
>this question is so fucking easy, you ain't fooling me with pointer arithmetic, i'm a pointer fucking master
>a week later
>0/5 for this question
>my friends who couldn't even READ the program and got confused by the pointer arithmetic eneded up with the same grade as me lol
how was i supposed to know what little indians and big indians are ffs
and i find it so scary actually that the memory layout isn't as i thought it was lol
it was not the exact same code but something like that btw. and ofc on paper there was no shiny color
i thought i knew everything but i got humbled HARD though
>>
no CS course has shit like this in it, it's all math
>>
>>106531572
Which country is this uni?
>>
>>106531572
This is ragebait, not playing.
>>
>>106531591
yeah come to my country (France) we do more math than CS here, even though it's called "INFORMATIQUE"
they teach us some crazy calculus and linear algebra but they don't teach us the basics, what we all came for
no web dev
no android/ios dev
no game dev
just c, sql and java with stupid and unusable design patterns
>oh but hey look that's how you solve a system of linear equation
IT'S SHIT HERE DUDE
>>
>>106531591
I took a class in my CS degree called systems programming where we implemented malloc from scratch and also built a simple shell. I would absolutely get questions like this on the final
>>
>>106531572
This is how they prepare you for the industry? Bullshit trick questions? Lmoa.
>>
>>106531785
>>106531646
That's how it is in the USA as well.
Programming should be taught as a trade that requires a degree. You have to actually meet programmers who have learned from other previous programmers to become supreme... it's not like it was in the 90s when you could be a 1337 hacker by knowing some bashcode or whatever the fuck.
You're either a total worthless dweeb, some sort of system-level architecture person who can describe "flows" to business people, or you can do complicated integrations. There's really no "in-between".
>>
Are you a first year student?
>>106531785
This isn't a trick question. You get this shit on the first year. Same class that introduces you to binary and hexadecimal
>>
>>106531824
>This isn't a trick question. You get this shit on the first year. Same class that introduces you to binary and hexadecimal
What a great introduction to programming.
"teach me how to make a basic video game... or read code and modify it?"
>NO, you will be learning about BIG ENDIAN, and data SUBTYPES...
"what is an IDE?"
>SILENCE... you will create a punycode unicode library now... in assembly
"what does that teach me?"
>SILENCE!
>>
>how was i supposed to know what little indians and big indians are ffs
By learning the lessons, did your professor not teach you that? If he's asking exam questions about stuff he didn't teach then you might be able to throw up a stink at the uni. If he did teach it your reaction should be "damn I need to study better" not "how was I supposed to know"

Also if your classmates are retards it can be really easy to succumb to hubris, if so take this as a lesson, just because your peers are shit doesn't mean you can sink to their level or shouldn't try your best anyway. At worst even if your uni is shitty and full of retards you can be a big fish in a small pond, that's still better than being a retard among other retards
>>
>CS
>Doesnt know about endian
If its in the test it was in the course
>>
>>106531572
if ( htonl(47) == 47 ) {
// Big endian
} else {
// Little endian.
}


i dont get it seems ez?
>>
>>106531572
if this is a real exam question, that's pretty niggerlicious.
>>
>>106531842
I'm not American.
We have a division of classes into lectures and labs. The assumption is that if you're going into CS, you already know at least the basics of IT knowledge from highschool. The idea is to teach you theory on lectures and practice in the labs.
Binary, basic architecture, data types, etc. is shit that everyone in the field should know. And it's not in the programming class, it's in "introduction to computer architecture" class.
>What is an IDE
programming I first class
>teach me how to make a videogame
How about they teach you the basics so that you can read documentation of whatever you wanna use for your videogame
>>
>>106531884
It's not so bad if you make it more legible.

#include <iostream>
#include <cstdint>

int main() {
uint64_t n[2] = {0xaabbccddeeff1122, 0x1122334455667788};

for (int i = 0; i < 2; ++i) {
uint64_t* n_addr = n + i;

printf(
"at address: %lx : \t number: %lx\n",
n_addr,
*n_addr
);

for (int k = 0; k < 8; ++k) {
uint8_t* single_byte = (uint8_t*)(n_addr) + k;

printf(
"at address: %lx : %x\n",
single_byte,
*single_byte
);
}

printf("\n");
}
}
>>
>>106531842
>>106531904
Moreover, from what I've seen, in American uni books about C, the topic of endians appears in the first or second unit.
We only had it mentioned, as we never had a C class.
>>
>>106531862
no one should need to know about endianness unless you're doing serdes type of shit.
casting a type to char is almost always wrong anyway and bitwise ops exist for a reason.

this is a retarded exam question.
>>
>>106531921
>no one should know about endianness
>no one in CS should ask themselves how shit is stored in the computer
Vibecodebrain
>>
>>106531944
>there's like bytes and shit inside the computer? wow thats so cool. hold on my CFO is calling me about the series a funding round.
>>
>>106531944
correct. you're working in a high level language. it's only relevant for specific serialization behaviors that are generally not relevant to a normgroid.
worrying about endianness is how you write shit code without realizing why you shouldn't do it.
>>
>>106531572
prof is a asshole you learn nothing from this.
>>
>>106531917
its obvious what it does its still a pretty bad exam question that only serves to trip you up. Thats not how you check someones knowledge on a topic.
>>
>>106531970
>doesn't understand whats going on under the hood
>explains how to avoid writing shit code
zoomers are cooked
>>
>>106531995
>goes to college for deep understanding
> gets mad when deep understanding is tested
>>
>>106532054
>doesn't understand whats going on under the hood
you're a fucking retard. literally braindead. I'm sick of you low IQ retards who claim to know things you know nothing about.
C is high level with a type system. You should not be inspecting bytes of a uint64_t by walking it as an unsigned char. It's literal 10/10 full retard brainrot.

https://commandcenter.blogspot.com/2012/04/byte-order-fallacy.html
>>
>>106531965
even in js you have to care about endianes. when you serialize a data structure in your db (any anywhere really), you have to take endianess into account. it also comes up a lot in networking, if you've ever used sockets for networking, you would know since this is pretty basic stuff

>>106531944
that's why the question is about x86_64 specifically, where unaligned memory accesses can be legal and large types can be casted to bytes. also the main point of the question was endianess and maybe to know how stack allocations work. OP probably skipped classes and was a faggot as usual
>>
File: 1649671868436.jpg (11 KB, 605x259)
11 KB
11 KB JPG
This is why it's better to do pointer (re)casting, rather than bitshifting and -OR'ing components together, because the compiler takes care of the endianess issue for you.
>>
>>106532142
>even in js you have to care about endianes
not really. DataView and Type Arrays take care of that with a single and simple boolean argument. You should never manipulate the actual value unless you need to write out an int bigger than 32bits and smaller than max safe int for f64
>>
>>106531572
You should have said "this is outside the scope of the C standard".
>>
>>106531842
>What a great introduction to programming.
I would assume OP's exam question is not in an introduction to programming class, it's in a computer architecture class, where the way information is stored in memory is actually relevant, and C is used as a vehicle to explain certain things rather than the topic of the course.
>>
>>106532206
But it is in scope of the x86_64 standard, which is also specified in the question.
>>
>>106532206
>You should have said "this is outside the scope of the C standard".
this, prof would have been btfo.
>>
File: a.webm (658 KB, 950x700)
658 KB
658 KB WEBM
>>106531689
I implemented my own shell a few month ago, it's really good at teaching you unix system calls and how shells work. I've had the hardest when trying to make a readline of my own with grapheme support.
In the future, I'll maybe implement more complete pattern matching and aliases
>>
>>106532221
>But it is in scope of the x86_64 standard
no it isn't. that isn't written in x86 asm.
>>
>>106532221
show me real system programming that only uses 'the c standard' and nothing more, no win32, no posix, no glibc specific etc..
>>
>>106532221
You might be right but it isn't clear if the exam is about the C language or about computer architecture, because that code is useless for either case and it encourages bad practices.
>>
>>106532293
I would assume from the type of question that this is a computer architecture class, not a C class. I agree that this question would be obnoxious in an exam for a class on C.

>because that code is useless for either case
What is wrong with this code as an exam question on computer architectures? If C is expected background knowledge and x86_64 assembly isn't, which is not unreasonable, this question seems like a fine test of whether you understand memory usage.

>it encourages bad practices.
I can't say I have ever used exam code is an inspiration for good practices. Half of the programs in exam questions are explicitly about "what is wrong with this code", any examples in exams everywhere should always be interpreted as archeological artifacts rather than good examples.
>>
>>106532228
this is so cool
>>
>>106531572
So the trick question is whether it prints
aa .. 22, 11 .. 88
or 22 .. aa, 88 .. 11?

Depending on the architecture and compiler it is not guaranteed to be the same.

But I remember that big endian is used in networking and networking is "different".
Which means it should be little endian for non-networking in x86. You can infer that little endian is the "normal one". And while at it we can say that normal (little) endian is how *bytes* are ordered in a multibyte number akin to how "bits" are ordered in binary number (actually any base system).

We had no questions like that at my school on tests and it's weird that they ask this.
We actually had only one subject in C in first year which was basic programming course.
I would probably fail this question at that time, because I sucked at C and only actually understood it years later.

For computer architecture course we had only paper test with no code at all, raw facts and closed questions tests. Lab for that though was in assembly in DOSBox using NASM which was hard again, because at this time I sucked at low level things.

Later subjects were mostly math and most programming subjects later were in Java. We only got back to C (actually C++) for OpenGL graphics course which I hated and think C would be more sensible, because the teacher's examples were using weird inheritance and coded in 80's style C++ and it was hard to follow wtf is going on.
>>
>>106531572
I'm a C programmer and have no idea what I'm looking at. Nor do I care. Something about printing the size of the address? And the addresses are stored in a differently sized type? Who gives a shit.
>>
Name one computer using big endian today
>>
>>106533064
Any computer with TCP/IP
>>
>>106532934
It prints the big number in hex and then iterates over its individual bytes in the order they're laid out in memory and prints out each one: >>106531917
>>
>>106531646
It's the same everywhere. CS is a branch of Maths, it's not supposed to teach you to be a vibe-coding jeet.
>>
>>106531785
Went to a top 20 school in the US. Yes, this is how they do it. The schools are "exclusive" and "rigorous" because instead of just learning a concept and taking a test that proves you know the concept, they throw a bunch of Nintendo Hard gotchas and trick questions in to make the tests arbitrarily difficult. You pass by not only learning the concept but being able to conquer asshole test design.
>>
>>106531965
Lmao based
>>
>>106533289
My man, I appreciate that it can be difficult to tell as a student, but this is not a nintendo hard question. This is a very normal question that anyone finishing a computer architecture course should be able to answer.
>>
>>106533413
I graduated over a decade ago. What I said is true and goes beyond the scope of whether you think this one question is tricky or not.
>>
>>106533597
Perhaps; I did not go to a US university. But you sure picked a bad example, if so.
>>
>>106531572
>thinks picrel is C
i think we have narrowed the problem, cotton
>>
>>106531646
lol
lmao even
post back of hand "frenchman"
>>
File: 1732959374200748.png (398 KB, 640x742)
398 KB
398 KB PNG
>>106531917
>>
>>106531572
I had similar questions for an interview for a programming job. You are fucked anon.
>>
>>106531572
How are you supposed to know what the "at address prints"? isn't that random since its at whatever address the operating system decides to put the stack at?
>>
>>106531646
learn your systems of linear equations unless you want to be replaced by a jeet with a llm.
>>
>>106531572
>how was i supposed to know what little indians and big indians are ffs
by reading the syllabus, probably
>>
>>106531572
how are you supposed to provide the output for stack addresses? just make up contiguous addresses? gay
>>
>>106532228
Wow, nicely done anon.
btw what's grapheme support?
Yeah I could just look it up, but I like learning from other people
>>
>>106531591
Depends on the university and course. An embedded or system programming course will drill you on endianess. At least they did when I was studying in Vienna 20 years ago.
>>
>>106533904
The exam was probably written by an old fart used to DOS programming who probably think that memory addresses are set in stone.



[Advertise on 4chan]

Delete Post: [File Only] Style:
[Disable Mobile View / Use Desktop Site]

[Enable Mobile View / Use Mobile Site]

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.