[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

/dpt/ - Daily Programming Thread

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 323
Thread images: 48

File: trop.png (1MB, 1280x720px) Image search: [Google]
trop.png
1MB, 1280x720px
What are you working on, /g/?


Previous Thread: >>62020058
>>
File: images.jpg (7KB, 275x183px) Image search: [Google]
images.jpg
7KB, 275x183px
>>62025163
>want to work on something
>can't stop browsing the internet
>>
>>62025163
thank you hime
>>
File: bjarne.jpg (23KB, 500x335px) Image search: [Google]
bjarne.jpg
23KB, 500x335px
let's be honest, C++ is for autists

normies can't keep in their heads the thousands of essential edgecases and nuances of core c++
>>
File: bjarne.png (91KB, 136x275px) Image search: [Google]
bjarne.png
91KB, 136x275px
>>62025203
This stupid fucking danish gnome and those fucks behind Java set back programming by decades
>>
File: 15822597.jpg (5KB, 370x334px) Image search: [Google]
15822597.jpg
5KB, 370x334px
>>62025163
why would anyone do that?
>>
>>62025184
So basically, if I have no pointers, then the complexity is going to not be O(1)?
>>
File: 1499763516243.jpg (1MB, 2048x1536px) Image search: [Google]
1499763516243.jpg
1MB, 2048x1536px
>>62025228

thankfully this is not the 90s and we can stop pretending that OOP makes sense
>>
In C, what is the difference between | and || in terms of boolean? Why can't I just do this for boolean statements?
if (A | B){...}
// instead of
if (A || B) {...}
>>
>>62025373
|| returns true if all it's operands are not zero
| returns the bits that are flipped on in both operands
if this new bitfield is not zero, the if conditional returns true
>>
>>62025373
| is a bitwise inclusive OR operator.
|| is a logic operator with short circuit evaluation.
>>
>>62025415
That's the point tho? 10 == 10 is 1, 12 < 10 is 0, so
if (10 == 10 | 12 < 10) {...}
=> if (1 | 0) {...}
=>if (1) {...}


>>62025434
>short circuit evaluation
I guess this is the only reason.
>>
>>62025373
The double || will always return either 1 or 0. The single | can return any bit pattern.
>>
>>62025447
they do completely different things
learn how expressions work in C
>>
>>62025203

Yes, and? Would you trust a normie to do systems programming?
>>
Explain why programming in insecure languages is still permitted.
>>
>>62025507
Because secure languages are hella slow.
>>
>>62025496
an excellent point
>>
>>62025507
creating jobs
>>
>>62025517
We don't need more internet-connected lightbulbs, cryptographically insecure 'smart' heating or leaky web apps, thank you very much.
>>
>>62025496
you can do it all and more efficiently in C where you just have to be smart
>>
>>62025515
Moore's law held true for many years. Today's computers are fast enough.
>>
>>62025507
name a secure language

name a language that can't be used securely
>>
File: 16831080.jpg (83KB, 541x767px) Image search: [Google]
16831080.jpg
83KB, 541x767px
>>62025553
it's never fast enough
>>
>>62025590
Java

Java
>>
File: old_hag_langs.png (173KB, 600x355px) Image search: [Google]
old_hag_langs.png
173KB, 600x355px
>office PC has Fedora installed
Niiiccceeeeee
>>
>>62025590
>name a secure language
One that doesn't let you directly access memory

>>62025590
>name a language that can't be used securely
There's several decades of evidence showing that programmers cannot write secure code in any non-trivial project
>>
still working on that language. This is an example from the Ada95 book translated into my language.
Sum is
first, second: i32
<=
put "Enter two intergers: "
get first
get second
put "The sum is #{first + second}"
newline
=>Sum

And since it's essentially supposed to be ada with symbols, you can either specify with words:
proc Sum is
first, second: i32
begin
put "Enter two intergers: "
get first
get second
put "The sum is #{first + second}"
newline
=>Sum

or go full symbolshit
Sum is
first, second := 0
<=
<|"Enter two intergers: "|>
>>first<<
>>second<<
<<"The sum is #{first + second}">>
=>Sum
>>
>>62025605
>not gentoo
>>
>>62025653
for what reason?
>>
>>62025605
>he works for the CIA
must be cool
>>
>>62025642
>One that doesn't let you directly access memory
you can have bounds checking etc

I mean nothing can be made completely idiot proof, see halting problem
>>
Can I use strncmp to compare two data structures?
struct State {
int i;
int a;
}

struct State m = {1, 2};
struct State n = {1, 3};
strncmp(&m, &n, sizeof(struct State));
>>
>>62025724
>you can have bounds checking etc
If you can circumvent a safety feature then you can bet programmers will do it

"I know what I'm doing, it'll make it run faster, look at that 2% speedup, don't worry this will never overflow"
>>
>>62025549

Many of C++'s abstractions are zero-cost. The equivalent code written in C would not offer any benefit in efficiency. And strictly speaking, you have to be smart to use either language, but even a smart person makes a mistake every so often, and these are often intolerable in low level code. RAII prevents a lot of mistakes, so why not use it?

>>62025507

Everything not explicitly forbidden is permitted. Programming should not be regulated in any way.

>>62025642

>One that doesn't let you directly access memory
Oh, so you want people to not be able to write device drivers. That's lovely.
>>
Most programmers have no need of a Turing-complete language.

Most programming problems can, in practice, be defined in terms of total functions and/or functions that are provably productive on an infinite, lazy data structure in finite time.
>>
>only worry about C and procedural programming for months
>read some OOP introductory concepts but can't really see the whole picture
>more months pass
>read Plato
>OOP makes sense now
>>
>>62025813
>Oh, so you want people to not be able to write device drivers. That's lovely.
I don't want programmers anywhere near device driver source code. Engineers only, please. Programmers cannot be trusted.
>>
>>62025804
memory manipulation is not everything, you can't stop people from making high level algorithmic mistakes either
>>
>>62025857
But at least if everything is written in a secure language, there's no risk of a bad algorithm in one program being able to break other programs.
>>
>>62025648
Why is it so ugly
Do those symbols have useful meaning?
Give me 4 reasons why this is better than just making most operations function calls, and using lambda calculus based syntax/semantics
>>
>>62025813
>Many of C++'s abstractions are zero-cost. The equivalent code written in C would not offer any benefit in efficiency.
That's complete bullshit. Also, enter the benchmark game and prove me wrong if you're so smart.
>>
>>62025843
>Plato
http://www.richardfarrar.com/plato-and-object-oriented-programming/
this?
>>
>>62025813
>Many of C++'s abstractions are zero-cost
inheritance and vtables are not zero-cost
RAII is not zero-cost
smart pointers are not zero-cost
exceptions are not zero-cost
copying everything at every turn is not zero-cost
>>
>>62025891
>Why is it so ugly
It's for low-level system writing. I don't get what's so ugly about it, it retains ada's readability while also making it easier on the programmer
>Do those symbols have useful meaning?
<| |>
is print
<< >>
is puts (or put, in the language's case)
>Give me 4 reasons why this is better than just making most operations function calls, and using lambda calculus based syntax/semantics

They are function calls, i just broke it down to it's base elements
>>
File: giphy.gif (1MB, 1000x853px) Image search: [Google]
giphy.gif
1MB, 1000x853px
What was the other big ebook library everyone used besides shodan? Trying to find a programming book not in the library.
>>
>>62025913
Yes that plato, but I didn't read that, just studied Plato in general and when I was going through his theory of forms it sounded familiar and when I revisited OOP concepts it just clicked.

In retrospect I don't know why the concept of objects and classes confused me, I think the usual examples they give of a a car class and an animal class confused me because I just never understood why anyone would want to program that.
>>
>>62025934
unique_ptr is allegedly zero cost
>>
>>62026010
Sure, but shared pointers aren't.
>>
File: 1486343938959.jpg (17KB, 267x262px) Image search: [Google]
1486343938959.jpg
17KB, 267x262px
>tfw codeblocks is so shitty I have to turn emacs into my debugger
>>
>>62026010
When you move out a unique_ptr, it just nulls the old unique_ptr.
This means that if you forget that you moved it, you'll likely get null errors. Also, the destructor will do a null check, so you have to bet on compiler optimizations removing that check (also on this point: a lot of C++'s "zero cost" comes from extremely aggressive compiler optimization; the base C++ language is laiden with empty procedure calls). An affine type system would be able to both prevent the bug and statically decide if the destructor needs to be called.
>>
>>62026024
I don't get why people use shared pointers instead of an actual garbage collector. Reference counting has the disadvantage of high overhead with the disadvantage of not being accurate. Worst of both worlds.
>>
>>62026036
embrace it
>>
>>62025989
ok, thanks
>>
>>62026057
>it just nulls the old unique_ptr.
>This means that if you forget that you moved it, you'll likely get null errors
Hmmmm. It's as if being uniquely owned is the point of unique_ptr.
>>
File: 1496356164331.jpg (33KB, 480x480px) Image search: [Google]
1496356164331.jpg
33KB, 480x480px
>>62026036

>not using gdb in terminal to debug everything

It's like you're actively trying not to make it.
>>
>>62026076
What I'm saying is that with affine types, it will literally be a compile error to try to access the memory after it has been moved.
>>
>>62026060
Also reference counting has horrible effects on multithreading performance if done naively (i.e. a mutex for every refcount increment/decrement). But you have to do something if you're going to use them across multiple threads.

One thing that I like about Rust is its distinction between Rc and Arc. You can't use the former across multiple threads, so it doesn't pay the performance penalty.
>>
>>62025854

1. The definition of a programmer is any person who creates programs.
2. A program is defined as a collection of instructions to be executed by a computer.
3. A device driver is a collection of instructions executed by a computer to control a piece of hardware.
4. Because of 2 and 3, a device driver is a program.
5. Because of 1 and 4, a person who creates a device driver is a programmer.
6. Therefore, if we consider that you do not want programmers anywhere near device driver source code, then no person can create and edit device driver source code. We know from 5 that even an engineer who develops device drivers is also a programmer.
6.5. Therefore we can conclude that you do not want device drivers to be created by anyone.

>>62025934

>inheritance and vtables are not zero-cost
>exceptions are not zero-cost
These are fair points, and I would argue that these are not tools that one should jump to every time, but instead, evaluate whether the cost is worth it.

>RAII is not zero-cost
Trivial destructors are aggressively inlined by modern compilers, often making them zero cost.

>smart pointers are not zero-cost
unique_ptr is zero-cost in a modern compiler.
shared_ptr is not zero-cost. Again, a choice for the programmer to evaluate whether it is a good idea.

>copying everything at every turn is not zero-cost
Then stop copying everything all the time.
>>
>>62026110
>learning R(J)ust
>>
>>62026178
Nothing wrong with learning that. Using it, though...
>>
>>62026167
>Then stop copying everything all the time.
Do you realize that this falls into the terrible argument of "just be a better programmer!" that you're probably using to justify C++ over C?

Companies like Google that are supposed to have very talented engineers have had huge problems with excessive copying in C++
>>
>>62026057

>a lot of C++'s "zero cost" comes from extremely aggressive compiler optimization; the base C++ language is laiden with empty procedure calls
Yes, and? Is there any particular reason why you are not using aggressive compiler optimization on everything?
>>
>>62026209
fuck my logic doesn't make sense here but the point is that "stop copying" doesn't work in C++ because const references are easy and rvalues are fucking confusing, and it's super easy to implicitly do a huge deep copy in C++
>>
>>62026238
>tfw delete all my copy constructors by default
>>
>>62026178
I wanted to know whether it is worthy of its hype.
>>
>>62026247
>using a language that you have to manually patch all the holes and deficiencies
have fun with that
>>
>>62026209

It does not take a lot of effort to pass a big fucking struct by const reference. Any C++ programmer with experience will do this instinctively, and it is harder to forget than accidentally leaking memory or doing a use after free in C. The only time people don't do this is when they don't fucking understand the language. The reason Google has problems with excessive copying in C is because their programmers are in their own words, too stupid for C, which is why they made Go.
>>
>>62026277
But now that C++ has move semantics and rvalue references, sometimes passing values instead of references results in more efficient code.
>>
>>62026277
You are not an woman.
>>
>>62026295

If it results in more efficient code, why are you complaining?
>>
>>62026303

Thank you for pointing out the obvious, but you should check your grammar. It should be "a woman," not "an woman."
>>
>>62026265
>deficiencies
What did he mean by this?
>>
File: bone-think.jpg (144KB, 572x303px) Image search: [Google]
bone-think.jpg
144KB, 572x303px
>>62025785
I didn't take this question seriously at first, but then I did it and it actually fucking worked.

#include <stdio.h>
#include <stdlib.h>

#include <string.h>
typedef char ElemType; /* to make changing
the type of the LL easier*/
struct Node
{
ElemType Item;
struct Node* Next;
};

struct Header
{
struct Node* Head;
struct Node* Rear; /* To make insertion into back O(1) */
int size;
};

typedef struct Header* List;
/* Done defining auxiliary structures */

struct Node*
InitializeNode(ElemType X, struct Node* nextNode)
{
/* Initialize Node* and create enough space for the ptr */
struct Node* toRet;
toRet = (struct Node*) malloc(sizeof(struct Node));


toRet->Item = X, toRet->Next = nextNode;

return toRet;
}
/* Inserts an element at the start of the list
(If we were to insert it at the end, we would have
cons('T', cons('o', list)) == 'oT')

List
cons(ElemType elem, List ll )
{
struct Node* toInsert;
toInsert = InitializeNode(elem, NULL);
if(ll->Rear == NULL) /* Initialize rear */
{
ll->Rear = toInsert;
return ll;
}
toInsert->Next = ll->Head;
ll->Head = toInsert;
return ll;
}

