[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
/dpt/ - Daily Programming Thread
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 255
Thread images: 29
old thread: >>54358814

What are you working on, /g/?
>>
I would really appreciate if anyone could answer my quick question please.

Using Selection Sort to sort an array of integers 1, 3, 8, 4, 2, 5, why is the number of comparisons required 15 and not 20? I need to scan the whole array once to show that 1 is the smallest, and then 3 more times for 3 other swaps, right? So why is it 15?
>>
early
you have shamed hime
>>
>>54363045
>310
>early
nice meme
I remember a day when they were always made at 300 and no one complained :')
>>
OOP should be avoided since most people have no idea how to use it correctly and forced OOP ala java is pure cancer.
>>
File: Illya.jpg (64 KB, 1920x1080) Image search: [Google]
Illya.jpg
64 KB, 1920x1080
>>54363106
>and no one complained
>>
is there a plugin to protobuf that lets you map generated objects to an SQL db somewhat easily?
>>
>>54363042
5 comparisons for i=0.
4 comparisons for i=1.
...
1 comparison for i=4.

Add them up, 5+4+3+2+1
>>
>>54363042
you don't check the number with itself
>>
File: girls who code.png (311 KB, 652x669) Image search: [Google]
girls who code.png
311 KB, 652x669
Could you do any better?
99% of programmers will get this wrong!
>>
>>54363185
public int Product(int a, int b)
{
return a / (1/b);
}
>>
>>54363226
Product(n,0)
>>
>>54363158
>>54363181
I got it from the explanations here and in the last thread. Thank you again.
>>
>>54363248
Alright Einstein in that case throw new IllegalArgumentException("OP is a faggot.");

Happy?
>>
>>54363290
stop pretending to be me please
>>
File: 131241521.gif (779 KB, 500x281) Image search: [Google]
131241521.gif
779 KB, 500x281
>>54363290
>non-monoidal integer product
>>
>>54363185
int product(int a, int b)
{
int val = a;
while (b--)
a += val;
return a;
}


:3
>>
>>54363308
a = n; b = 1;
>>
Here is >>54363308 original code:
int product(int a, int b)
{
int i = b;
while (i--)
a += b;
return a;
}


n/t though.
>>
int product(int a, int b) {
if (b <= 0)
return a;

return product(a+a, b-1);
}
>>
>>54363376
product(5,-1)
>>
>>54363022
Why was the picture deleted?

Mods are bullies today.
>>
>>54363416
I don't know, cracking down on trap OPs is a relatively recent thing, wouldn't have happened a month ago. Guess they're just transphobic
>>
if you know every law of physics, you can simulate the entire universe, right?
Can you shortcut this by just using newtonian mechanics and chemistry and simulate, say just a solar system? Starting from a supernova of course

How do we know we're not in a simulation?

Sorry for the popsci post
>>
>>54363416
AHAHAHAHAHA GET REKT FAG
>>
>>54363416
because nudity
>>
>>54363022

So I'm using PhantomJS and it isn't recognizing my function that is within another .js file in my working directory.

when I try

analyzePage("http://www.internet.com");


it doesn't work, but if I do

foo.analyzePage("http://www.internet.com");


were "foo" has never been mentioned once in my code, it works
>>
Funny thing is, they're more likely to delete this post >>54363448 than this post >>54363452
>>
>>54363449
depends if determinism
>>
>>54363448
it was always a thing, like last year with the 3d trap posting the threads would usually get deleted very quickly
>>
>>54363448
mods are from reddit

t. 4chan insider
>>
just did a quick 160 lines of adding more inline query modes for my telegram library but im trying to focus more on finals than code right now
im getting kinda close to having full 2.0 support but im thinking i want to redesign some parts of the library since 2.0 requires me to break compatibility anyways. maybe i should just do a 2.1 release that revamps the core API? anyone got some advice for this?
>>
>>54363478
3d isn't anime, and they weren't programming related
>>
>>54363022
I'm writing a game, I've already written a lot of the games backend logic, and I can interact with it via a primitive text interface
I've written the game in what could be called C-like C++, using C++ features for a few areas where objects are most helpful, but most of it is functional/procedural in design.

I need to choose a graphics library to use. I've narrowed my choices down to SDL, GLFW, and SFML. What do you guys prefer and why? Thanks :)

It's time for me
>>
>>54363496
there was one with the haskell logo shopped onto his shirt, that's about as programming related as OP's fag shit
>>
>>54363468
>PhantomJS
nice
>>
File: mainmenuripples-nosound.webm (610 KB, 316x562) Image search: [Google]
mainmenuripples-nosound.webm
610 KB, 316x562
Wanted to work on my shitty game last night/today but I've fallen ill, four days before my "if you dont pass this you have to change majors" exam. (true for everyone taking it, doesn't have to do with my current grades or anything)

