[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: 24
File: DPT.png (389 KB, 934x1000) Image search: [Google]
DPT.png
389 KB, 934x1000
Old thread: >>54569278

What are you working on /g/?
>>
>>54576477
averaging 2 ints in c
>>
Rewriting TempleOS in Haskell
>>
>>54576487
Int avg(x, y: Int) {
return x + y / 2;
}

done
>>
rewriting the linux kernel in javascript
>>
>>54576500
>in C
nice reading comprehension
>>
>>54576500
OVERFLOW
>>
>>54576500
>C
That's not C.

Also, by order of operations, it's not even the average.
>>
>>54576500
>x + y / 2
y/2 + x is not the average.
>>
Writing an OS in Lua.
>>
>>54576508
>doesn't know what language it is
>it's not even the average
m8...
>>
>>54576520
>y/2 + x is not the average
ok; I literally didn't say it was
>>
>>54576536
>>54576546
>hue hue i made my own language that does left to right evaluation
>>>/v/
>>
>>54576555
>got told and now it's time for damage control
you from /v/ lad?
>>
>>54576137
>>54576166
Thanks.
Any other cool projects that require some real world interaction? I'm looking around me but the only thing I can think about automating is vacuum cleaning. But I'm assuming programming a roomba is too far away from a single person's capabilities.

Am I mistaken?
>>
>>54576507
wrong! Int can't overflow; git gud!
>>
>>54576565
You can shitpost all you want, but it's not C.
>>
>>54576573
>lel I'm a gaymur
please leave
>>
File: monitor.jpg (58 KB, 450x443) Image search: [Google]
monitor.jpg
58 KB, 450x443
I'm continuing my quixotic task of learning Swift so I can write an iOS app for personal use.

I hate everything about this language, Xcode, and OOP in general. I can't even imagine what actual big projects look like when written in this shit.
>>
>>54576502
You monster.
>>
>>54576581
>being this butthurt
>>>/b/
>>
>>54576634
>animooooooooooo
REKT
E
K
T
>>
>>54576641
>>>/b/
>>
>>54576568
What can you already do? Can you create a irc bot that counts how many words have been said in a channel every hour?
>>
>>54576644
>memuuuuuuuuu
>>
>>54576656
>>>/b/
>>
>>54576661
t. autism
>>
>>54576697
>>>/b/
>>
Daily reminder that testing if for code monkeys.
Definition U : nat -> Type :=
(fix f (n : nat) {struct n} :=
match n with
| 0 => nat
| S n => nat -> f n
end).

Definition sum : forall n : nat, U n :=
(fix f (accu : nat) (n : nat) {struct n} :=
match n return U n with
| 0 => accu
| S n => fun x => f (accu + x) n
end) 0.

Eval compute in sum 5 1 2 3 4 5.


Check (eq_refl : sum 5 1 2 3 4 5 = 15).
Check (eq_refl : sum 6 1 2 3 4 5 6 = 21).
Check (eq_refl : sum 7 1 2 3 4 5 6 7 = 28).

Dependent types are the future.
>>
>>54576711
>testing if
ok, monkey
>>
What the fuck am I doing wrong here. I'm switching between textures using glActiveTexture and glGet is confirming the textures are being switched but for some reason I can only seem to render the last texture set. This exact code worked fine in OpenGL 3.1 but it doesn't work at all in 3.3+.

I'm using libpng.
http://pastebin.com/af4pDpEg
>>
File: coq.jpg (74 KB, 1045x636) Image search: [Google]
coq.jpg
74 KB, 1045x636
>>54576711
>>
>>54576752
How is it possible? There is no IO in coq.
>>
>>54576626
Noob
Swift isn't OOP
It has features such as classes and interfaces

It's actually quite nice to write in swift, did a sample 4chan app

Better than Java/objective-c
>>
how would i get the first byte from a short (without mask)?
i have tried something like this and it dont work

short s = 12345;
char b0 = *(((char*)&s)[0]);


pls help
>>
>>54576785
>first byte
The lower byte? Or the byte at lower address?
>>
>>54576797
if the short is mapped to bytes 1000 and 1001, i want the one in 1000
>>
>>54576772
I have no fucking idea. I found it trending one night. Code is still there.
>>
>>54576785
Just do
s & (1 << CHAR_BIT) - 1
>>
>>54576815
#include <assert.h>

#include <stdio.h>

typedef unsigned char byte;

int main (void) {
short i;
byte cl;
byte cu;
assert (sizeof (short) == 2 * sizeof (byte));
i = 12345;
cl = ((byte *) &i)[0];
cu = ((byte *) &i)[1];
printf ("0x%4X\r\n", i);
printf ("0x%2X\r\n", cl);
printf ("0x%2X\r\n", cu);
return 0;
}

But beware the bytes order is not portable.
>>
>>54576649
No. But it'd help to have some sort of 'project hierarchy' to see what would I be able to do with certain skill level.

e.g. By the time I'm an old fart I'd like to program a strapped AED so I can fool death if* I live alone. The same with giving the dogs their meals and so on.
>>
>>54576785
char b0 = *(char*)&s;
>>
>>54576477
hey guys how to do this without using cins in C++

Sample
Input 1-5
4
Op
is
not a
faggot
>>
>>54576785
The easiest is of course a mask, but you can always do this

union {
short value;
char bytes[2];
} s;

s.value = 12345;
char b0 = s.bytes[0];


or this

short s = 12345;
char b0 = *((char*) &s);
>>
daily reminder that power to abstract corrupts just as much as the power to use state
>>
>>54576785
short s = 12345;
char b0 = ((char*)&s)[0];

Turnon ur brain pls
>>
>>54576953
>easiest is of course a mask
how? did you think this through?
>>
>>54576835
not portable
>>
>>54576987
It is in fact the MOST portable, assuming you're trying to get the least significant byte.
>>
>>54576977
>how? did you think this through?
Are you stupid or something?

short s = 12345;
char b0 = (0xff00 & s) >> 8;


OH WOW THAT WAS HARD
>>
>>54576993
>assuming
stop assuming
>get the least significant byte
anon wants the first byte in memory, you fucking dolt
>>
>>54577001
Anon didn't ask for that.
>>
>>54577001
Or even >>54576835 if you care about portability.
>>
>>54577001
>stupid
you certainly are
>>
>>54577014
That's why I gave him two alternative options, you fucking imbecile.

>>54577023
What's the point in samefagging?
>>
>>54577016
see >>54576987
>>
>>54577032
You're wrong. It is the most portable.
>>
>>54577031
>alternative
you don't even know the meaning of that word you shithead
>>
Hi /g/entlemen I know python really well, I use it for numerical mathematics. But I want to learn a lower level language. I specifically want to be able to create really lightweight games. Do I go for C or C++ ?
>>
>>54577053
C.
>>
>>54577044
What the fuck are you on about?
>>
>>54577053
>I specifically want to be able to create really lightweight games
example?
>>
>>54577041
>wrong
yes, you are
>>
>>54577053
C++
>>
>>54577061
How is it unportable?
>>
>>54577058
you are apparently retarded; let me spell it out for you: when 2 methods give different results, they are not "alternatives"
>>
>>54577070
it doesn't give the required result on all platforms
>>
>>54577053
where are these games going to be played, on a network switch?

anything with enough juice to deal with graphics is going to have enough juice to run Python.
>>
>>54576487
int average(int x, int y)
{
return (x & y) + ((x ^ y) >> 1);
}
>>
>>54577078
It does.
>>
>>54577053
Unity
>>
>>54577103
you continue to be wrong
>>
>>54577072
Are you trolling or what?
>>
>>54576477
>tfw you get in the office on Monday and someone replied with stupidity to one of your posts from Friday in the 404'd thread
>tfw can't refute the objectively wrong thing they said
>>
>>54577098
I actually tested this.

Can someone explain how a bunch of ands, xors and shifts result to an average? I mean, is there a formal mathematical proof?
>>
>>54577110
Tell me which platform it is going to give the wrong result on.
>>
>>54577112
are you retarded or what?
>>
>>54577112
Where is it written in C89 specs that the union use the same memory for each kind of value? Where id documented the memory model of union in C89 specs? I'm not sure that you're code is portable.
>>
>>54577098
Does this work with negative values?
>>
>>54576500
That returns x+(y/2) unless this language can't do order of operations, but that would mean it's behind c.
>>
>>54577060
Just simple 2D games with minimal overhead.
>>54577093
Just as a stupid challenge I guess. I like to optimize for the heck of it. I know it's retarded to do so, but it's fun to see how much you can squeeze out of a program.
>>54577105
Unity isn't lightweight.
>>
>>54577125
Trolling it is then.

>>54577127
>C89
>>
>>54577122
the ones you didn't test on, because you refuse to use logic instead of your retarded trial-and-error
>>
>>54577147
Except, I don't have to use logic because I can read the fucking standard.
>>
>>54577146
>b-but it works on muh computar
fuck off
>>
>>54577147
>says it is unportable
>fails to point out why it is unportable
>>
>>54577163
>b-but it works on all computers that implement C properly
ftfy
>>
>>54577153
>I can read
doubt that; otherwise you'd know C doesn't specify a byte order
>>
how do i access the copy paste buffer from terminal?

i want to do like
cat FILE | copypastebuffernigger
>>
>>54577166
I did, you're just to stupid to understand
>>
>>54577142
C is fine then
>>
File: indians.png (5 KB, 235x117) Image search: [Google]
indians.png
5 KB, 235x117
Can someone explain what alpha conversion is in basic terms?

It seems really simple, but I may be missing something.
>>
>>54577175
>I don't know C
>>
i have to run 'ntfsfix' on my 2nd hdd every other day or so, is it time to get a new drive or is it just the ntfs fs that is trash?
>>
>>54577200
>i wear my pants on my head
>>
>>54577190
What are you actually trying to do?
>>
>>54577207
>must meme for damage control
>>
>>54577198
signing up for a gym membership
>>
>>54577190
To paste you do:
cat FILE | xclip


If you want to copy into the selection/middle mouse button then:
cat FILE | xclip -selection c


To paste:
xclip -o >> FILE


(The selection argument applies for pasting as well)
>>
>>54577116
>is there a formal mathematical proof?
Ofc
>>
>>54577098
no workee
>>
>>54577219
>To paste you do:
I meant to copy the file into the clipboard.
>>
>>54577219
Not the anon who asked but thank you.
>>
>>54577179
If you're too dense to understand it, OP didn't specify which byte to read. He just said "first byte" which could be the most-significant or least-significant, left-most or right-most etc.
>>
>>54577198
Rewriting the same code with different identifiers. If it doesn't introduce a collision and the expr doesn't contain free identifiers, the meaning doesn't change. It's a conversion and not a reduction because none of two Ī±-equivalent expressions is simpler than the other.
>>
>>54577267
I think I'm still missing something on what one anon said.

Basically, she said smugly
>How does it feel that you can't do alpha-conversion in SQL?

And it didn't feel like much of anything because I don't see how it applies or would make any DBA's life easier.

Any ideas?
>>
>>54577257
>didn't specify which byte to read
sure he did, you're just too retarded to follow a conversation
>said "first byte"
yes, first byte in memory, as clarified here >>54576815
>which could be the most-significant or least-significant
and that's why you can't use a mask portably, you fucking shit stain
>>
File: laughing-pirate.gif (4 MB, 400x376) Image search: [Google]
laughing-pirate.gif
4 MB, 400x376
>>54577290
>backpedalling this much
>>
File: Problem.png (65 KB, 1616x1398) Image search: [Google]
Problem.png
65 KB, 1616x1398
I'm having trouble assigning string values into string variables. I know, I sound retarded, but it just doesn't work.
>C++
>Eclipse
>MinGW

Here's the code:
#include <iostream>
#include <string>

using namespace std;

int main() {

cout << "Hello!" << endl;

int b = 12;
cout << b << endl;

string a;
a = "Yo!";
cout << a << endl;

return 0;
}


When I run the program, I get the following exit code in the console (and no output):
<terminated> (exit value: -1 073 741 511) IfStatement.exe [C/C++ Application] C:\path\to\IfStatement.exe (date, time)

When I remove
a = "Yo!";
cout << a << endl;

the program runs just fine and outputs to console with exit code 0.

What is going on?
>>
Made my first game guys. I call it "Football Fan" it's like Football Manager games, but you can't affect the result in any way. It's a footbal fan's life simulator game.
from random import randint
x=randint (0,6)
y=randint (0,6)
import random
randint (0,6)
players = ["Spurdo", "Sparde", "Sborde", "Barda", "Sbodro", "Spudro", "Bukkake", "Moot"]
if x>y:
print ("your team won", x,":",y," so you went to celebrate, got drunk and beaten up by police\nPlayers scored:")
count = 1
while count <= x:
print (random.choice(players))
count = count +1
elif x<y:
print ("your team lost", x,":",y," and your wife left you\nPlayers scored:")
if x==0:
print ("no one")
count = 1
while count <= x:
print (random.choice(players))
count = count +1
else:
print ("the match ended with a tie", x,":",y," you got beaten up by other teams fans\nPlayers scored:")
if x==0:
print ("no one")
count = 1
while count <= x:
print (random.choice(players))
count = count +1
>>
>>54577220
Where?
>>
>>54577343
steam greenlight when?
>>
>>54577343
This is brilliant, is it available for download?
>>
I wish /g/ would post their githubs so that I can fork you all.
>>
>>54577364
Please no pirating. If you already downloaded the game to try it, at least send me some 4chan Gold to compensate me.
>>
>>54577367
Fork off
>>
>>54577338
>shit, he's right, better play it cool
I know
>>
>>54577342
Because you're assigning a string (char) literal that's a constant, instead do this:

a = std::string("Yo!");
>>
File: heheheh.gif (2 MB, 400x206) Image search: [Google]
heheheh.gif
2 MB, 400x206
>>54577401
>i'm greentexting so i can play cool on 4chan
>>
File: 2016-05-16-134752.jpg (274 KB, 1280x720) Image search: [Google]
2016-05-16-134752.jpg
274 KB, 1280x720
>>54576477
>What are you working on /g/?
I am building basic circuits with atmega328p. Try to learn that shit in real C now. Fuck arduino.

#include <avr/io.h>
#include <util/delay.h>

int main(void)
{

DDRB |= (1<<DDB0);
DDRB &= ~(1<<DDB1);

while(1) {
if(!(PINB & (1<<PB1))) {
PORTB |= (1<<PORTB0);
} else {
PORTB &= ~(1<<PORTB0);
}

}
return 1;
}
>>
>trying to argue with the big dick playa
>on averaging ints
>on EOF
>on aliasing
>on byte order
>get BTFO every time
they never learn!
>>
Rate my program /g/.

http://pastebin.com/raw/EFA84C83
>>
>>54577367
I recently removed all of my repositories because it was all spaghetti.

And then I realized I can only write spaghetti.

Public github never.
>>
>>54577367
Why do you want my github?
>>
>>54577413
Not him but looks like you got rekt pretty bad anon.
>>
File: 4chan4.jpg (228 KB, 1152x2048) Image search: [Google]
4chan4.jpg
228 KB, 1152x2048
>>54577443
>not him but...
>>
int average(int a, int b)
{
double avg;

avg = a;
avg += b;
avg /= 2.0;

return (int) avg;
}
>>
>>54577423
Inconsistent indentation => it's shit.
>>
>>54577422
what was the argument even about, you already had the short so the byte order isn't a concern at that point if you loaded the short correctly
>>
>>54576785
>how would i get the first byte
>>54577257
>OP didn't specify which byte to read
wew laddie!
>>
>>54577472
not good
>>
>>54577485
>first
Yfw first can mean any of the following:
"lowest"
"highest"
"least significant"
"most significant"
"leftmost"
"rightmost"
>>
>>54577485
you already had the short so the byte order isn't a concern at that point if you loaded the short correctly
>>
>>54577497
Why? At least it doesn't overflow.
>>
>>54577485
>>54577500
That anon answered a long time ago to that question.
>>54576815
>>
>>54577516
you either have the short 10001001 or 10010001

which one is it, do you want the least significant byte or the most significant?
>>
>>54577524
the first, retard!
>>
File: Nope, still there.png (66 KB, 1621x1380) Image search: [Google]
Nope, still there.png
66 KB, 1621x1380
>>54577402
Thanks for the suggestion, but that didn't work either. See pic
>>
>>54577516
>mapped to 1001 and 1000
>i want 1001
It still doesn't specify byte order. The short can still be either 10001001 or 10011000
>>
>>54577524
Fucking read that post >>54576815
>>
>>54577500
first means the one with the lowest address; try reading the standard sometimes
>>
>>54577537
kill yourself retard
>>
java is the programming language i know and like the best, should i stick with it? where is java being used in daily life?
>>
>>54577534
you're still a retard
>>
>>54577534
Yes, the byte order is irrelevant. Only the lower address byte is required. Are you stupid?
>>
>>54577538
>>54577537
See >>54577534

He didn't specify the order.

"Mapped to 1001 and 1000" doesn't say anything anything about order.
>>
>>54577532
delete "using namespace std;"
>>
uint8_t b = (uint8_t) s;
>>
>>54577511
based on what assumptions did you get to that conclusion?
>>
>>54577549
Lower address can give you either 1001 or 1000 depending on which one of them comes first in memory, you idiot.
>>
>>54577554
>He didn't specify the order.
he doesn't have to
>>
>>54577568
The fact that truncating != overflowing

Arithmetic overflow = unspecified behaviour
Truncation = well-defined behaviour
>>
>>54577570
if you have a short, you have a value, you fucking retard, the byte order doesn't matter

what you should be asking is how to load the short properly so that its value is consistent across different platforms
>>
File: rekt.png (66 KB, 1621x1379) Image search: [Google]
rekt.png
66 KB, 1621x1379
>>54577564
That just wrecks the program.
>>
>>54577545
You should probably stay with it. It's used primarily as an enterprise application language, in lots of industries.

If you're wanting to learn another language, consider C#. It's very similar to Java and frankly much nicer to write in.

Whatever you do, you should just be very familiar with a top 5 language + SQL. Do that, and you're easily employed.
>>
>>54577567
doesn't give the first byte
>>
>>54577570
No it's 1000. You're retard. Address 1000 is lower than address 1001. You're retard anon.
>>
>>54577577
See >>54577570

>>54577586
>if you have a short, you have a value, you fucking retard, the byte order doesn't matter
He said he wants the FIRST BYTE, not the value. Can you even read?
>>
>>54577593
shitty bait. kill yourself.
>>
>>54577606
It doesn't, it gives the last byte.
>>
>>54577605
the first byte is the LSB of the short's value, the byte order doesn't matter, fucking cancerous retard
>>
>>54577581
that's a non-sequitur; let me rephrase: how do you guarantee you don't have an overflow when you add the 2 doubles?
>Arithmetic overflow = unspecified behaviour
wrong, it's undefined
>>
>>54577589
i'm not that into business application stuff, can i use my java skills for web and app development?
>>
>>54577621
>the first byte is the LSB
wrong
>>
>>54577630
Java is the brains of Android-apps (the GUI is made using XML), so if you want to make apps for Android, Java is golden.
>>
>>54577636
fuck off and die you're not funny
>>
>>54577587
uhh... no idea then. i'm not really good with c++, i thought you might not need to declare that namespace when using it directly with the string object
>>
>>54577645
>you're not funny
at least I'm not wrong
>>
>>54577630
>can i use my java skills for web and app development?
Yes
>>
>>54577627
>that's a non-sequitur; let me rephrase: how do you guarantee you don't have an overflow when you add the 2 doubles?
Because it's double precision.

>>54577621
>the first byte is the LSB of the short's value
That's wrong. The first byte is the first in memory. It's only the LSB if the system is a little endian system. Therefore byte order matters.
>>
choke me, GNU/daddy~
>>
>>54577587
put std:: in front of string, cout, endl or put the using namespace std back again
>>
>>54577342
>>54577532
>>54577587
Just use Java. You're not man enough to use C++
>>
>>54577621
>the first byte is the LSB
https://en.wikipedia.org/wiki/Endianness#Big-endian
>>
>>54577662
byte order doesn't matter at the point where you're using ints and shorts, fucking clueless sperg, you don't know what you're talking about
>>
>>54577643
>>54577661
thanks, i'll have to use java/jps's for backend/frontend development in uni, so i'll probably stick with that for now and will try app development at a later point
>>
>>54577670
Gotta start somewhere, you were here once too, you know.
>>
>>54577662
>it's double precision
that doesn't imply adding 2 doubles doesn't overflow
>>
if register variables do not have an address, do they even exist?
>>
>>54577472
int average ( const int a, const int b )
{
return a / 2 + b / 2 + a % 2 + b % 2;
}

There you go.
>>
>>54577678
Are you seriously retarded?

short s = 12345;
char b0 = (char) s; // least significant byte
char b1 = *((char*) &s); // first byte in memory

printf("%d\n", b0 == b1); // prints 1 on a little endian system and 0 on a big endian system
>>
How hard would it be to modify the Sumatra pdf viewer to make it borderless and remove the menu bar?
>>
>>54577698
wrong
>>
>>54577703
kill yourself retard, there's no reasonable situation where you would be doing what you're doing, except for checking endianness, fucking retard
>>
>>54577670
You should use
std:cout
and
std:string
if you're not going to declare the namespace
>>
>>54577669
Okay, so I'm back where I started. I can't wrap my head around what's wrong. The syntax is correct. Everything should be fine, it just doesn't work!
>>
>>54577692
No, it doesn't, but it implies that when you store two ints in a data type that is guaranteed to be able to represent at least twice the range of an int, it will not.
>>
>>54577705
Do you have the source code?
>>
>>54577698
the average of 3 and 5 is 5?
>>
>>54577705
Not very.
>>
>>54577712
>i write non-portable shit
>>
>>54577713
Yea I had, but someone told me to remove it, so I did just to show them that it didn't help. I have declared the namespace again.
>>
>>54577714
http://en.cppreference.com/w/cpp/string/basic_string

use the constructor
>>
File: damage-control.jpg (109 KB, 650x650) Image search: [Google]
damage-control.jpg
109 KB, 650x650
ITT
>>
>>54577737
FUCKING RETARD, when you the short in the first place, from a char array, THAT'S when you care about the byte order, and then the short has a consistent value on all platforms, there's no reason why you would take the first byte in memory of a short, FUCKING RETARD
>>
>>54576875
Somebody throw me a bone, pelase.
>>
>>54577726
Yes it's open source.

>>54577733
Maybe I'll give it a try next weekend then. I like muh minimalism.
>>
>>54577769
Except that's what anon fucking wanted, you idiot. >>54576815

He wants the first byte in memory, not the least significant byte.
>>
>>54577786
IT'S BAIT YOU RETARDED FUCKING SPERG
>>
>>54577789
>i can't solve a trivial programming task therefore it's bait
>>
>>54577719
>guaranteed
no such guarantee in the standard; that's the assumption I was asking about
>>
>>54577798
others already posted the solution, what's the problem, what are you even arguing about
>>
File: Capture.png (30 KB, 1575x940) Image search: [Google]
Capture.png
30 KB, 1575x940
>>54577746
I don't know what you're doing but it's working here
>>
>>54577769
>I'm imagining this convoluted problem
>OP asked about accessing the first char in an array of chars
m8...
>>
>>54577809
No one agrees on the solution.

>>54577549
>Only the lower address byte is required
>>54577621
>the first byte is the LSB of the short's value

Which one is it you fucking spergs
>>
>>54577823
follow the big dick playa and you can't go wrong
>>
>>54577823
it depends on what the fucktard is asking about, it's a shitty question. he wanted to do it without a mask, a mask is what you'd use to get the LSB or MSB, so his question is fucking ambiguous, or in fact bait since it's the "big dick playa" that's behind the post, see >>54577422
>>
File: 1462365880478.jpg (227 KB, 640x1136) Image search: [Google]
1462365880478.jpg
227 KB, 640x1136
Alright guys I'm a senior in HS and in a pre ap computer science course and for my final I have to make a space invaders type of mini game. We're using Java by the way. Are there any easy ways to do this since we never have made a game before? I would really appreciate some help.
>>
>>54577840
>>54577844

What does the big dick playa do then?
>>
>>54577844
>"big dick playa" that's behind the post
actually, I'm not the one that posted the question; I underestimated /g/ and didn't expect something this trivial to turn into another "average"; I should step up my meme-game and find other simple shit to bait you guys
>>
>>54577813
I typed in the EXACT same program in Eclipse, and it wouldn't run. Same exit code.

I just tried the same program in Visual Studio, and it worked for me as well. There's something fundamentally wrong in my installation of Eclipse or MinGW, probably.

Thanks for the input guys.
>>
If I move to C++ from C, do I still have to deal witg a lot of C preprocessor blood magic fuckery?
>>
>>54577849
libgdx is shitty but i guess it's the best for your situation. there's even tutorials and demo code specifically for space invaders so you could check that out
>>
>>54577933
Yes and no.

The preprocessor is still there, but it's generally considered bad form in modern C++ to rely on it.
>>
>>54577933
>still have to deal
what's forcing you to use the preprocessor?
>>
>>54577939
Well, in Linux C, there's a lot of it and so much of the code is putting #if blah blah for portability
>>
>>54577933
only for stuff surrounding OS/Compiler/X64 portability
which is quite a lot, actually
>>
>>54577923
Well it could also be different compilers, VS uses Clang now right? So check those. I don't know c++ though sorry
>>
>>54577933
No
Modern C++ recommends against prepressor Magic

You have templates
>>
>>54577955
>much of the code is putting #if blah blah for portability
see, java is a lot more portable than C in this regard, you don't need the preprocessor shit. unrelated but we had this "discussion" yesterday where retards were saying C is far more portable than java
>>
>>54577968
>stuff surrounding OS/Compiler/X64 portability
not actually required tho, it's just that people are lazy and don't know any better
>>
>>54577987
>java is a lot more portable than C
false
>C is far more portable than java
true, it's the most portable language
>>
>>54578017
>hurr my definition of the word portable is the one true definition sperg meme
>>
>>54578035
>hurr my definition of the word portable is the one from microsoft
>>
File: what the fuck comrade.jpg (9 KB, 228x210) Image search: [Google]
what the fuck comrade.jpg
9 KB, 228x210
>>54578004
>not actually required tho
it is if you ever want to release something
>>
>>54578017
>false
false
>true, it's the most portable language
false
>>
>>54578052
you don't seem to know what you're talking about and before we continue I have to warn you that I'm the big dick playa
>>
>>54578065
>>false
>false
false
>>
I hate vim and emacs, should I use Atom or Sublime?
>>
>c portable: works on different os/arch combinations
>java portable: works on "any certified JVM"
>microsoft portableā„¢ (since 2002 - .net): works on more than 1 windows version!!!
>web portable: works on these 2 browser versions
>>
>>54578113
yes
>>
>>54578113
vim
>>
>>54578212
t. retard
>>
>>54578177
>web portable: works on these 2 browser versions
and you have javascript enabled, otherwise you'll get a blank screen
>>
>>54577746
i told you to remove it, because you might come to the point where you might want to use a function from another namespace with the same name like from the std namespace.
so if you declare the std namespace globally it will always be prioritized
you can keep on using
using namespace std;
for laziness sake, but you might regret it sooner or later
>>
Why is everyone so hostile lately?

I mean, there's always a bit of rage, but usually the hostility was paired with reasonable arguments or proof of someone being a retard.

>kill yourself
vs.
>kill yourself. here's an example of why you're fucking wrong, and here's the relevant section of the standard backing up my claim
>>
>>54578235
Thanks for the tip, I'm not so far into it that I really know what a namespace is (I'm still pretty new to this stuff). I'll read up on it sooner or later, thanks.
>>
>>54578219
wow, rude
>>
>>54578303
>here's an example
it gets tiring after a while considering the supply of retards is infinite; no point in explaining to mouthbreathers incapable of any coherent thought
>>
>>54578335
accurate tho
>>
>>54578303
/g/ goes on its period for months at a time
>>
>>54578344
Then why respond at all?
>>
>>54578235
you're welcome. you should just use std:: in front of strings, cout and so on. it's a little bit more to type but it's going to be helpful