int main()
{
List list1, list2;
list1 = (List) malloc( sizeof(struct Header) );
list1->Head = list1->Head = NULL;

list2 = (List) malloc(sizeof(struct Header));
list2->Head = list2->Head = NULL;

list1 = cons('T', cons('E', cons('S', cons('T', list1))));
list2 = cons('T', cons('E', cons('S', cons('T', list2))));

printList(list1);
printList(list2);

printf("Comparing using strcmp... %d\n", strcmp(list1, list2));
printf("Comparing using strcmp... %d\n", strcmp(list1, list1));

}

>>
>>62026310
The point is that "pass things by const reference" isn't optimal advice. Sure, in many situations it is best, but there are a few edge cases where it is not. On top of the many other edge cases C++ has. The language is practically nothing but edge cases at this point, and remembering all of them is something very few people are likely capable of doing.
>>
>>62026342
Not first language. Was actually going to spell it write but changed my mind in the last second.

But none of this matters. You are not a real woman. You degenerate fuck.
>>
>>62026057
>When you move out a unique_ptr, it just nulls the old unique_ptr.
>This means that if you forget that you moved it, you'll likely get null errors
that's why move semantics are explicit in that context. forgetting you invalidated an object a few lines after you explicitly asked for that would be a pretty stupid mistake. it'd be like assigning a literal value to a variable and then being surprised that it's not some other value when you refer to it soon after. the common case is moving ownership *out* of a scope anyway, in which case it's not an issue
>>
>>62026374
Fuck. forgot the output:
Test_strncmp.c:74:53: warning: incompatible pointer types passing 'List'
(aka 'struct Header *') to parameter of type 'const char *'
[-Wincompatible-pointer-types]
printf("Comparing using strcmp... %d\n", strcmp(list1, list2));
^~~~~
/*
...
Compiler Warnings
*/
4 warnings generated.