Oh well.
>>
File: booleanfoolean.jpg (176 KB, 1366x768) Image search: [Google]
booleanfoolean.jpg
176 KB, 1366x768
>>54363022
so im learning java right now, teacher gave me this. i keep thinking the boolean false statement become useless b.c the if else statement but he says nothing gets taken from this just added and im not sure what i should be adding to make it use the boolean false statement can i get a hint?
>>
File: code bloat.jpg (99 KB, 630x655) Image search: [Google]
code bloat.jpg
99 KB, 630x655
>>54363525
>Haskell
>Programming related
>>
>>54363593
>stupid
>retard related
>>
>>54363593
still more programming related than the fag shit
>>
What's harder: assembly or Node JS?
>>
>>54363639
node js probably
>>
>>54363408
happy?

int product(int a, int b) {
int val = a;

if (b == 0) {
return val;
}

if (b < 0) {
if (a > 0) {
return product(0-a, b+1);
} else {
return product(a-a, b+1);
}
}
else if (b > 0) {
return product(a+a, b-1);
}

return INT_MAX;
}
>>
>>54363663
ignore the val. I was testing something out first that failed.
>>
>>54363663
wow this is genuinely terrible and I feel bad for you
>>
>>54363639
my dick when fkin ur mom lol
>>
>>54363586
he's using a style from C where you declare all your variables at the top of the function so people can easily figure out how much memory the function will use. its useful but somewhat outdated. you can take that line out and change the below code
boolean foundNumber = checkGuess(...)