good luck with it
>>
>>54578367
meant for >>54578320
>>
>>54578365
why not?
>>
File: melonbread.webm (2 MB, 960x540) Image search: [Google]
melonbread.webm
2 MB, 960x540
Ask your favorite programming literate anything (IAMA).

>>54576487
>averaging 2 ints in c
int average (const int x, const int y) 
{
if ((x > 0) == (y < 0))
return (x + y) / 2;
const int xh = x / 2;
const int yh = y / 2;
const int xhr = x % 2;
const int yhr = y % 2;
return xh + yh + (xhr & yhr);
}


>>54576626
Swift is actually a decent programming language.

>>54576785
union { char c[2]; short s; } u = {.s = 12345};
printf("%c\n", u.c[
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
0
#else
1
#endif
]);


>>54577053
>I know python really well, I use it for numerical mathematics

"The easiest machine applications are the technical/scientific computations. " -- Edsger W. Dijkstra

>>54578303
http://www.catb.org/esr/faqs/smart-questions.html#keepcool
>>
>>54578353
nah
>>
>>54578424
yah
>>
>>54578412
Can I try and guess who you are? What if I say your nickname (or one that you used before)? Will you acknowledge it?
>>
>>54578412
doesn't work on big endian
>>
>>54578481
Sure, go for it.
>>
>>54578078
>>>false
>>false
>false
false
>>
>>54578492
numa
>>
>>54578303
usually the "kill yourself" will only come after an explanation has already been posted but the person is being fucking retarded
>>
>>54578492
tetsumi, code artisan and undefeated master debater
>>
File: zBb23so.jpg (172 KB, 800x1195) Image search: [Google]
zBb23so.jpg
172 KB, 800x1195
>>54578481
No, it's unimportant. We are Anonymous. We are Legion. We do not forgive. We do not forget. Expect us.
Thread replies: 255
Thread images: 24

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.