T ->E ->S ->T ->
T ->E ->S ->T ->
Comparing using strcmp... -64
Comparing using strcmp... 0
>>
>>62026375
>very few people are likely capable of doing
And they don't have to. All these edge cases just give people who are aware of them the ability to consider them in particular. Otherwise it'd happen as with any language that has a unified way of handling everything: better working in some cases than others.
>>
>>62026374
Because strncmp compares each bytes of the structure. I came to the conclusion that it shouldn't be used because I don't think the C standard guarantees that each element in a structure are aligned together.
>>
>>62026392
>>62026374
Of course it's gonna work, char are bytes aka the smallest addressable unit.
>>
>>62026385
Holly fuck just stopped to read it. I swear I'm not that uneducated, it was the the phone spell checking.
>>
>>62026420
OMFG now everyone thinks I'm a phone poster.
It was only this time guys, I swear.

FUCK I JUST TO FIT IN
>>
>>62026247
>rule of 5
>have to write 4 almost identical initialization functions to instantiate an object
fuck this Im goin back to structs
>>
>>62026433
Stop embarrassing yourself
>>
>>62026433
>FUCK I JUST TO FIT IN

PHONEPOSTER BTFO.
>>
>>62026457
>structs
*Rust
fixed that for you
>>
>>62026342
>heh nice argument kid but I see you made a typo
>>
>>62026479

>>62026178
>>
File: PantiesOnHeadPepe.jpg (34KB, 396x385px) Image search: [Google]
PantiesOnHeadPepe.jpg
34KB, 396x385px
>>62026476
HOLY FUCKING SHIT NOT FUCKING AGAIN
>>
File: questin.png (183KB, 386x406px) Image search: [Google]
questin.png
183KB, 386x406px
Is it actually portable to use strncmp on a structure or any arbitrary array????
>>
I'm writing a http media player for android but should I target android 5.0 for flac support?
It'll cut out 30% of users
>>
>>62026529
If the standard library is properly implemented I don't see why not. But again <threads.h>
>>
>>62026529
Just compare them using == and then let the compiler deal with optimization.
With arrays you might have issues with padding bytes not being equal when all the fields are equal
>>
>>62026551
The thing is you might want to know how much they differ.
>>
>>62026178
>>62026257
i want to like rust but holy shit it's so ugly
it's like C++ devs are so used to eating shit that the rust team has to wipe their asses with it to make it palatable
>>
>>62026561
How will strncmp tell you this correctly? I would suggest just writing the code that conveys your intent the best and then benchmark later
>>
>>62026457
just use pod/aggregate/standard layout types when you can. you can even still use inheritance costlessly in some cases to avoid redundancy/simplify composition, and aggregate initialization still works in many of those cases. a lot of people would benefit from taking a more data-oriented approach to C++
>>
>>62026579
Returns -1 if the first argument was lower and +1 otherwise. The point is it's not semantically equivalent to ==.
>>
>>62026598
But what does "lower" mean for structs? Especially considering endianess, it probably tells you nothing useful (if you consider portability)
>>
beginner at python writing a python script to guess your number, though i feel like im not doing something right

number = input("put your number you want me to guess here")
print("your number is %s" % number)
>>
>>62026385

>You are not a real woman.
I have never claimed to be a woman. You seem to have fallen for a meme going around here.
>>
>>62026626
Don't worry Ruby, I know you're a man, the manliest man in this thread, probably a lumberjack in fact.
>>
>>62026641
A lumberjack (girl).
>>
>>62026641

Well, I'm not a lumberjack, but if you saw only my face, you might come to such a conclusion.
>>
>>62026626
>You seem to have fallen for a meme going around here
the meme exists because you use a woman's name which also happens to be the name of a meme language nobody gives a shit about to the point that people in a programming thread apparently often don't even recognize it
>>
>>62026667
er wait not really a meme language that would be kind of a contradiction
>>
>>62026662
A conclusion that you're a lumberjack and you're okay.
>>
holy shit is it impossible to get gcc or clang working in windows?
>>
>>62026701
just use ming
>>
>>62026701
Both work fine through cygwin. clang works natively.
>>
>>62026701
>not using WSL
>>
Fuck that shit, I'm going to install Linux in that laptop anyway, there goes my remaining installation of windows
>>
>>62025549
I wrote a program in C and it took me a month to write and it came out to a binary 13kb in size.
I wrote the same program in C++ in a day and it came out to 20kb in size.
I'd say it comes down to where you want overhead: size or time?
>>
>>62026849
>I wrote the same program in C++ in a day and it came out to 20kb in size.
that's because you already programmed it once
>>
>>62026849
This says absolutely nothing about the program.
>>
>>62026701