or
if (checkGuess(...
>>
>>54363639
apples and oranges
>>
>>54363716
It is called tech debt.

Notice how my original one here >>54363376 covered everything in >>54363185

Then >>54363408 changed the requirements, and instead of rewriting I did what anyone would do and add on to it.
>>
>>54363586
if(foundnumber == true)

Your teacher is an idiot.
>>
File: 4fuk222.webm (3 MB, 576x356) Image search: [Google]
4fuk222.webm
3 MB, 576x356
Making my BFS not shit.
>>
>>54363768
>didn't work with zero
>didn't work with one
>didn't work with negatives
>changed the requirements

Maybe you shouldn't have used ints in your type signature then
>>
>>54363551
>>54363787
>>>/vg/agdg/
>>
>>54363308
>using val to copy a value
>update a instead of updating val (val should be named product instead)
>wrong result (should using --b instead, or product = 0 before hand)
fuck you. I hope you'll die in the most horrible way ever.
>>
>>54363716
this

and drop the recursive function calls for fuck's sake, you should literally never have them
>>
>>54363841
I'm not using an engine though :) agdg is for unity babbies
>>
>>54363787
why is the motion so jerky and fuck off to >>>/vg/agdg
>>
>>54363865
I thought arguing about enginedev is all that they were doing over there?

Anyway, what are you using?
>>
>>54363888
I haven't been so I don't know actually
And I'm using meme library libGDX
>>
>>54363878
It's jerky because there's supposed to be a pause between each 'turn'. Also Okay, but i'll shitpost here aswell.
>>
>>54363738
>>54363780

he said nothing should be changed in the main ,just added to it
>>
In c++ how should I declare global functions whos header is included in multiple source files?
>>
so here i am /dpt/, getting ready to get into GUI and Game making with C++.
So what are good stuff i need to read to get into those. The thingi want to learn from game programming is jsut the general train of thoughts that go into making them.
i picture i should go about them this way.
i make a core that holds all the data types, with a layer with all the functions that will apply on them as well as general functions to the general flow of the program, then for a gui software, a layer with all the GUI elements, connected to the inner layer's functions with the general flow dictated in this layer.
should go the same for game making.
any help would be good on this shit.
also i guess i'll getting into Qt now, right?
what else should i go for to study the general way GUI components should work, or the various ways you can connect them together or whatever. same for gaming.
>>
>>54363942
oh he wants you to define checkGuess and getNumber.
>>
>>54363955
write it in a header file, include the header file in your source files
>>
>>54363955
file.hpp:
#ifndef HEADER_HPP
#define HEADER_HPP

void function();

#endif


file.cpp
#include "file.hpp"

void function()
{
}


Then include the header wherever you need to use the function.
>>
>>54363955
you should define the functions :
int getNumber(10){
//generate a random number beteween 1 and 10
}
boolean checkGuess(randomNumber, userGuess){
//compare these two values and return true if equal, false otherwise.
}
>>
>>54364015
meant for >>54363942
>>
>>54364015
for getNumber i did a number generator at the top but its still showing it as a non defined symbol and i cant figure out why
>>
>>54364012
Every compiler worth a damn supports

pragma once


No more need for the ugly ifndef/define/endif boiler plate in headers.
>>
>>54364118
show me code or something, i can't read your thoughts.
please use pastebin, don't take a screencap
>>
>>54364175
made one of these

<script src="//pastebin.com/embed_js/QDCBvFhz"></script>
>>
Dudes, weeds, lmao.
>>
>>54364279
holy shit
>>
>>54364300
benis haha :-DDDDDDDDDDDD
>>
>>54364279
rip
never tried using paste
>>
>>54363846

jesus christ nigger chill the fuck out
>>
What augmented reality libraries do people actually use?
>>
>>54364279
you kind of want to learn how to program first
>>
>>54364279
nice xss exploit bro. should have known better than to trust 4chang with sanitizing user input

IF YOU READING THIS, YOUR 4CHAN PASS HAS BEEN STOLEN AND YOU HAVE BEEN MARKED BY 312cuck
>>
>>54364279
ok the function should be called getNumber not randomNumber.
otherwise it should work fine/
>>
>>54364358
aaaand im a dumbass id have looked at that for days if it wasnt for you

thanks man
>>
Anybody know what I'm doing wrong here?

I'm trying to split the string shown on the right but it only makes an array with two elements and it also doesn't split it in the right place either.
>>
>>54364674
Maybe print out readMessage before the split line?

What are you working on btw?
>>
>>54364674
split[3]

should be
split[2]

The array does have 3 items, the exception message even says so.
>>
>>54364734
Fucking hell, how did I miss that.

Cheers.

>>54364726
RC car with a bunch of sensors and stuff on it controlled via an android device.
>>
>>54364761
neat!

And I've made similar errors before as well, essentially typos that take hours to find... Try the duck debugging method in the future perhaps
>>
File: 126146619089.jpg (155 KB, 550x700) Image search: [Google]
126146619089.jpg
155 KB, 550x700
Eclipse or IntelliJ for Java?
>>
>>54364817
IntelliJ
>>
>>54364817
I tried Eclipse for a week or so, started tolerating it until I used IntelliJ. Huge, huge fan of IntelliJ now.
>>
>>54363376
>>54363348
>>54363308
>>54363226
Why the fuck are you guys doing actual bitwise iteration?

public int Product(int a, int b) 
{
try
{
return a*b;
} catch {
throw new System.ArgumentException("Parameter Invalid", "a", "b");
}
}
>>
>>54364881
>without * operator
>>
File: 1332738190302.jpg (48 KB, 613x533) Image search: [Google]
1332738190302.jpg
48 KB, 613x533
>>54364900
Ah.
Yes.
I see that now.
>>
>>54364881
>bitwise
uh
>>
>>54364881
>bitwise
please refrain from using words you don't understand pajeet
>>
File: msf.gif (123 KB, 500x658) Image search: [Google]
msf.gif
123 KB, 500x658
is something like this illegal in python?

for i in range(0, 100):
workhere
tab = []
for i in range(0, 5):
someworkhere
for i in range(0, 10):
someworkhere
tab = map(str, tab)


it says unexpected indent about line tab = map(str, tab). I checked all tabs twice, it looks okay.
>>
>>54364947
>for i in range(0, 5):
>...someworkhere
>......for i in range(0, 10):

that might be it
>>
>>54364817
eclipse

>>54364845
nice shill
>>
>>54364947
fixed
for i in range(0, 100):
workhere
tab = []
for i in range(0, 5):
someworkhere
for i in range(0, 10):
someworkhere
tab = map(str, tab)

remember you only need spacing after a :
>>
>>54364973
I wish I got paid for that post honestly :( I don't even use real IntelliJ, just android studio :)

>>54364983
the second
>>
>>54364983
fixed more
for i in range(0, 100):
workhere
tab = []
for i in range(0, 5):
someworkhere
for i in range(0, 10):
someworkhere
tab = map(str, tab)
>>
>>54365004
>>54364983
sorry guys I fucked up spacing in my previous post

for i in range(0, 100):
workhere
tab = []
for i in range(0, 5):
someworkhere
for i in range(0, 10):
someworkhere
tab = map(str, tab)
here some more work with tab




If comment out tab = map(str, tab) and all code under that line, everything works okay. Now what I am trying to achieve is creating an sql insert at the end of second middle loop each time it iterate.

I tested it with
:set list

and it look normal
>>
static struct Item * as_item(const struct raw * const r, struct Mempool * const mempool) {
const size_t msize = sizeof(struct Item) + r->klen + r->vlen;
struct Item * const item = (typeof(item))mempool_alloc(mempool, msize);
/* etc */
}


>they say java is verbose
>>
Have to implement a symbol table for a compiler by Friday. Fun shit, yo.
>>
>>54363185
uint32_t product ( const uint32_t a, const uint32_t b )
{
uint32_t out = 0;
for ( uint32_t i = 0; i < 32; ++i )
out += ( ( b >> i ) % 2 ) ? ( a << i ) : 0;
return out;
}

Only with unsigned ints, but that's the general idea
>>
>>54365290
>uint32_t
>unportable shit
>>
https://github.com/ziman/idris-ocaml
not gonna lie this shit gave me a boner
>>
>>54365301
What am I supposed to do according to you?
>>
Just finished my decimal to hexadecimal converter!

I'm new to programming entirely, a friend of mine suggested I take this project on as a learning experience and, fuck me, it was a good idea I learned a lot about hexadecimals and making a program that follows on-paper math logic.

Thanks for the encouragement /g/

suggestions for another good learning project?
I'm learning JavaScript right now but I'm open to anything in JS or Python
>>
>>54365194
you're just converting tab to strings over and over
>>
>>54365344
int
>>
>>54365344
uint_least32_t
>>
>>54365301
>unportable
its 2016, why aren't you using the C standard released 17 years ago?
>>
>>54365369
unsigned int product ( const unsigned int a, const unsigned int b )
{
unsigned int out = 0;
for ( unsigned int i = 0; i < 8 * sizeof ( unsigned int ); ++i )
{
out += ( ( b >> i ) % 2 ) ? ( a << i ) : 0;
}
return out;
}

Okay.

So what is the advantage?
>>
>>54365228
>>54365019
>>54365307
>>54365387
memetards BTFO
>>
test
\tbenis
>>
>>54365301
kys

if anything, uint32_t is more portable than unsigned int if you need the 32 bits

>>54365369
UNSIGNED int you ridiculous fucking shitter
>>
>>54365352
ever heard of the tower of hanoi?
it's easy to implement and will teach you recursion. also if you want to have some fun make a simple gui for it in javascript
>>
>>54365368
its weird because something like this works fine.

tab = []
kek = 'meme'
for i in range(0, 4):
tab.append(1)
for i in range(0, 4):
print kek
tab = map(str, tab)


and I am not sure why my code poste before is not working, I tested it with vim
:set list and it show that I have proper indent
>>
>>54365538
Will do thanks
>>
>>54365538
easier just to M-x hanoi :-)
>>
File: the_standard.png (48 KB, 779x266) Image search: [Google]
the_standard.png
48 KB, 779x266
>>54365417
exact width integer types are optional in c99
>>
>>54365417

uint32_t is not guaranteed for all implementations of C99 and C11. Where none of the standard types are 32 bits in size, uint32_t can't be used. It is preferred by some to use uint_least32_t for types that don't need to fit exactly 32 bits, but need to be at least 32 bits and as small as possible.
>>
>>54365352
good work anon

a couple exercises:
1. make a program that prints all permutations of a string
so, if you enter the word like "dog", it will print "dgo", "gdo", "god", "ogd", "odg"

2. write a program that prints the prime factorization for a number (less than, say, 100)
so if you enter 45 it will print 3^2 * 5^1
>>
>>54365567
>>54365575
Should anyone really care though? I get the whole autism here, but it's not an actual relevant problem, come on. I use int*_t because it's short and I see exactly what I get.
>>
>>54365301
When I write software, it should work on most but not all systems.
However, for the systems on which it does work (virtually all consumer personal computers), it must work exactly how I desire.
This means exact width types.
>>
>>54365648
or you could not write shit code. I bet you're one of those programmers who thinks they need to know the byte order of their system to write portable network code.
>>
>>54364881
What in the world is bitwise iteration?
This is the new rotational velocidensity.
>>
>>54365648
do you also make sure this is true?
sizeof(char) == sizeof(short) == sizeof(int) == sizeof(long)

because there are real systems that guarantee this
>>
>>54365675
Well no, in C (both unix and winsock) you have htons and friends, in C++ asio will do it.
What is your point?
>>
>>54365648
When you use [u]intN_t, you're making the claim that this type is that exact length for a specific reason. You should question whether that type NEEDS to be N bits, or if it only needs to be at least N bits.
For example, if you want something to be at least 32 bits portably, use long or [u]int_leastN_t. There is no point fixing a type to exactly 32 bits, just because it MIGHT overflow 16 bits.
The only situation I can think of where you really need exact width integer types is when you're dealing with binary files where you need to read values that are an exact size.
>>
>>54365803
Oh.
>>
>>54365680
When you do things like
if (val & (1 << a)) 
out |= (1 << a);
>>
So I'm writing some C++.

I try to combine an int and a string and I get the weirdest results.

 
int number = 250;
String str = number + ".txt";
Serial.println(str);


All I get is weird characters.
>>
>>54365615

For pretty much all relevant platforms, you don't need to care. Tru64 UNIX on an Alpha machine doesn't support 32 bit types, but chances are high that the code that you're writing won't be run on one.
>>
>>54365962
Let me fix that for you:
int number = 250;
String str = std::to_string(number) + ".txt";
Serial.println(str);
>>
>>54365989
Hmm I thought I read I could do it my way.

Thanks
>>
>>54365962
>>54365989
uh shiet didnt realize it wasnt std::string, sorry
>>
>>54365962
you want to concat the string and the number?
first you convert the into to a string
stringNumber = to_string(number);

then you use strcat
>>
What can I use C++ for? I mainly use C, Java, Python. I just want some C++ on my resume mostly, and am interested in getting back into the language.
>>
>>54366050
Any software involving 3D graphics
>>
>>54366006

What you did is more like this:

const char *str1 = ".txt";
const char *str2 = &(str1[250]);
string str = str2;
>>
>>54366050
contribute to qTox
>>
>>54366050
>What can I use C++ for?
masochism mostly.
>>
>>54366081
>>54366028
>>54365989
std::string has operator+(int), right? can you do
string s = "dog";
string s2 = s + 5; // "dog5"?

I'm hoping not, seems javascripty
>>
>>54366081
All he did is printing ascii equivalent of 250, ie
printf("%c", 250)
>>
>>54366050
C++
Legacy as quant for 30k $/month salary
>>
>>54366093
Getting into my desired company doesn't seem like masochism, although I do agree C++ is, as everyone says, a huge clusterfuck.

>>54366083
Seems maybe over my head but contributing to foss sounds like a good idea.
>>
>>54366014
>>54366028
>>54366081

I used strcat to add them together and it worked fine. Thanks for the help everyone.
>>
-
-
Does a video contains more bytes if it has a fat person recorded in it?
>>
>>54366105
Nope std::string does not have operator+(int). Your example will not compile.
>>
>>54366210
okay, good
>>
File: playlist system.png (16 KB, 818x427) Image search: [Google]
playlist system.png
16 KB, 818x427
Finally hacked a playlist onto my music player.
>>
>>54366191
since the less pixels change in a video between frames, the more it can be compressed; and taking into consideration that fat people could potentially fill more pixels of a frame and are less likely to move than average people; i'm gonna say no, it potentially can be compressed to be smaller in bytes than the same length video of an average size person.
>>
>>54366249
Today is a good day because you did your best!
Good job.
>>
>>54366249
I have not seen that in quite a while. It's always nice to revisit old projects huh
>>
File: 1458255503220.jpg (47 KB, 720x439) Image search: [Google]
1458255503220.jpg
47 KB, 720x439
>>54366249
>>
>>54366249
What UI framework? Is that XP?
>>
>>54366262

I don't get it.

>>54366265

I saw some other guy on here was working on his media player and I was like "huh, maybe I should do that."

It really is hacked on there in the truest sense of the word, though. The code is awful, top to bottom. It was an old project, after all.
>>
>>54366268
>win98 window decorations
>>>>XP
I'm pretty sure up to win 7 had the option for win98 window decorations, no?
>>
>>54366268

WinForms & Win7.
>>
>>54366284
I feel; I think that every project I've done in the past was designed poorly and could be done better. The thought is keeping me from extending past projects, it would be better to just redo them
>>
File: FortranCodingForm.png (54 KB, 1573x997) Image search: [Google]
FortranCodingForm.png
54 KB, 1573x997
Should I go full hipster?
>>
>>54366316
It would be fun at least.
>>
>>54366301
not bad looking
>>
>>54365962
>String
>not string
>>
>>54366120

Nope. He added 250 to a pointer and printed garbage. Pointer + Integer = Integer + Pointer = Another pointer.
>>
>>54366336

thanks fambly. I've been meaning to redo it entirely (and do it right).
>>
File: 12.png (254 KB, 875x692) Image search: [Google]
12.png
254 KB, 875x692
>>54366284
>Today is a good day because you did your best!
>Good job.
>>
>>54366131
>Seems maybe over my head but contributing to foss sounds like a good idea.
There is probably plenty of little bugs and stuff to fix.
>>
>>54366347
You don't know that a String is a pointer, famalam

(unless you do, I honestly have no idea what String he is using)
>>
File: bait_for_the_khorne_flakes.jpg (85 KB, 1016x970) Image search: [Google]
bait_for_the_khorne_flakes.jpg
85 KB, 1016x970
>>54364881
>missing the point this hard
>>
>>54366249
you should add a background to it and make it look like pic related
>>
>>54366351
What would you change? Do you have it online?
>>
>>54366368
you must be 18, pizza man
>>
>>54366380
guess again
>>
>>54366258
>>54366191
however: a static background is kinda the best compressed chunk of a video, and a fat person though hardly ever in motion, can cover up a sizable static background. certainly more than an average size person.
>>
>>54366391
I was telling you that you have to be 18 to post here, not guessing that you are 18 years old
>>
>>54366362

The type of a string literal in C++ is defined by standard to be const char*. Adding an integer to that is just basic pointer arithmetic.
>>
>>54366362
>You don't know that a String is a pointer
const char *str2 = &(str1[250]);
string str = str2;

For that assignment to be valid, string MUST be a pointer, unless there is some silly Meme++ nonsense going on in the background that I don't know about.
>>
>>54366413
then why are you still here?
>>
>>54366428
you got me, I mean't to say you must be at least 18
>>
>>54366438
>>>>>>>>>>>>>>mean't
shit
I have it coming
>>
#include <stdio.h>
#include <stdlib.h>

int main(void)
{
1 || puts("Top\n");
0 || puts("Kek\n");
1 && puts("M8\n");
0 && puts("Fag\n");

exit( 0 );
}


what is the output?
>>
I've been programming for around 4 years (on and off), and I've produced absolutely nothing of actual value. Everything I've done has been a small project. The realization is a pretty terrible feeling and I don't know how I get it to stop.

Does anyone know this feel?
>>
>>54366375
>What would you change?

Literally the whole thing. The UI and logic are tangled together.

>Do you have it online?

Nope.
>>
>>54366473
Top
Kek
M8
>>
>>54366473
>Top
>Kek
>M8
>>
>>54366476
Yep, well I'm not depressed or anything, but I'm also a student with a job in the field so the fact that I've only ever made small personal projects isn't a depressing idea. Perhaps contribute to FOSS?
>>
>>54366490
>>54366506
explain
>>
>>54366490
>>54366506
Logical OR is short circuiting.

>>54366473
"Kek

M8
"
>>
>>54366533
the || ones will always print
the && ones will only print if neither of them is 0
>>
>>54366476

Yep. But you just have to keep pushing yourself. Always make new goals. Try new shit, find things you want to make, attempt them when you have the time... and have fun even if what you make is just a toy.
>>
>>54366533
if the first operand of && is false, it doesn't check the second one, because it already knows the entire statement evals to false
>>
>>54366480
>Nope
You should. I like the minimalism of it. Do it up nice and polished and you might find a lot of people appreciating it.
>>
>>54366556
>>54366569
Right, I understand logic operators
I don't understand how puts() is "true" or how 1 or 0 are true/false, nor do I understand how those are interpreted as statements rather than the conditions to check before executing a following statement.

How is the command (puts()) also one of the conditions?
>>
File: 0002 - YauaMbL.jpg (552 KB, 1631x1571) Image search: [Google]
0002 - YauaMbL.jpg
552 KB, 1631x1571
>>54363022
>download writing software demo
>see its $60
>"well might as well try to test my cracking skills"
>realize its in java
>mfw
>decompile it and find out the keys are generated from retarded method
>make keygen

why would anyone write commercial fucking software in java? i dont understand.
>>
>>54366596
>>54366596

>1 || puts("Top\n");
Here, the compiler knows the entire statement is true after it checks the 1. My compiler doesn't print Top here, but yours might.
>0 || puts("Kek\n");
It checks the 0. 0 is false, so it checks the second operand, puts("Kek\n");. To check an operand, it has to evaluate it. So it evaluates puts("Kek\n"); by running it, like anything else.
>1 && puts("M8\n");
For && to be true, both conds have to be true, and since it knows the first one is true, it checks (runs, then checks the result) of the second one.
>0 && puts("Fag\n");
Since for && to be true, they both have to be true. If 0 isn't true, there's no use in running and checking the second operand, since we already know the statement evaluates to false
>>
>>54366601
I have some software written in C# that i'm adding copy protection too. Basically verifies with a server that it's not copied. I figure if i sell enough copies for someone to bother cracking it i'll be in good form anyways. Could rewrite the whole activation system then with something more crack proof.
>>
>>54366596
C needs to evaluate any statement on either side of || so it can return a value.
and C considers anything except 0 to be true. not just 1.
maybe you need to study some compilers.
also this guy is right >>54366548
it will short circuit. the actual output is as he said
>>
>>54366648
>So it evaluates puts("Kek\n"); by running it,
this feels very obvious now and i feel dumb
>>
>>54366674
it's okay, you are dumb
>>
File: 1222579124503.jpg (32 KB, 367x341) Image search: [Google]
1222579124503.jpg
32 KB, 367x341
>>54366682
>>
>>54366665
look - as long as you don't have the fucking key generation methods HARDCODED INTO THE FUCKING SOFTWARE ITSELF, you should be ok.
>>
>>54366698
Sorry, I'm just projecting
>>
https://www.youtube.com/watch?v=kLpyuaNyli0
>>
>>54366749
hey terry
>>
>>54366749
>Random
more like pseudo-random
>>
>>54366771
They're divinely random
>>
>>54366814
No.
>>
>>54366710
wow, yeh i don't do that. It checks with a server to verify the activation code. But if you decompile it, you can just change the verify activation method to always succeed.
>>
>>54366572

Maybe one day. Summer is coming up so I'll have some free time.
>>
>try to do custom drawing on control so I can get get background image on listbox
>most convoluted drawing system of all time

Now I remember why I don't fuck with custom user controls.
>>
; rax contains 0x1
; r12 contains 0xA
div r12
; rax now contains 0x1999999999999999
; rdx now contains 0x7

Can anyone explain why? Self-teaching Assembly
>>
You have a stack of n sheets of paper, each with a date and time written on them. You need to sort them by date. Your memory isn't perfect, and whether you divide things up into piles, or mark it with sticky notes, you can only remember the position and date of k different sheets of paper. Your ability to eternal positions also isn't perfect, so inserting a piece of paper or pile of papers into another pile of papers at an arbitrary position i is impossible, although if the papers are sorted or marked in order, you can take log n time to find position i.

What is the ideal sorting method for this situation, and what is its time complexity?
>>
>tfw you have an idea that sounds brilliant but the algorithm is so simple that its almost certainly already been done
>>
File: DOGEEEE.jpg (351 KB, 1200x900) Image search: [Google]
DOGEEEE.jpg
351 KB, 1200x900
https://www.youtube.com/watch?v=FdRE8q5TBJ0


HOW YOU DO THIS
>>
>>54367084
Typed "x86 div" into google and found a page that says this:
>Unsigned divide EDX:EAX by r/m32, with result stored in EAX = Quotient, EDX = Remainder.
So probably there is some weird shit in rdx before the instruction.
>>
>>54367084
What does rdx contain before you go into that instruction? It plays a part in it too.
rdx:rax / arg, where : is concatenation and the result stored in rax and the remainder in rdx.
>>
>>54367160
you can do this stuff with pretty much any 2D graphics library.
>>
>>54367115
post it
>>
>>54367171
>>54367187
I completely forgot to zero out rdx
That explains a lot
>>
>>54367160
>the pen's entire point is to set variables to numeric values
wow, what a fucking gimmick.
>>
>>54367084
>>54367171
>>54367218
>>54367187
https://www.cs.uaf.edu/2006/fall/cs301/support/x86_64/

mov rax,0x1
mov r12,0xA
mov rdx,0
div r12


Now that wasn't so hard.

You're on x86_64 right?
>>
>>54367201
How are those figures called? (The line ones)
>>
>>54367265
Ye, I making a FizzBuzz, and goddamn was it a pain
pastebin.com/XyXvpVCD
>>
>>54367205
It's an algorithm for generating recipes by cross -referencing a database full of ingredients with whatever shit you have in your fridge and pantry.

The database stores ingredient pairs prioritized by compatibility, ingredient information, and generic recipe information (for example, a burger has buns, ground meat or meat substitutes, 0-4 vegetables, 0-2 cured meats, 0-1 eggs, 0-2 sauces, 0-2 cheeses)
>>
>>54367320
no idea. Reminds me of the mystify screensaver windows used to have https://www.youtube.com/watch?v=p-howMhFecQ
>>
>>54367265
>mov rdx,0
You can also use the 'cqo' (convert quadword to octoword) to sign extend rax into rdx.
global _start
_start:
mov r12, 3
mov rax, 10
cqo
div r12

mov rdi, rax
mov rax, 60
syscall
>>
What are the benefits to learning assembly?
>>
>>54367581
you can do embedded systems shit and that's about it
>>
>>54367581
It helps you understand how higher level programs are implemented.
>>
>>54367617
>programs
programming languages*
>>
File: 1460005029794.jpg (356 KB, 1100x825) Image search: [Google]
1460005029794.jpg
356 KB, 1100x825
What the hell is overloads in Visual Studio? I been crawling all over Stack Overflow and can't figure it out.
>>
>>54367201

is their an easy "plug n play" one with a "drawLine" function
>>
>>54367718
yes, pretty much all of them. 2D canvas in html 5 for one.
>>
>>54367727
There's also cairo, skia, GDI, Direct2D and a shitzillion others.
>>
>>54367718
You wouldn't even consider it a plug n play library just because it has a draw line function, that's pretty essential to all graphics libs, idk about really lowe level stuf though like opengl (probably not) or whatever the actual library is called
>>
File: bgpic2.png (174 KB, 799x433) Image search: [Google]
bgpic2.png
174 KB, 799x433
Work smart not hard, right?

And by that I mean give up on trying to make a custom user control and instead use a ListView in "List" mode so it works like a ListBox.

Fuck you Microsoft.
>>
>>54363185
static int Product(int a, int b) {
if (a == 0 || b == 0) return 0;
else return a + (Product(a,b-1));
}
>>
>>54367828
even opengl can practically do it.

it's more like
gl.begin();
gl.drawVertex(Vector3(0.0,0.0,0.0));
gl.drawVertex(Vector3(0.0,1.0,0.0));
gl.end();
gl.flush();

or some shit but it's not far off.
>>
>>54367885
you've been at it for what, an hour? work hard
>>
>>54367885
>jungle girl
>can't even properly see her ass
Utter shit m80
>>
>>54367907

The custom drawing is an enormous pain in the dick. All the suggestions I've read online are hacky to the max.

>an hour?

Eh, probably 45 minutes.


>>54367909

That's my nigfu you're talking about, m9. Show some respect.
>>
>>54367901
opengl fixed pipeline immediate mode is deprecated
>>
>>54367959
true, but not dead yet.
>>
https://shodan.me/books/Algorithms/
Which of these would you rec for someone mostly new to algorithms
I'd prefer to be using C
>>
>>54367931
>All the suggestions I've read online are hacky to the max.
That's what you get for sticking with winforms. WinForms sucks shit for any kind of UI that's not a gray enterprise data entry form.

Learn some WPF.
>>
I am retarded. My method ends before finishing.
public static void searchList(ArrayList<Integer> list){
Scanner in = new Scanner(System.in);

System.out.print("What number would you like to search for?: ");
int num = in.nextInt();

for(int i = 0; i < list.size()-1; i++){
if (list.get(i) == num){
System.out.println(num + " was found in the list.");
}
if (i == (list.size() - 1)){
System.out.println(num + " was not found in the list.");
}
}
}
>>
>>54368024
>Learn some WPF.

WPF is scary! In any case, the listview works perfectly.

Maybe I'll do my music player rewrite in WPF so I can actually learn it.
>>
>>54368072
>WPF is scary!
It's not that bad. It's not a ton of extra shit you can ignore. Otherwise it's just like WinForms. The main difference is xaml. Which is basically nothing more that an intermediate step between code genning your WYSIWYG to C# as WinForms does. It's a lot fucking nicer that that dirty designer.cs bullshit WinForms does.
>>
>>54368115
>It's a lot fucking nicer that that dirty designer.cs bullshit WinForms does.

Don't shit talk muh partial classes, m8.
>>
>>54368138
partial classes are one of the ugliest parts of C#. It wouldn't surprise me at all if they existed only for the sake of WinForms. I've never seen a good reason to use them otherwise.
>>
Why don't people use cython again? It's just python cross-compiled to C code
>>
>>54368170
Why not just write in C?
Thread replies: 255
Thread images: 29

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

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.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.