数学の恋人
just merge the lines
klimi
Thats cool
klimi
Like from 5 10 To 5+10 right
数学の恋人
yes
数学の恋人
that -d flag adds +
klimi
Neat
Alex
awk '{sum += $2}END{print sum}'
klimi
I need to learn more of awk.. That looks superb
Anonymous
awk is awkward, but useful
Alex
why awkward? is good
数学の恋人
awk '{sum += $2}END{print sum}'
but bruh wouldn't that give just 0?
Alex
Mind explaining?
its pretty simple. awk reads file line by line(you should pass file name as second argument). second column is $2
数学の恋人
no initial value
Anonymous
every awk variable is initialized to 0
klimi
What is that END section?
Anonymous
gets executed at the end of the file, after all lines have been read
Alex
What is that END section?
code to execute when script is about to finish
klimi
Damn that genious
klimi
I dont need python anymore
数学の恋人
wierd
klimi
wierd
Um no cut
Anonymous
How does it relate to c++?
Alex
wierd
no. just use standalone awk, without cut
数学の恋人
Um no cut
ah right
Alex
awk '{}' <filename>
数学の恋人
yeah
klimi
awk '{}' <filename>
I dont even need cat? Nice
Anonymous
Again
klimi
Again
Reverse enginnering, hacking and related topics are allowed, but asking to hack facebook, instagram, etc. is NOT allowed. Also if you ask "how to become a hacker" and obviously have zero knowledge on anything related to that you may get warned or banned.
Anonymous
How does it relate to C++?
Alex
I dont even need cat? Nice
don`t need. actually almost every unix tool can read file
Anonymous
An awk interpreter can be written in C and C++, there's the (granted, distant), relation
数学の恋人
There's no word about Bash
that's no bash also
Alex
How does it relate to C++?
more efficient way than c++
数学の恋人
it's awk
Vinícius
Can someone help me? I'm trying to normalize a vector2<float>, in a game I'm creating in SFML, When my player moves to the right the velocity is 30.0f, when it moves to the top the velocity is 30.0f, but when this two things happens together, the player moves faster, how can make it equal the the others? I try this: d * sqrt(2) = 30 (player's velocity) But the player moves too slow.
Vinícius
(sorry for the large msg)
Artöm
You need to calculate horizontal and vertical components of speed and velocity separately
Vinícius
How so?
piggyho
x and y vector. hypotenuse from x ° y angle
Martin
We
Martin
well, that's normalization does.
Đỗ
u can boost the player's speed in every way u design
Đỗ
try tinkle it in some test/ dump case first
Robert
Hey guys, how can I paste the text copied from Windows into the text file in the remote Linux?
Robert
Just by command line
Artöm
I meant projection of speed on 2d plain
Vinícius
Thanks, I try to implement that.
Vinícius
I'll try*
Artöm
Sorry I should have said velocity
@unchanted
Right now i was studing critical section problem in OS, where we have to synchronize the critical section code to resolved the issue of share "resources". What are these resources and how can i access these resources in c/c++ program?
@unchanted
For example?
@unchanted
And how can i access them?
olli
For example?
a global variable/shared memory
@unchanted
Is a global variable is stored in stack
olli
doesn't matter where they are stored
@unchanted
Stack memory is cleaned after the code is executed
@unchanted
So it would never be counted in mutual exclusion as it would never be causing an issue to another code..
olli
yes, but it doesn't matter in that case (btw, in the C++ standard there is no such concept as stack and heap, it's just how it's implemented)
olli
So it would never be counted in mutual exclusion as it would never be causing an issue to another code..
x is basically valid the whole lifetime of the program, so you can do whatever with it, although being on the stack int main() { int x = 0; // do something with &x }
@unchanted
yes, but it doesn't matter in that case (btw, in the C++ standard there is no such concept as stack and heap, it's just how it's implemented)
In c we use malloc to dynamically store in heap memory In cpp we use new to dynamically store in heap memory Else we can store in stack directly
@unchanted
This seems confusing 😅
@unchanted
U mean we cannot use stack and heap in standard c++ compiler?
olli
again, my point being, when talking about Critical Sections and race conditions it does not matter whether you're accessing heap or stack memory
Anonymous
U mean we cannot use stack and heap in standard c++ compiler?
What is void* malloc(size) to you anyway?
Anonymous
Compiler only knows the return type and the argument type for malloc
Anonymous
malloc can be anything
Anonymous
It could even be a macro
@unchanted
But it must be mutually exclusive
I mean it we cannot share the resource
Anonymous
And depending on runtime
Anonymous
Malloc can change significantly
@unchanted
What is void* malloc(size) to you anyway?
No, my question was on recources