GCC is easy to get working on Windows actually, and there's multiple distributions of it. I recommend downloading it through MSYS2.
>>
File: 19366211.jpg (52KB, 960x890px) Image search: [Google]
19366211.jpg
52KB, 960x890px
Are debuggers a meme
>>
>>62027078
i just print debug, desu.
>>
>>62027096
Or just use pragma
>>
>>62025190
That's my current state, I have to finish work by the end of this week, fuck freelance work and procrastination.
>>
java is the only thing i know from college

will future employers laugh at me?
>>
c++ and c are both great languages

no need to fight

why you ask?

c autists over here
c++ autists over there

keeping them separated
excellent design implementation
>>
>>62027132
www.baddragon.com
>>
>>62027078
Compiler errors, static analysis and a well-designed language help far more than any debugger could.
>>
>>62027132
Not unless you are good at it
>>
>>62027144
what is this supposed to mean
>>
>>62027150
sure but it feels like everything of note is written in c++ or assembly
>>
Is there anyway I can emulate AVX512 on my shitty i3-6100 on arch.
trying to test my algorithm
>>
>>62027028 >>6206701
+1, use it all the time now. it's easy enough to patch for NT3 if i wanted to without missing out on new std feature
>>
>>62025163
>Why are you casting the return value of malloc()

This one always confused me... Isn't this regularly done? Here's a snippet from K&R casting the return value of malloc:
char* strdup(char *s) /* Make a duplicate of s*/
{
char* p;

p = (char* ) malloc(strlen(s) + 1); /* +1 for '\0' */
if(p != NULL)
strcpy(p, s);
return p;
}
>>
>>62027250
Additional info from K&R:
>In C, the proper method s to declare that malloc returns a pointer to void, then explicitly coerce the pointer into the desired type with a ast.
>malloc and related routines are declared in <stdlib.h>
>>
>>62027250
>>62027262
Or you know, maybe it was inappropriate in the situation to do it.
>>
>>62027078
I use gdb for for debugging segfaults. Pretty useful I'd say.
>>
>>62027274
I haven't seen this anime, so I don't know the context.
Just thought it was idiomatic to (almost) always cast malloc.
>>
File: dumb animeposter.gif (2MB, 416x414px) Image search: [Google]
dumb animeposter.gif
2MB, 416x414px
Is structure assignment and comparison in C a valid thing to do or do I have to memcpy and memcmp structs?
>>
>>62025163
What anime is this?

>>62027300
Not too sure myself, but I think this SO thread's pretty good about explaining it:
https://stackoverflow.com/questions/2302351/assign-one-struct-to-another-in-c
>>
>>62027300
>structure assignment
Yes, that's perfectly fine and valid.
>structure comparison
The C comparison operators do not work on structs.
memcpy is dicey too, because structs may have internal padding which can mess with the raw equality check.
Usually, you want to compare members directly.
>>
>>62027325
I hope you dont think thats real.
Just look at the thinkpad.
And any self-respecting anime wouldnt use anything but a Yinkpadâ„¢
>>
>>62027208
just got the answer, for those of you out there wondering:
https://software.intel.com/en-us/articles/intel-software-development-emulator
>>
>>62027338
as long as the struct was zeroed i think memcmp will work
>>
File: web_dev_lumberjack.jpg (57KB, 842x444px) Image search: [Google]
web_dev_lumberjack.jpg
57KB, 842x444px
>>62026662
You would fit into the web dev community then. Post your face when?
>>
>>62027491

1. I don't do webdev. I do, however, have a Unix beard.
2. I'm not posting my face.
>>
>>62027325
>However, there are problems:
[how pointers work]
>C++ made a cludge around it so you can write boilerplate instead of gitting gud
>>
>>62027491
what went wrong
>>
File: sadness_comes_over_me.jpg (33KB, 401x485px) Image search: [Google]
sadness_comes_over_me.jpg
33KB, 401x485px
>>62027560
I just shaved my beard because I don't want to look autistic.
>tfw women will still ignore
>>
>>62027964
>anime image
i get a feeling it's not hard for people to tell you're autistic regardless of your facial hair situation
>>
File: all_hope_gone.jpg (162KB, 1280x720px) Image search: [Google]
all_hope_gone.jpg
162KB, 1280x720px
>>62028068
I'm not really fat or anything. I'm like 6"3', blue eyes, light brown hair, average weight and I don't dress like an autist. I gave up though, women only want Chad and I can only wait until women hit the wall and they can no longer get a Chad pounding on the regular.
>>
>>62028095
>I'm not really fat or anything. I'm like 6"3', blue eyes, light brown hair, average weight and I don't dress like an autist
it doesn't really matter that much how you look or dress, it's about behavior. you can often tell a person is autistic before they even say a word, or otherwise generally not long after. that is, unless you have autism. because not being able to pick up on those kinds of subtle cues is pretty much exactly what autism is

>I gave up though, women only want Chad
good lord, are we really at the point where everyone who doesn't watch moeshit is a chad now?
>>
File: logo_JavaScript[1].png (10KB, 1052x1052px) Image search: [Google]
logo_JavaScript[1].png
10KB, 1052x1052px
>>62027751
>>
>>62028095
be more confident. just looking good/normal won't help if you can't even say hi or hold a conversation.
>>
>>62028356
How is this supposed to help when women only want Chad?
>>
>>62028362
chad is confident. if you're more confident than normal, you can seem like a chad.
>>
>>62028380
But I'm not Chad. I'm just an autist who spends all day programming and browsing a korean water puppet forum.
>>
>>62028394
Magic tricks
Looks at eye and smile.
Respect personal space.
Ask about how is her or if she feel OK.
Never judge or make feel alone or reject.
Make this to multiple women until you don't thinks begins bf or had sex.
>>
>>62028440
I don't even know how to meet wemen. There are no female programmers or anything.
>>
>>62028453
Get out, social groups like biking,dance or music, even otaku groups.

Tall and blue eyes, a lot women will love you but you never tried,never talk, never look in eyes
>>
>>62027378
>i think
well gee that sure is reassuring, let me just base all my future work that this assumption holds true and does not produce bugs for me.
>>
>>62028487
False. I go out to meet ups but it is always one of these:
>Only guys with no girls
>There are a lot of girls, but they split up and form their own meet ups, like "Girls Geek Club" or "Girls Night Out"
Anyway, women in general just ignore me and never talk to me anyway. As I said before, they only want Chad. That's why I just read and program because it's my "out".
>>
>>62028453
>There are no female programmers or anything.
There are in big commercial sites like banks and insurance companies. Airlines, oil companies, car makers; anywhere the money is you'll find female coders. All the big shops are equal-pay and equal opportunity.
>>
>>62028854
But I'm not good enough to work for those big companies.
>>
>>62027289
this isn't on the anime though.
>>
File: 1436489004580.png (1MB, 1014x1055px) Image search: [Google]
1436489004580.png
1MB, 1014x1055px
Working on something and I can't get it to work no matter what. Language is Java. inb4 pajeet

I want to read integers only from a scanner, so if the user inputs "nigger 12 faggot 34 dicks 56", it will save "12", "34," and "56" into an array. I want to do this by using the hasNext___ methods.

My problem is that my while loops do not ever break. I first have a while hasNextLine loop which is supposed to terminate when the user does enters nothing in a line. This does not work.

The second while loop is a hasNextInt loop which is supposed to read if there are any integer tokens left in the current line. This also does not exit when there are no more integers in the line left to read, instead it sometimes throws different exceptions, or just never stops.

Pls help.
>>
File: cannot link.png (12KB, 822x85px) Image search: [Google]
cannot link.png
12KB, 822x85px
i have 2 files

main.cpp
#include <SFML/Graphics.hpp>
#include "some_other.hpp"

int main()
{
sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
sf::CircleShape shape(100.f);
shape.setFillColor(sf::Color::Green);

while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
}

window.clear();
render(&window);
window.display();
}

return 0;
}

some_other.cpp
static void render(sf::RenderWindow *window)
{
// do stuff
};


pic related is my script

pls help newbo
>>
>>62029425

nvm i think i got it to work, so i have to compile each files into .o separately then link them afterwards

tfw 2 dumbo for child plus plus

any references program-bros
>>
Saw the following build pattern from what was supposed to be good Java
>have a dedicated class for what is an an email struct
>private fields for message, to, from and enclosed files
>getters and setters for every field
Proposed addition: a builder method that constructs the object which in calls the setters but as an inner class, along with assertion to test. To top it off: add a interface for the whole mess to guide it all.

Can you get more bloat? Jesus
>>
>>62029425
>>62029509

i lied it still doesnt work and im too retarded to fix this
>>
>>62025203
>edgecases and nuances of core c++
There's a name for all of that, it's called the C programming language.
Learn C, and C++ will make sense, and will be much much easier.
>>
>>62029376
Here you go:
        ArrayList<Integer> ints = new ArrayList<>();
Scanner scanner = new Scanner(System.in);
while(true) {
String s = scanner.nextLine();
if(s.isEmpty()) break;
if(s.matches("^[0-9]+$")) ints.add(Integer.parseInt(s));
}
>>
>>62025934
>inheritance and vtables are not zero-cost
Inheritance is zero-cost
The equivalent of vtables in C++ are structs of function pointers in C, which Linux uses extensively. So yes, they are zero cost because they don't add any other overhead that isn't already in C.
>RAII is not zero-cost
Yes it is
>smart pointers are not zero-cost
Unique pointers are certainly zero cost
>exceptions are not zero-cost
No but they offer other performance gains, and better error handling.
>copying everything
Something C++ doesn't do.

You have absolutely no idea what you're talking about, nor have you ever actually used C++.
>>
>>62029734
as a general rule of thumb you compile each file individually with the "-c" flag to produce object files (use -o to give them specific names), then link them together in the last step. So something like
gcc -c main.c -o main.o
gcc -c foo.c -o foo.o
gcc -o myprogram main.o foo.o -llib1 -llib2 -llib3
>>
>>62026238
>rvalues are fucking confusing
To you, maybe.
>>
>>62029924

yea it finally worked now, i hope it stays that way

had ton of fun learning scripting with bash tho :D
>>
>>62026238
Java was invented for idiots like you, wasn't it?
>>
File: 1378813226031.jpg (44KB, 590x500px) Image search: [Google]
1378813226031.jpg
44KB, 590x500px
I prefer simple "C with classes" style C++ with a little bit of template magic sprinkled in where relevant.
>>
>>62030003
That's the best C++. Anon.
>>
>>62025785
>>62026374
>>62026396
>>62026403
Of course it won't work you fucking retards.
What if you have a null byte in the middle of your struct? Fucking think your stupid shit through before posting absolute SHIT here.

Use memcmp, or just use a better fucking language and overload the equality operator.
>>
File: 1503356089620.png (28KB, 250x354px) Image search: [Google]
1503356089620.png
28KB, 250x354px
>got rejected by CS
w-what now?
>>
>>62025163
How can i shorten this?


print(str(pr[2])+" "+str(pr[7])+" "+str(pr[6])+" "+str(pr[6]))


>>
>>62030061
printf("%s %s %s %s",pr[2],pr[7],pr[6],pr[6])
>>
>>62030040
>overload the equality operator
Disgusting. Operator overloading is a cancer.
>>
>>62030054
How do you get rejected by a field? dumb frogposter.
>>
>>62030115
There is nothing at all wrong with operator overloading.
You're just a dumb Cfag who is scared of things that aren't in C.
>>
>>62030003
I agree. I also try to use RAII.
>>
>>62030086
Thanks anon! That cleared my code up nicely.
>>
Why are modules not in C++17?

What would modules even mean for the C++ linkage model?
>>
>>62030003
What is actually the difference between "C with classes" and proper C++?
>>
>>62030155
C++ cemented operating overloading as being a terrible, terrible, idea << std::endl;
>>
>>62025230
I read it in production code so much. It's annoys the shit out of me.
>>
>>62025230
For a more painless migration to C++.
>>
>>62030183
The people who claim to use C with classes do it just because some faggot on the internet said bad things about modern sepples features.
Then they continue to use modern sepples features but claim to just use "C with classes".
Holy shit sepplesfags are obnoxious.
>>
>>62030185
Do you have any actual arguments?
Operators are pretty pointless if you can't define them over user defined types.
Operators serve to make things more concise, so if you're not going to use them properly, then you may as well just remove them all together and replace them with builtin functions.
>>
>>62030219
With operator overloading you have two "problems".
>It no longer becomes easy to distinguish primitive types from user-defined types
>Some retard will overload + to mean something which isn't addition and == to mean something which isn't equality.
>>
>>62030236
Far better than the == vs .equals crap in Java
>>
>>62030236
>>It no longer becomes easy to distinguish primitive types from user-defined types
Not a problem, and a stupid fucking argument.
In C, + is defined over int and float (and others), so if you see something + something, it's "not easy" to determine if it's an int or a float. (Well actually, it is, just look at the fucking type of the variable, the exact same argument applies to C++ and operator overloading).

>>Some retard will overload + to mean something which isn't addition and == to mean something which isn't equality.
Yeah and?
I can define a function called printf that actually invokes the shutdown syscall.
Any language can be abused, this is a non-issue, just don't be fucking retarded and don't use code written by fucking retards.

These are hardly problems, in fact, they are flat out not problems at all.
Try again.
>>
>>62030291
I actually don't mind .equals in Java. It makes tests of reference equality vs tests of value equality consistent and clear.

>>62030334
I like operator overloading when used tastefully, but take one look at streams and you can see how easily it lends itself to abuse.
I wouldn't want to do any kind of arithmetic with non-primitives in a language without operator overloading.
>>
File: no bully pls.jpg (155KB, 502x546px) Image search: [Google]
no bully pls.jpg
155KB, 502x546px
Newfag here


H-How do i do the code tag like
>>62030061
>>
>>62030443
Read the damn sticky.
At least you posted an anime image, so I can forgive you slightly.
>>
how much of a meme is bachelors of IT?
>>
>>62030370
>but take one look at streams and you can see how easily it lends itself to abuse
I don't think it's abuse, because the << notation actually makes sense for what it does.
But I do think that C++ streams syntax is pretty ugly. They really need to standardize precompiled and type checked format strings (that compile down to stream operators, prehaps?) built into the language, kind of like Rust. That would improve it a whole lot.
I've actually tried to implement at least type checked format strings in C++ using templates and constexpr functions (they can accept constexpr char*, and actually dereference them), but that failed because I couldn't figure out a solution.
Maybe someone who is better at TMP/constexpr magic than I am could look into it.
>>
>>62030443
[fag]
your.code(here)
[/fag]

replace fag with code
>>
>>62030508
https://github.com/fmtlib/fmt
This one might get standardized soon.
>>
>>62030528
Great, that's another thing C++ needs: more duplicated functionality.
>>
>>62030579
It's not duplicated if it's much much better.

printf:
>Zero type safety
>No support for user defined types

Replacing shitty things with much better things is generally good.
>>
>>62030606
typesafe printf? Yes please.
>>
File: g.png (578KB, 1500x1500px) Image search: [Google]
g.png
578KB, 1500x1500px
/g/ word cloud created using Python
>>
>>62030639
Compilers have been able to accurately check printf arguments for ages.

>>62030606
>>No support for user defined types
Because creating a function which returns a string is so difficult.
>>
>>62030656
>Because creating a function which returns a string is so difficult.
>Unnecessarily allocating memory
>Bloating your code with stupid shit, because if you want to free that memory, then you have to assign that string to a variable before the print, in order to free it after the print, resulting in very ugly code

>as opposed to just directly writing the characters as they are generated out to a stream, and not having to bloat up your code with noise
>>
>>62030656
>Compilers have been able to accurately check printf arguments for ages.
It is non standard, and it's a really shitty hack.
You shouldn't even have to specify the type at all in the format string, you should be able to just put something like {} and the compiler be able to call that objects specific formatting method, after verifying that it even has one.
>>
File: 1503153124893.jpg (25KB, 540x540px) Image search: [Google]
1503153124893.jpg
25KB, 540x540px
>>62030195
I feel sorry for you
>>
>>62030653
>it'll

pajeet..
>>
>>62030195
autismo
>>
File: jday.png (379KB, 1331x332px) Image search: [Google]
jday.png
379KB, 1331x332px
waiting for jenkins
for
jenkins
>>
>>62030859
"it will".
Are contractions really that hard for you to understand?
>>
>>62030963
the point is that all other contractions were filtered out but this one slipped by
>>
>>62031003
Not the anon you replied to but the one who made the word cloud. The only non-alphabetic character I retained when sanitizing the input was the ' character (which, in retrospect was a mistake). The Python word cloud library I used only removes the ' character if a word is in the possessive form, or if that word is in the set of words to ignore (in this case, the set of common english words) hence the inconsistent results in that regard.
>>
What are some good materials for learning C#? Where can I find its standard library documentation?
>>
>>62024567
>knowing more poisons your reasoning
Hogwash.
>>
>>62025317
C is the only mainstream language left without any kind of automatic memory management. Why put up with this?
>>
>>62031374
because [alternative with same degree of control except much stronger semantics and equivalent performance] is for brainlets
>>
>>62025813
>zero cost abstractions
Almost every abstraction in C++ is based on functions in one way or another. It just so happens that optimizing call graphs is one of the most important and most difficult problems in compilers. Failing to inline has a very high cost because it prevents other optimizations.
To consider any abstraction that makes the compiler deal with more function calls zero-cost is not sensible. Its still zero cost in theory because inlining/outlining is purely up for the compiler to decide in C++. But realistically it's not that simple.
People don't inspect their disasm enough to learn to hate C++.
And using compiler attributes to force the compiler is not a good solution because the compiler is the only one who knows what's best in context. It can solve individual instances of the problem though.
>RAII prevents a lot of mistakes.
More than that, it hides mistakes. Makes code slow where resources should be managed in chunks and is just a poor idea perpetuated by exception handling.
The one instance where I find RAII useful is in stack allocation. Where C and C++ don't have good facilities to specify an object as living entirely on the stack. And it's trivial to deal with.
>>
>>62031420
good post
>>
>>62025907
RAII is zero-cost and really useful
>>
>>62031420
You're talking about sepples. You simply can't use sepples in groups. It's for single programmers only that's a huge problem.
>>
>>62030653
Make /dpt/ cloud
>>
>>62031451
>zero cost
No. Stop lying to yourself and everyone else.
>>
File: 1503399635969.jpg (379KB, 1920x2110px) Image search: [Google]
1503399635969.jpg
379KB, 1920x2110px
>>62025163
I see malloc casts all the time. What's the purpose of it? malloc returns a void pointer, right?
>>
>>62031579
>posts anime for no reason
>asks question that could be answered searching google

sigh
>>
>>62031579
C++ does not allow implicit conversions from void* to other pointer types.

But if you're writing C++ you should use operator new instead.
>>
>>62030520
test
>>
>>62031579
Thank you for posting anime image.
>>
File: 1264126944732s.jpg (9KB, 251x189px) Image search: [Google]
1264126944732s.jpg
9KB, 251x189px
>>62031608
>posts anime for no reason
You need to have reasons to post anime on anime website?
>>
File: 1502468106477.png (119KB, 317x641px) Image search: [Google]
1502468106477.png
119KB, 317x641px
>>62031608
>>
>>62031579
>>62031682

cute
>>
>>62031579
C++ doesn't let you use malloc in the convenient way C intended. They 'fixed' malloc by breaking its convenience.
If you're just a newbie you should just use new in C++.
Nobody serious uses malloc or new directly in C/C++ though.
>>62031625
I don't agree with making such a blanket statement on the operator new vs malloc in C++.
http://www.scs.stanford.edu/~dm/home/papers/c++-new.html
>>
>>62031608
There's reason. Anon wanted to post anime. It's a good reason. And if it makes him and me happy it's also a good thing.
>>
>>62031579
Just letting the compiler know what you think the hunk is supposed to be is so it'll throw an error if you try to assign it to the wrong kind of pointer.
>>
>>62031732
You don't know what operator new is. Hint: it's not the new operator.
>>
>>62031682
Dumb akariposter
>>
>>62031840
>operator new
>the new operator
I'm not sure what you mean anon. I'm talking about these:
http://en.cppreference.com/w/cpp/memory/new/operator_new
>>
>>62031224
MSDN
>>
>>62031874
If you call the allocator function directly in this fashion
void *buf = operator new(1024);

Works just like malloc, except now you don't have to worry about whether you should delete or free that pointer.
>>
is it possible to write a 'professional, sort of' application with SFML?

its very easy/comfy to use desusempai
>>
>>62032079
If it's comfy it can't be professional.
>>
>>62032104

i mean... i can put sprites and shit on it, why cant i? as long as i can put buttons will there be problems?
>>
>>62031939
That's nice. Didn't know about that. But why you call that operator new when new is an operator and every other instance of it in the language is declared as operator new and the whole world calls new an operator. It's just a weird distinction. It's still bounded by the fact that you can only specify alignment for the globally replaceable news.
>>62032079
There's lots of worse choices being made in professional applications. Don't worry about it. It's zlib license so if that was what you're asking you're golden.
>>
>>62032164

bad choices such as?
>>
>do a shit ton of /v/ cross-linking
>end up getting 1-day banned for asking why /dpt/ hates karlie kloss
Funny how that works.
>>
how do people handle camera movement?

im thinking of moving the entire world according to my movement but I think that is incredibly dumb

or maybe have every object's location in an array then calculate the distance to be rendered on the camera nbased on that?
>>
I want to build an application like Dropbox: a user basically dumps something via the web (after authentification) onto another PC.

Would an Cloud Web App make sense for that? Or is there another go-to solution?
>>
>>62032351
>im thinking of moving the entire world according to my movement but I think that is incredibly dumb
That's how 99% of games do it.
>>
>>62032351
I don't know much about opengl but I think the entire world is transformed based on your current location in the vertex shader
So yes, you "move" the entire world
>>
Why is console I/O on Winblows so slow?
>>
>>62032421
>Winblows
Found your problem
>>
Can we all agree that C# is the best language for scripting games?
>>
>>62032429
you did?
>>
>>62032402
>>62032392

why dont they do my second option? you only have to calculate the thing in front of you
>>
>>62032436
C# is the best language for pajeets that think they are too cool for Java
>>
>>62032446
>have every object's location in an array then calculate the distance to be rendered on the camera nbased on that?
The vertex positions are already available in the shader
>you only have to calculate the thing in front of you
I think this is what culling is for
>>
>>62032262
There's people whos method of developing mobile apps is to open a web-frame and then do all of their actual application as if it were a web application.
Just for instance. Whatever issues you see with using SFML for your applications are probably mild compared to that.
>>62032310
We don't in general. I get the sense that /dpt/ understands the nature of it. Invaders do hate, and they probably don't understand it at all.
>>
File: 1502976455772.jpg (41KB, 439x439px) Image search: [Google]
1502976455772.jpg
41KB, 439x439px
>>62032446
It's less expensive to transform all vertices in world space than to move camera space.

Imagine the kind of maths involved with moving a camera from point of origin and doing perspective/projection from that relative point, to simply moving all points in world space.
>>
File: 1503399189503.png (107KB, 421x269px) Image search: [Google]
1503399189503.png
107KB, 421x269px
>>62032520

man you reminded me to sharpen my linear algebra skills

;...; too much work desu
>>
>>62032351
Normally you use a world-matrix that transforms the world into your view.
Read this:
https://learnopengl.com/#!Getting-started/Transformations
You can ignore the opengl specifics and just try to grasp how and why they do this.
>>
>>62030864
>>62030828
Don't lurk on 4chan and then be suprised by the presence of spergs.
>>
>>62032520
weeaboos are always the most productive posters
>>
Can someone recommend me a good book on how graphics engines work? I'm coming from a mathy background if that helps.
>>
>>62033024
Why not just read the source code, some engines even have documentation about how they work for example Horde3D.
>>
>>62033024
Computer Graphics Principles and Practice
Real-Time Rendering
Physically Based Rendering
>>
>>62033043
I asked for a book. The source code doesnt have arguments on why something is good or bad.

>>62033065
Thank you.
>>
>>62032520
Oh, so they move the world instead of the camera to not fuck up perspective?

Neat.
>>
>>62033099
Just a heads up, all those books are expensive as shit unless you get like one edition older. I got Second Edition CompGraphics for like 10 bucks on ebay, and Second Edition Real-Time Rendering for like 7. Physically Based Rendering seems expensive unless you get the First Edition, though.

The only thing you're missing from Third Edition in CompGraphics is Bezier Curves. Not sure what the real differences are between Second and Third in Real-Time Rendering are, though.
>>
File: 306607.jpg (29KB, 225x350px) Image search: [Google]
306607.jpg
29KB, 225x350px
Nene says you should be using C++!
>>
>>62033136
>buying books
>>
File: SpeakAssembly.png (79KB, 651x241px) Image search: [Google]
SpeakAssembly.png
79KB, 651x241px
How's your Assembly, /dpt/?
>>
>>62033171
Physical is so nice though
>>
>>62033185
Computer Hardware classes are where you learn Assembly, right?
>>
>>62033164

I would c plus plus her coony if u know what im saying
>>
>>62033185
I only know basic x86/x86_64
>>
File: cuteSoftwareRasterizer.webm (2MB, 1440x1080px) Image search: [Google]
cuteSoftwareRasterizer.webm
2MB, 1440x1080px
Learning some 3D
>>
>>62033345
PD
>>
>>62031579
Pre-ANSI C didn't have void, malloc returned a char * by default, requiring an explicit cast.
In fact, omitting the return type was the cool thing to do because it would implicitly default to int.
C89 brought implicit casting from void *.
C++98 doesn't allow this, it requires an explicit cast.
>>
Decided to do some C programming on Windows, yes I know... Anyway so i download mingw write quick sdl window program aaand try to compile and guess what i get? Linkage error? no... Entry point error so I'm forced to use this horror:

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)


where hPrevInstance is legacy shit from 16 bit days and is always 0, first one is handle for windows to know shit, third one is only one of interest...
ugh...
>>
>>62033509
Either make the subsystem console (in which case a cmd window spawns as well), or specify the entry point as mainCRTStartup and you can use regular main() for win32 programs.
>>
>>62033509
I think you link -mingw32 or something to it it'll fix the need to use WinMain. There's like 12 StackOverflow questions about the same shit, go looking.
>>
>>62033625

how do i set it to mainCRTStartup? Its not subsystem so i don't know how...
Is there any downsides to using WinMain as entry point beside horror to the eyes and one line replace loss of portability that can be macroed away?
>>
File: 142706709091.jpg (853KB, 1416x1072px) Image search: [Google]
142706709091.jpg
853KB, 1416x1072px
>>62033345
At first looks like some Amiga demo
>>
>>62033509
int main() works for me using mingw32-gcc
>>
>>62033164
What's good full and quick book on C++?
>>
>>62033509
You are using SDL 2.0 or 1.2?
>>
>>62033761
SDL 2.0 but i decided not to bother anymore ill just use WinMain entry point and add just simple ifdef for recompile on Linux... I wont be looking much at main anyway
>>
How to do live programming or library hot reloading with C?
I know I can reload shared libraries but is there some IDE or others tools that already accomplish this?
Something like I
edit one line
press some key combination
it compiles the library, reloads it into the running program
???
profit
>>
File: 1501996332194.jpg (21KB, 411x376px) Image search: [Google]
1501996332194.jpg
21KB, 411x376px
>>62025190
>want to work on something
>when I try a wave of anxiety pours over me
>>
>>62033792
Well for recompiling on save is easy u can check last edit date and make your own program to do that, should be simple enough on Linux.Have not sure about reloading shared libs
>>
File: baka.jpg (7KB, 225x225px) Image search: [Google]
baka.jpg
7KB, 225x225px
>>62033799
try drunk programming
>>
write a better one than this shit

int rand_with_negative(int range)
{
unsigned int rand_value = 2 * rand();
int value;

if ((rand_value) & (1 << 31)) {
value = -(rand_value / 2);
} else {
value = (rand_value / 2);
}
return value;
}
>>
>>62033815
Probably a good idea, but I wish I could do it without a drink.
>>
>>62025317
Are all those c++ books good?
>>
>>62033831
>take range as argument
>nowhere use range
>>
>>62033899

sry sebnai, i fixed it with homomorphism or whatever its called

int rand_with_negative(int range)
{
unsigned int rand_value = 2 * (rand() % range);
int value;

if ((rand_value) & (1 << 31)) {
value = -(rand_value / 2);
} else {
value = (rand_value / 2);
}
return value;
}

int rand_with_negative(void)
{
return rand_with_negative(1);
}
>>
>>62033831
Maybe something like this?
int rand_with_negative(int range)
{
return rand() % (2*range) - range;
}
>>
>>62033930
Is it C++?
>>
i need help C++

I have a program that does something every 5 seconds, i.e. Sleep(5000) (win32)
i want to be able to pause it by pressing space and quit with ESC

i do this with GetAsyncKeyState(key)

the problem is that when the program is in Sleep, no keypresses seem to be recorded (i expect to press ESC and the program should exit at most 5 seconds later when the Sleep ends), even though it's supposed to be ASYNC, documentation says GetAsyncKeyState is true if the key has been pressed since the last call to it

do i need to make 2 threads for this?
>>
>>62033946

wouldn't it be 0 for any x > 2^31 - 1 ?? because RAND_MAX is 2^31 - 1 so the % will return 0 every time
>>
>>62034068
What do you refer to as x?
The range?, the value that rands returns?

Also, with the answer I gave, bad stuff happens when range >= RAND_MAX
I think this is better:

int rand_with_negative(const int i_range)
{
int range = abs(i_range);
return 2*(rand()%range) - range;
}
>>
>>62033792
There's not that much information on that that I've found. But there's this.
https://hero.handmade.network/episodes
Day 22-23
and
https://asafgartner.github.io/annotations_search/#live%20code
(note day 087 for instance)
It sadly puts some constraints on your memory model.

Also consider this:
https://blog.molecular-matters.com/2014/05/10/using-runtime-compiled-c-code-as-a-scripting-language-under-the-hood/
It's not quite what you're after I imagine but it's similar.

The reason you get hits mostly for game engines is because most other software don't tend to need this. Often when you patch software you allow yourself the freedom to just restart. Games have a development model that often has a lot of interactive inspection/testing.
>>
>>62033792
>>62034472
Also:
https://github.com/RuntimeCompiledCPlusPlus/RuntimeCompiledCPlusPlus/wiki/Alternatives
This is nice. It's broader than hotswapping.
>>
>>62034429
return 2*(rand()%range) - range;

return 1*(rand()%range);
>>
File: 1501768070135.jpg (785KB, 1712x1535px) Image search: [Google]
1501768070135.jpg
785KB, 1712x1535px
Just learned if in C. Rate my first project
#include <stdio.h>

int
main()
{
int b, d, e, a, c;


printf("Does \"she\" have a penis? Y/N:");
scanf(" %c", &a);

if (a == 'Y'){
printf("Is it a femenine penis? Y/N:");
scanf(" %c", &c);
if (c == 'Y')
printf("Nice!");
else
printf("Gay as fuck bro");
} else {
printf("Did she have a penis before? Y/N:");
scanf(" %c", &d);
if (d == 'Y')
printf("That's fucking gross.");
else
printf("3D women lmao");
}

return(0);
}
>>
>>62034049
Make use of the win32 message loop.
GetMessage is a blocking call, so it will put your thread to sleep until a message (like a keypress or timer event) arrives.
Search on msdn for win32 message handling example.
>>
File: sexylegs.jpg (32KB, 960x720px) Image search: [Google]
sexylegs.jpg
32KB, 960x720px
Best resource/book to learn Hasklel?
>>
File: nooo.png (933KB, 1953x1400px) Image search: [Google]
nooo.png
933KB, 1953x1400px
>>62034746
What's your current experience?
>>
New thread:

>>62034793
>>62034793
>>62034793
>>
>>62034593
Fucking terrible.
>>
>>62034746
The wikibook, though it's quite slow
>>
File: 1304432226655.jpg (42KB, 300x332px) Image search: [Google]
1304432226655.jpg
42KB, 300x332px
>>62034798
>declare 5 variables, use 3
>int vars receiving char types
>shit indentation
>parenthesis on return
>printf without newline at the end (on the cases where you don't use scanf)
>actually, using printf for non-formatted output at all
2/10 for effort
>>
>>62034886
>int vars receiving char types
but why does it work?
>>
>>62028232
That's a pretty good metric for entry level chads. Not watching moeblobs.
>>
>>62034972
narrowing conversions
>>
>>62025163
>wah javascript is ugly and fucked up
>meanwhile, the c program bellow is allowed to exist:
#include <stdio.h>

typedef struct honk { int honk; } honk;

int main() {
honk honk;
printf("honk %p\n", &honk.honk);
return 0;
}
>>
>>62034886
>using printf for non-formatted output at all
It's 2017 anon the compilers deal with that trivially.
>>
>>62035341
>typedef struct
horrifying
>>
>>62035341
Are you just pointing out referencing uninitialized memory? What is your concern here?
>>
Will I have to post this in another thread?

---
>>62034972
>>62035215
Because scanf is only changing one byte of the integer. Try this:

#include <stdio.h>
#include <stdint.h>

int main() {
int32_t i = 0x0000ca00;
ungetc(0xfe, stdin);
scanf("%c", &i);
printf("Welcome to deadbeef %x\n", i);
return 0;
}


On a little endian machine it should output:

Welcome to deadbeef cafe



>>62035410
I was just memeing.

I was just showing that C has multiple namespaces.
Thread posts: 323
Thread images: 48


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
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.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.