[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: 30
File: it's a trap.png (873 KB, 1275x677) Image search: [Google]
it's a trap.png
873 KB, 1275x677
Previous Thread - >>55002296
>>
First for superior Java
>>
>>55007944
Cog gnobblin.
>>
this is decent for HKT-like until it gets added
https://github.com/gmpl/FsControl
https://github.com/gmpl/FSharpPlus
>>
>>55007964
not good enough
>>
>>55007969
what would you want to achieve exactly not doable there
>>
Node *add(int data, Node *head)
{
Node *new_node = nalloc(data);
new_node->next = head;
return new_node;
}

int main(void){
Node *new_node = nalloc(1);
int i = 2;
for(i; i<11; i++){
new_node = add(i, new_node);
}
print_linked_list(new_node);
return 0;
}


Why does this give a warning:statement has no effect warning and it points to my for loop
>>
>>55008008
are you storing this in a byte array?
>>
>>55008017
for (;i < 11; ++i)

i;
has no effect
just do ;
>>
>>55008031
Aaa thanks, I see
>>
>>55008008
make your own server that communicates with the API server and your client (which is installed in people's machines)
>>
>>55007901
>I feel like a pajeet right now, but how do servers actually present websites and interact with databases?
>The basic idea is just to have a program waiting for a request to arrive on port 80 and get a thread from a threadpool to handle said request. Any interactions with the database are just simple queries to the database (which is running on a normal rdbms - completely separate from the server program itself) through whatever libraries are available for that combination of programming language + rdbms.
>Is this just it? Is the word server actually used in two different ways (server - the box running your code + rdbms + whatever else) and the code that's actually "serving" the requests? Why are there popular "serverside" languages? What gains would be gained from using PHP over Ocaml, for instance? What does an apache server have that makes it so popular? And how would I get an host for my server + database? I tried looking at microsoft azure, but it's all so complicated. Where can I find answers to these questions?

Repost
>>
Oh shit wat do
>apply for paid intership at bank
>it involves mostly of programming in C#, asp.net and mvc, along with databases
I dont know what to study so I can prepare, Ive had an ASP.NET class but not sure if that will be enough to not look dumb once I get there and get assignments.
Databases shouldnt be a problem, but I fear Im lacking some basic programming skillz
>>
>>55008088
>What does an apache server have that makes it so popular?
Apache is popular because you install it, change 5 lines in the config file and are good to go.
Most people who just want to host a few html pages cannot be bothered to work out how to set things up properly, so they don't, they use the easy tools.

>Why are there popular "serverside" languages?
Because they are known to work better in server environments rather than single-user environments, without the programmer having to fiddle with thread safety and such all the goddamn time.
Also because they have more safeguards in place to make it more difficult for memory leaks etc. to happen, because a server is expected to run for long amounts of time without restarting.

If you leak memory 100MB of memory per hour in your C program that normally only runs for a few minutes at a time, it's not going to do much damage
If you leak memory 100MB of memory per hour in a server program that runs 24/7, it's going to grind things to a halt consistently until the problem is fixed.
>>
>>55008088
you can learn about how HTTP Servers work from google

but choosing a language has gains on
- the advantages the language has with writing/reading code
- performance
- tooling it provides with regards to debugging and development
- ``mature" libraries for that ``ecosystem"
- features such as CSP, actor model concurrency, etc.
- (as a company) how much talent you can leverage, not everyone knows Haskell or Ocaml/F#

for example RubyOnRails has tons of shit attached to it which can make it very easy to startup something quick, but performance wouldn't be that great compared to Go (for example, Go has other disadvantages like less library support compared to RoR)

Then there are companies who already use JVM/.NET for their business for non-web related things and want to use the web. They would likely only pick JVM/.NET languages like Clojure/Scala/Java and C#/F# for their backend.

End of the day it depends on your circumstances and what fits your needs.
>>
>>55008130
sounds like basic web backend work (AKA CRUD)
try to get familiar with asp.net and youll be fine
>>
>>55008130
they will ask you database questions
they will ask you general c# stuff and probably some async questions
>>
>>55008226
>>55008217
Ah okay them, doesnt sound too bad.
I havent worked with MVC so I guess Ill go study that
>>
How do you beat analysis paralysis?
>>
File: 562.jpg (36 KB, 600x600) Image search: [Google]
562.jpg
36 KB, 600x600
>>55007919
>posting the degenerate homosexual anime image
>>
>>55008288
How's it homosexual exactly?
>>
>>55008283
Don't use OOP.
>>
Eclipse, IntelliJ, or Netbeans for Java?
>>
>>55008361
Generic Java, or for something specific like android?

Using anything but IntelliJ for Android is painful, don't even bother.

Otherwise, just go with whatever, they all have their perks and their downsides, neither is better than the rest.
>>
>>55008304
Well. I'm not really using OOP that much. I have some inheritance. But it's not really much and I don't constrain myself to OOP practices.

I just keep thinking of the end goal and the options are just too many and tough to analyse.
>>
>>55008168
So the TL;DR is convenience in both cases

>>55008214
I tried to google a bit before asking here, but everything is full of buzzwords and acronyms and whatever the fuck else. I just want to know if my understanding of how they work is correct.

What's a good host where I can use ocaml + mysql?
>>
File: OpenGL_logo.svg.png (16 KB, 280x130) Image search: [Google]
OpenGL_logo.svg.png
16 KB, 280x130
i have one week (7-8 days) to make a game in openGL with shaders, textures, perlin noise, etc,


can i do it?
>>
>>55008470
yeah if you stop browsing and get to it
>>
File: 1404095561279.webm (2 MB, 1354x578) Image search: [Google]
1404095561279.webm
2 MB, 1354x578
Got data to flow around the network logically and quickly
>>
>>55008470
anyone else could
you? probably not
>>
File: output.webm (2 MB, 1047x431) Image search: [Google]
output.webm
2 MB, 1047x431
>>55008499
as well as DDOSing
I'm learning a lot about graph theory from all this, it's quite fun
>>
>>55008516
>I'm learning a lot about graph theory from all this, it's quite fun
no you aren't
>>
>>55008536
I certainly know more about it now than I did before
It's not like I'm going to learn an entire branch of mathematics from making a game
>>
File: 1464632537832.png (152 KB, 1948x858) Image search: [Google]
1464632537832.png
152 KB, 1948x858
>>55008536
dont bully anon
/dpt/ is a Christian thread
>>
>>55008444
you can use linux virtual servers which allow you setup your own shit
>>
>F#
God, it's like Winfag .NET shills fused with functional memers.
Truly cancer.
>>
>>55008622
Why do people insist in create programming languages??

create useful libraries instead
>>
>>55008622
>functional programming is bad
Nice meme
>>
>>55008622
nothing is fused, it's functional by default and includes optional OO features and even has ocaml syntax strict mode
>>
>>55008553
> Fleable
> Leggable
I shouldn't be looking at these pictures at work, I'm giggling like a retard.
>>
>>55008641
>it's functional by default
Yeah, it's exactly as I said, retard.
Winfag .NET shills fused with functional memers and made F#
>>
>>55008603
But doesn't that still require me to have my own server? I don't have one.
>>
>>55008659
.NET is cross platform dumbass
Functional programming has loads of great features that senile fags like you don't understand
>>
>>55008668
I guess look into Azure, amazon aws, and digital ocean
>>
>>55008671
.NET is a Winfag invention.
Only Winfags actually care about .NET, no one else uses it but Winfags.
>>
>>55008730
What the fuck is a Winfag and why should I care?
.NET has a bunch of shit I like and it's portable and not slow as fuck.
>>
>>55008761
Point me to a Linux application that uses .NET
Protip: You can't, they all still rely on Windows specific stuff.
>>
>>55008792
.NET core was released this year (as an alpha), so I would be amazed if any application was ported
>>
>>55008792
https://www.google.co.uk/search?q=.NET+linux+application
>>
>>55008712
I already looked into azure, but it was all so confusing and seemed like overkill for what I wanted. I'll try looking at the others too, but I'd welcome any other suggestions. I just want something like "here's a server. do whatever the fuck you want"
>>
>>55008841
Then DigitalOcean is what you want. You just create a "droplet", select the hostname & system, and you get SSH root password mailed. Don't buy into AWS and other crap, those are over-priced technologies for hipsters from California.
>>
>>55008841
well I think digital ocean is easier in that regard
>>
File: 1461407752307.png (189 KB, 647x965) Image search: [Google]
1461407752307.png
189 KB, 647x965
>>55008838
You sure showed me.
>>
File: burns.gif (2 MB, 176x144) Image search: [Google]
burns.gif
2 MB, 176x144
>>55008761
>it's portable

wew
>>
>>55008864
nobody targeting .NET wants to make a linux application

>>55008879
it is faggot
>reddit.gif
nice try hilary
>>
>>55008893
Exactly, it's precisely as I said, only Winfags use .NET, nobody else cares about it.
>>
File: jk2autostrafeNA.webm (2 MB, 1920x1072) Image search: [Google]
jk2autostrafeNA.webm
2 MB, 1920x1072
Finished an autostrafer "bot" for Quake3 based games, based on the physics rules in the engine. This is really OP, since hitting the optimal angles for strafe jumping is very hard as a human. Pic related.
>>
>>55008902
Yeah dude, "only" 86% of all computer users
https://www.netmarketshare.com/operating-system-market-share.aspx?qprid=10&qpcustomd=0
>>
>>55008931
cool
>>
>>55008902
>only windows users
>only 87% of desktop users
>>
>>55008931
> Jedi Outcast
Awww shit nigga, that's cool stuff.
>>
>>55008948
>only 87% of a dying market, in a world where usage of every other computer device is going through the roof

I'm sorry, what world do you live in where windows phone market share is not a joke?

Let's not even get into backend systems doing the real work.
>>
>>55008879
It IS portable, anon.
>>
File: video.webm (631 KB, 1050x680) Image search: [Google]
video.webm
631 KB, 1050x680
This is 5x sped up because I'm only sampling every 5th frame.
Now to add player position markers...
>>
>>55008856
>>55008863
Thanks guys, I'll try them first then. I think they even have a student package and everything.
>>
>>55009067
Desktops aren't dying faggot, and phones and tablets aren't gonna fucking replace them for a long time
>>
>>55009084
what is this? some kind of game?
>>
>>55009108
Even if they were, I deploy C# + Xamarin apps to mobile and tablets.

Xamarin is pretty damn hot, especially now that it's free (freedom and beer).
>>
>>55009121
>programming in C# when you could be programming in F#
>>
>>55009137
C# has more support, and is more widely used.

F# is fine. I just don't care for the functional style that much.
>>
>>55009137
>F#
>>
>>55008516

Could you do me a favour? Film the following:

Click on the UK
Under the image, put some static text saying "If we stay in the EU".
>>
>>55009167
is a good language
>>
>>55009176
>It's the EU's fault we imported so many indians and pakis from our ebin colonies.
>>
java test today pls wish me luck
>>
>>55009194
Good luck, anon.
>>
>>55009218
Thanks :)
>>
File: Hey Zeus.jpg (65 KB, 964x659) Image search: [Google]
Hey Zeus.jpg
65 KB, 964x659
>>55009194
wishing you luck
god bless you
>>
>>55009190

muh sovereignty tho
>>
>>55009176
Gimmie a sec
>>
>>55009194
good luck cutie!
>>
char* string_array[];
char char_array[y][x];
for blah blah
{
for blah blah
{
fill char_array;
}
}


After this, how would I assign char_array to string array?

I'm asking since you can't declare char char_array[][].
>>
>>55009194
gl mang, is it a beginner course?
>>
>>55009118
It's part of a large project. We're taking soccer match broadcasts, performing shot analysis to classify them into closeups, overview shots and crowd shots. We take the overview shots, perform some more image recognition magic and extrapolate which part of the court is in view in every 5th frame. More image recognition creates bounding boxes around the players that are in view in each frame.
I wrote a script that takes some camera parameters like spatial coordinates, zoom factor etc and visualizes the camera FOV as seen from above. The next step is to take the parameters of the bounding boxes, extrapolate player screen coordinates from that (easy), transform those into world coordinates and show them in the video as well.
>>
>>55009194

Wear your lucky panties, you'll do great!
>>
>>55009271
You can declare char char_array[][]. I think only the first one may have variable/unknown length though. So you could do char char_array[][size].

string_array = char_array should work, I believe.
>>
>>55009315
have always been interested, how do you do that
>>
>>55009315
so soon you'll have a bunch of colored boxes indicating players moving around on your field in the video?
>>
>>55009315
what techniques of image recognition do you use?
>>
>>55009363
I should have clarified, I don't actually know what size would be until just before the for loop.

char* string_array[] is in a struct and char char_array[y][x] is in a function. X and Y are only found out inside the function.
>>
>>55009429
just post the whole code already.
>>
>>55009442
typedef struct
{
SDL_Texture* texture;
SDL_Rect rect;
char* map_data[];
} TileMap;

void LoadMapData(TileMap* tile_map, const char* map_file_path)
{
FILE* map_file = fopen(map_file_path, "r");

// get the width and height of the map
int width = 0;
int height = 0;
{
char c;
while ((c = fgetc(map_file)) != '\n') width++;
fseek(map_file, 0, SEEK_SET);
while ((c = fgetc(map_file)) != EOF) if (c == '\n') height++;
fseek(map_file, 0, SEEK_SET);
}

// load the actual map data
char map_data[height][width];
for (int y = 0; y < height; y++)
{
char line_buffer[width + 2];
fgets(line_buffer, width + 2, map_file);
for (int x = 0; x < width; x++)
{
map_data[y][x] = line_buffer[x];
}
}

// the important part i want to find out
tile_map->map_data = map_data;

fclose(map_file);
}
>>
What are some Python projects I can study as a beginner?
>>
>>55008931
Wow, that's really neat
>>
>>55009490
Uhh before trying with video games, try learning the fundamentals on the language you're trying to use because clearly you know nothing about C.
>>
>>55009569
ok thanks you solved my problem
>>
>negative double max value is smaller than double min value
>java
>>
>>55009594
you're welcome
>>
File: output.webm (2 MB, 1120x695) Image search: [Google]
output.webm
2 MB, 1120x695
>>55009176
>>
>>55009569
what do mean? its valid C
>>
>>55009387
Magic, a couple thousand lines of code and a grid engine.

>>55009394
Colored circles in the overhead view, but yes.

>>55009411
Depends on what you use it for. In order to determine the camera parameters, for example, we have the program find out which part of the court is visible based on the markings. Obviously this is more accurate if the goal area is in view since that's where most markings are, so we actually go back and forth in time and improve the estimation in frames where no goal area is visible by extrapolating camera movement starting and ending in the goal area.
For example if the video is panning from the center of the court to the right goal area, the FOV estimation will be very inaccurate since you only have an ellipse , a horizontal and a vertical line to base your estimation on. Once the goal area comes into view there are suddenly a half dozen lines or so that the program can recognize, so the estimation of the camera parameters is more accurate. So now the program "rewinds" the video to see how the goal area markings move out of the field of view to extrapolate camera pan speed and thus improve the camera parameter estimation for the frames where the estimate was inaccurate before.
>>
>>55009569
What does that sort of quip help, you fucking cuckshit? It's one thing to hate on webdevs, but why hate on a guy trying to make a real program?
>>
>>55009645
yes, it is valid C, but he has no idea how memory management and pointers work, which is a fundamental knowledge required to make any program beyond fizzbuzz
>>
>>55007919
thats a boy isnt it
>>
>>55009740
who cares you fucking manchild

>>>/a/
>>>/out/
>>
>>55009688
and that's why i asked a question
>>
>>55009288
Nah, it's second year. It's mostly on Linked/Array
bags and stacks, recursion, error handling, and the concept of Model-View-Controller.

>>55009233
>>55009257
>>55009358

Thank you guys :)
>>
>>55009773
instead of using the temporary stack array, allocate the heap memory for tile_map->map_data and write directly there, not sure how that helps you though
>>
>>55009629
That's not java, that's floating point spec you goober.
>>
File: 1461185606861.png (392 KB, 832x832) Image search: [Google]
1461185606861.png
392 KB, 832x832
>>55009643

It's too bad remainers are going to ruin everything for Britain.
>>
>>55009806
The only retards in the debate are those who are strongly in favour of either option, being completely ignorant of the huge lists of benefits and drawbacks that come with EU membership.

Anyone who knew how they were going to vote instantly without really thinking about it should be shot in front of their families.
>>
>>55009688
Actually, I do know jack shit about memory management. You've just started me learning.

So here's an actual sincere thanks. I needed that.
>>
File: 3543.jpg (1 MB, 3543x2126) Image search: [Google]
3543.jpg
1 MB, 3543x2126
>>55010038

Yeah, I don't think so, cunt. When remainers start getting portrayed as neo-nazis, let me know.
>>
>>55008499
What is this? My networking class would enjoy it.
>>
In which CS class do you learn about malloc?
>>
>>55010178
>implying Brexiters haven't continually portrayed the EU as a new nazi Germany

"Hitler, tried this out, and it ends tragically. The EU is an attempt to do this by different methods." - Boris Johnson

http://www.express.co.uk/news/world/470967/The-EU-was-HITLER-S-idea-and-it-proves-Germany-WON-the-Second-World-War-claims-new-book
>>
>>55009176
The UK pushed for more immigration, not the EU
Also, Brexiters never consider emigration, or "ex-pats" as I think they prefer being called
>>
>>55010178
When Boris starts using numbers that aren't completely made up, let me know.

There are cunts on both sides, why do you choose to be blind?

Also, probably one of the most hilarious things to come out of the debates is people who immigrated 20 years ago, telling other people they have no right to enter the country.
Standard right-wing double standards, but nobody can actually go after it as a story since they would be attacking the "minorities".
>>
>>55010221
the first one
>>
>>55010038
With certain upcoming agreements like TTIP. If you want a democracy you should probably get out. It's looking like it will pass.
>>
>>55010293
>democracy
>handing complete control to a government elected on about 30% of the votes and an unelected house of lords
>>
>>55010248
No.
>>55010221
You don't learn it in any CS course. You learn it in your first C programming course (hopefully). Anyone doing serious software is actually using malloc. So it doesn't matter.
>>
>>55010225
>>55010245

ITT: lefties talking bollocks, as predicted
>>
>>55010341
*Utter bollocks
>>
>>55010230
No country ever considers their own citizens living abroad as immigrants, it's called xenophobia and is alive and well in most of the non-european world.
Even then, you have the great-grandchildren of american immigrants telling other immigrants they have no right to enter, all the while pretending they have a single Irish/Italian/Polish bone in their body.

>>55010293
There are valid points on both sides, and that is one of them. The idea is to actually weight them up, rather than cherry-picking whichever one you have convinced yourself is the most important, and pretending the others are irrelevant.

The UK government wants to pass the snoopers charter, and that is only going to become easier if the leave the EU. There is no right or wrong answer as to which option is better to remain a "better" democracy.
>>
>>55010321
Read up on TTIP. It's subverting the remaining elected representatives by allowing private companies to lobby directly in the European parliament. Along with other things.

Don't particularly care for the state of our democracy here right now (Sweden). But shit like that is way worse.
>>
>>55010341
>Claiming that the amount of money your company makes as turnover is the same as its profit isn't making numbers up

He literally can't subtract a number from another number. My asshair has a better understanding of basic arithmetic than he does.

I would actually slightly prefer to leave the EU than to stay, but it is not an outright "good" idea, and certainly not while the tories are still in charge to completely fuck up the transition.
>>
>>55010341
>I can't argue against these so I'll just say they're bollocks, that works
>>
>>55010380
TTIP is indeed dangerous ground, but if the UK leaves the EU, the Conservative government would have free reign to do much worse. And they would.
>>
>>55010404

I won't defend Boris, he's a total moron, but that doesn't mean anything for Brexit.

Frankly, he looks like a moron, too.

>I would actually slightly prefer to leave the EU than to stay

Really, it's important as a matter of autonomy. If leave wins, the EU can't really boss you around any longer.
>>
>>55010363
Well anon actually if you're taking a sledgehammer to people's ability to weigh in on political decisions like TTIP does everything else is secondary. But this isn't Pol. And you're being retarded for taking the center for such reasons without even understanding what the fuck is being talked about. You're the kind of person that suppresses opinion to further whatever direction things happen to be heading. And that's basically taking a bad position because people act out of self interests. Democracy is just one of the attempts at preventing these problems when attention is paid to them. Your argument doesn't encourage political engagement. Which I think was what you wanted. Always supporting the less favored position would be the way to increase engagement. Flip flop right there in discussion and you will find that people see that politics isn't as simple as right or wrong.

That there's still people appealing to common sense revolts me.
>>
>>55009643
I had a sensible chuckle at this.
>>
>>55010425
That guy is actually american.

I've noticed americans really hate the EU.
>>
>>55010495
Usually just the Drumpf mouth breathers
>>
>>55010513
>hurr Drumpf

Haha, it's the $current_year!
>>
File: dpt in a nutshell.png (467 KB, 796x913) Image search: [Google]
dpt in a nutshell.png
467 KB, 796x913
>>55007919
>>
write a function that averages an array of integers in C
>>
>>55010436
>the conservative government would do worse
What? How would they do worse? Are you some kind of wannabe dictator? They're elected officials. If people don't like what they're doing they can vote for someone else. They can riot in the worst case. What happens if you do that in opposition to the EU and become a rogue state? That's hopefully not war but it's pretty fucking bad.

I'm not saying you should leave the EU. I'm just saying that people are ignoring big stuff that makes it insane to stay unless you fix it. It's a very clear flowchart really. And I suspect that you could reach a majority just using the people who are certain when they understand what's going on.
>>
>>55010495
Yeah, I'm always surprised patriotic Americans really seem inexplicably turned off by the idea of a bunch of States in a Union.
>>
>>55010542
>patriotic Americans

I'm not one of them, lad. Balkanization now.
>>
>>55010528
Can I use another language?
>>
>>55010542
It was fine when we were a homogeneous people with a small federal government. Too bad that ain't true anymore
>>
>>55010574
no u dumb slut
>>
>>55010533
My point is that people won't realise how insane our own government can be until it's too late. They only got elected because the opposition was so weak and ineffective.
>>
>>55010461
Are you actually from the UK? Do you actually know what you are talking about?

How is the TTIP, which might be used negatively against our citizens automatically worse than repealing the human rights act and passing the snoopers charter, that can ONLY be used negatively against our citizens?

Again, it's very easy to cherry-pick and then forget about everything else, but then it's generally easier to be an idiot than to use your brain.

>>55010453
Quite honestly, the only matter in which they noticeably boss us around is border control, and even then there is no majority government that automatically wants to shut them down.
Having the discussion about it is good, leaving the EU for one and only one reason whilst forgetting about all of the (minor, admittedly, but plenty in number) advantages of membership is stupid.

>>55010533
>elected officials
>The "majority" government had less than 40% of the votes, in a system that demands 50% of seats for a single-party government
Seems legit.
>>
>>55010528
 
int avg(int* arr, size_t count) {
int average =0;
for (int i=0;i<count;i++) {
average+=arr[i]/count; //insert whatever rounding you want if you want it
}
return average;
>>
File: 1463604502077.jpg (60 KB, 670x503) Image search: [Google]
1463604502077.jpg
60 KB, 670x503
>>55010580
>tfw believing in state's rights makes you a bigot, racist, and homegrown terrorist.
>>
>>55010580
>Americans
>Ever homogeneous
The delusion is real.

This is coming from a white American that wants less H1Bs, stronger borders, and a ban on immigration from predominantly Muslim countries.

We were never a homogeneous society in any capacity. Not race, not religion, and not political beliefs.
>>
>>55010602
wrong
>>
>>55010528
Fuck you


void swap(int *x, int *y)
{
int tmp = *x;
*x = *y;
*y = tmp;
}

int average(int x, int y)
{
if (x > y) {
swap(&x, &y);
}

while (x < y) {
x++;
y--;
}

if (x == y) {
return x;
} else {
return y;
}
}


>>
>>55010645
My bad, it guess we weren't all Englishmen after the Revolutionary War
>>
>>55010679
Fuck wrong copy paste lol
int avgn(int *nums, size_t n)
{
int total_quot = 0;
int total_rem = 0;
int i;

for (i = 0; i < n; i++) {
total_quot += nums[i] / n;
total_rem += nums[i] % n;
}

return total_quot + total_rem / n;
}
>>
>>55010645
B-but muh history books!

Gosh, it's almost like there wasn't a whole civil war tearing the entire country to shit because they couldn't agree on almost anything.

Trump supporters are just mad they'll have to start paying their gardeners minimum wage when they actually get citizenship.
>>
>>55010684
No, you really weren't.
>>
>>55009740
Yes. Although he [spoiler] wanted to fix himself and become more manly. [/spoiler]

If I remember correctly, he directly typed in a human-level general AI.

>>55009749
Piss off.
>>
>>55010684
lots of europeans went to America
not just anglos
>>
Should I use smart pointers exclusively or only when dynamically allocating?
>>
>>55010684
Half the people want to stay in the empire what are you talking about
>>
>>55010712
dude just use a void* lmao
>>
>>55010624
Maybe not, but you are a tremendous faggot who somehow manages to have the incorrect opinion on everything
>>
>>55010600
No I'm not from the UK. As I said you illiterate Anglo.
>snooper charter
OK so you simply don't know about TTIP then. That's fine. But they're not on the same scale of intrusion.
>>55010596
Yes but when there's a major problem running at us with rapid speed perhaps deal with that first before the relatively minor issues? Because there's plenty of shit that the EU doesn't protect you from.

And I sincerely doubt that a brexit would come without adopting at least some portion of EU legislation. There wouldn't be any discussion if everyone considered everything all bad. UKIP would probably like you to believe that for obvious reasons (every politician wants power). But that's not the general political opinion of the conservatives in the UK (pretty ridiculous you still use words like conservative).
>>
Been learning Python, still a huge noob but I now have a general idea.

I am learning programming in order to make an app. I know what I want to do and have a reasonably well laid out plan. The big question is, Android or iOS? I get the impression I am more likely to be able to make some money if I develop for iOS.

Also, do I need to buy a mac to use Xcode? I am pretty happy with my Thinkpad.
>>
>>55010652
Elaborate. I specified that the implementation could be altered given the idea of an average you wanted.
It's the perfect solution.

Write your own damn homework. Basically.
>>
>>55010776
INTS CANNOT BE AVERAGED IN C DUDE LMAO
WAS JUST A PRANK BRO
AHAHHHAHAHAH
>>
>>55010735
>the incorrect opinion

Thanks, lad. I appreciate the critique.
>>
>>55010776
Look at my answer (the one that gets the quotients and adds the remainders) and you'll see why you were wrong
>>
File: 1430611415359.jpg (15 KB, 200x200) Image search: [Google]
1430611415359.jpg
15 KB, 200x200
So, what does this code does?

So /g/, I'm trying to figure out what does a C Gaussian elimination does.

Assuming we have a

float A[20][20];
float x[10];[spoiler][/spoiler]

then it's divided between two operations:

int operation01(void){
for(j=1; j<=n; j++)
{
for(i=1; i<=n; i++)
{
if(i>j) //
{
c=A[i][j]/A[j][j]; //Whas does this does?
for(k=1; k<=n+1; k++)
{
A[i][k]=A[i][k]-c*A[j][k]; //Same question here
show();
}
}
}
}
x[n]=A[n][n+1]/A[n][n];
}

int operation02(void){
for(i=n-1; i>=1; i--)
{
sum=0;
for(j=i+1; j<=n; j++)
{
sum=sum+A[i][j]*x[j];
show();
}
x[i]=(A[i][n+1]-sum)/A[i][i];
}
}

What does the x[10] does? And why c=A[i][j]/A[j][j]; ??
>>
>>55010697
>signed overflow
ishyggy
>>
>>55010809
Except covered that by saying that this integer average doesn't deal with it.
Imagine someone tells you to implement 'swap'.
And you take no arguments to the function and swap two arbitrary memory locations.
There you did a swap according to spec.
My comment wasn't even needed. But I wrote it to make the argument more clear.
>>
>>55010843
>There you did a swap according to spec.
t. spergshit
>>
>>55010738
>OK so you simply don't know about TTIP then. That's fine. But they're not on the same scale of intrusion.
>Please believe everything I say is true without a shred of evidence!
Most of the problem with TTIP is that everyone handling it is being very quiet about it.
What on earth makes you think the current UK government would be more honest about it to our citizens than the EU? Literally what?
The House of Commons has already proven they want to spy on US by approving the charter by close to 80% voting for it.
Other that you just speculating the UK alone would handle TTIP better than the EU, what fucking proof is there?

>pretty ridiculous you still use words like conservative
David Cameron still thinks the UK is a "Christian nation". Conservative is an understatement.
Please continue to show how little you understand the current situation.
>>
>>55010858
t. Moron who can't even write a basic C function.
>>
what's a good git client for linux? I also use macs and gitkraken shits itself if you use different versions of git on the same repo.
>>
>>55010835
Doesn't happen you tard
>>
>>55010879
>Doesn't happen
you are mistaken
>you tard
why the aggression towards someone obviously better than you that can teach you more about C?
>>
>>55010878
git
>>
>>55010864
It kind of is, you know, it being the state religion and all.
>>
>>55010864
>what makes you think letting a group of people have less governmental influence over their own lives will make them more responsible for their actions?
Nothing. Nothing at all. But they're at least given the chance. That's enough. Here in Sweden people haven't cared yet because there's too much dick to suck (and money to spend on aiding relatively rich people who come here rather than helping a much larger group of people who are far worse off). But I'd also like to leave if this is going where it seems to be going.

Not because I think we would necessary be smarter about things. But just because there's the chance for us to be smarter.
>>
>>55010944
Also important to note that I don't particularly care for a population that can't deal with their own shit and would have to have foreign political aid to sustain some form of privacy law.

Yeah. You're shit and should get shit for it if you're having these issues. Maybe then you will learn?

You sharing a political organization with us harms us. Instead you should be forced to adapt.
>>
>>55010906

I was hoping for something with a gui

Is there an advantage to taking the time to learn the cli?
>>
will I ever get comfortable wiht C pointers
>>
>>55010999
>I was hoping for something with a gui
>I use Linux

what the fuck
>>
>>55011010
What are your current doubts?
Take a piece of code you have. Post it here and explain what you're unsure of.
>>
>>55008295
It's a trap.
>>
>>55011015
Linux desktop is a thing, plugging your ears and shouting wont change this fact.

>>55010999
History browsers exist standalone, not sure about guis that offer full git on linux though
>>
>>55010999
Wtf? Do not use a git gui
>>
>>55011081
>denies that linux is generally anti-GUI
>fails to offer a GUI option for a ubiquitous software development technology

lol
>>
where can I find Computer Security Principles and Practice 3rd Edition pdf?
>>
>>55011034
I feel I have to figure out how it works omw
>>
>>55010927
We don't sing the national anthem or hum Church of England hymns in schools.
It used to be a Christian nation, but it is not so any more.

When he said it, he didn't mean in a technical sense, the cunt actually believes most of the country still lives by Christian values.

As I said before, conservative is an understatement.
>>
>>55010864
>monarch is head of state
>monarchis appointed "by the grace of God"

Objectively speaking, the UK is a Christian nation. And my left bollock is further to the right than Cameron. This is the guy that legalised gay marriage. Not because he was forced to; he was the one publically pushing for the law to pass. He's a centrist populist with very few (if any) fixed beliefs.
>>
What's the best way to parse an image
>>
When converting a decimal number to binary, what if the number ends up with a remainder? Or is that never going to happen?
>>
>>55011292
>We don't hum Church of England hymns in schools.
I had daily worship in secondary school where we prayed and did stuff like that, this was only 10 years ago or so
>>
>>55011310
>parse an image
What exactly do you mean by this?
>>
>>55011305

It seems like, outside of the USA, everybody else besides actual communists are "far right"
>>
>>55011327
Can you be specific as to how you're converting it? And is the number an integer or floating-point?
>>
>>55011327
if the decimal number is an integer it's never going to happen
if the decimal number is a decimal fraction i don't think it can happen either
>>
How does one use autotools
I figured some things out but I'm confused about one thing, if I want to have my code on github, do I compile the configure before-hand so the user could do
./configure
make
make install

or do I let them doing the autoconf stuff something a long of lines of
autoreconf --install
./configure
make
make install
>>
>>55011364
>>55011374
Let's say it's any regular number like 5, 9001, or 6 million, it will always perfectly convert to binary, yes?
>>
>>55011439
yes
>>
>>55011439
as long as its integer you should be perfectly fine
if its any sort of floating point number, you might get to some problems
>>
>>55011449
Awesome. What about a fraction or decimal like 2/9 or 3.5, how messy does that get?
>>
>>55011329
Where did the priests touch you?

>>55011305
Well no politician is ever forced to change existing laws to fit in with newer ones so as to not be contradictory, but it's generally a good idea.
It also had overwhelming support, and would have been suicidal to oppose because "muh jesus".

I'd also say that selling off chunks of the public sector is pretty much *the* defining act of a conservative government.
Let's not get into who did or didn't stand to make a lot of money off of the sale of Royal Mail either.
>>
>>55011439
Yup. Every integer can be written as a sum of powers of 2 - try some examples if it's not intuitive.
>>
>>55011476
Well 2/9 is periodic so the binary fraction will be periodic also

3.5 will be converted easily

I don't actually know the algorithm but it's pretty easy
>>
>>55011343

to get something usable

raw image data would just be hex, how do you get something more palatable from this? (a higher level data type)
>>
>>55011479
The Royal Mail selloff was bullshit, but it was economic bullshit, not social bullshit. Being a greedy cunt with chums in the private sector isn't a far-right political position.

>It also had overwhelming support, and would have been suicidal to oppose because "muh jesus"

But as I said, Cameron did more than not oppose it. He was the most visible proponent, and made a show of passionately arguing for it in the Commons. Obviously this wasn't done out of genuine deep-rooted belief, but rather because he recognised a popular policy and wanted to stamp his face on it. This is how an opportunistic politician behaves; it's the emphatic opposite of somebody with far-right beliefs.
>>
>>55009490
Okay so after following >>55009569
I figured out how to do this.

typedef struct
{
SDL_Texture* texture;
SDL_Rect rect;
int width;
int height;
char** map_data;
} TileMap;

void LoadTileMap(TileMap* tile_map, const char* map_file_path)
{
// if a previous map has been loaded, clear all of it's data
if (tile_map->map_data != NULL)
{
for (int i = 0; i < tile_map->height; i++) free(tile_map->map_data[i]);
free(tile_map->map_data);
tile_map->width = 0;
tile_map->height = 0;
}

FILE* map_file = fopen(map_file_path, "r");

// get the width and the height of the map
{
char c;
while ((c = fgetc(map_file)) != '\n') tile_map->width++;
fseek(map_file, 0, SEEK_SET);
while ((c = fgetc(map_file)) != EOF) if (c == '\n') tile_map->height++;
fseek(map_file, 0, SEEK_SET);
}

// load the map data
tile_map->map_data = malloc(tile_map->height * sizeof(tile_map->width * sizeof(char)));
for (int y = 0; y < tile_map->height; y++)
{
char* map_row = malloc(tile_map->width * sizeof(char));
char line_buffer[tile_map->width + 2];
fgets(line_buffer, tile_map->width + 2, map_file);
for (int x = 0; x < tile_map->width; x++)
{
map_row[x] = line_buffer[x];
}
tile_map->map_data[y] = map_row;
}

fclose(map_file);
}


My question is about the first part of LoadTileMap, should I use realloc instead of just freeing the data?
>>
File: nn_schematic.gif (10 KB, 510x290) Image search: [Google]
nn_schematic.gif
10 KB, 510x290
Is it safe to say that PyBrain is the best Artificial Neural Network library in existence?
>>
>>55011476
You have to make up the remainder with reciprocals of powers of 2: 0.5, 0.125, 0.125, et cetera. You might get lucky and only need a few bits, but often it'll turn into a recurring number and you'll have to truncate, even for seemingly simple numbers like 0.55.
>>
So a quote in scheme can be interpreted in two ways
either you do:
 'x
so that x is a symbol or
'((((rosenberg)))))))
and the quote 'operator' picks up only the first 4 balanced brackets
with the exception of a situation where you type in
'((00000))
where it evaluates to ((0))
>>
>>55011562
What the fuck are you talking about?
>>
So what's the demand for C programmers like?
>>
I've got this code for generating matrices:

int ** arrayGenerator ()
{
size_t ARR_DIM_1 = 4; // (rand() % 9) + 1;
size_t ARR_DIM_2 = 5; // (rand() % 9) + 1;

int ** output = new int * [ARR_DIM_1];
for (unsigned i = 0; i < ARR_DIM_1; i++)
output[i] = new int[ARR_DIM_2];

for (unsigned i = 0; i < ARR_DIM_1; i++)
for (unsigned j = 0; j < ARR_DIM_2; j++)
output[i][j] = (rand() % 10);

return output;
}


Problem is, it only gives me a pointer to the first element of the array, telling me nothing about the array sizes. Is there any way I can return the sizes along with the pointer?
>>
>>55010899
show me inputs that cause overflow or kill yourself tard
>>
File: langs.png (66 KB, 556x533) Image search: [Google]
langs.png
66 KB, 556x533
>>55011764
If you went off of /dpt/, you'd think it was the most in-demand language.

In the real world, however...
>>
>>55011801
>ios is a programming language
>>
>>55011709
No, reread wharever you've read
Quote isn't meant to pick up text or textual representation, it protects stuff from being evaluated. It only comes in play after its argument has been parsed, and it can be written as
(quote stuff)
(this yields the symbol "stuff")
>>
>>55011801
>Programming jobs
>SQL

News just in, HR doesn't know how to advertise for the positions their companies need, more at 10.
>>
>>55011820
>he can't program in iOS
>>
>>55011820
>>55011853
That chart is retarded, but it's true that there isn't much demand for C programmers.
>>
File: 1465268823651.jpg (128 KB, 1440x1080) Image search: [Google]
1465268823651.jpg
128 KB, 1440x1080
>>
>>55011883
>obvious_bait.jpg
>>
File: 1460860815633.jpg (54 KB, 388x621) Image search: [Google]
1460860815633.jpg
54 KB, 388x621
>>55011015

things you do with git, e.g. create and merge branches, compare files, are the sorts of things that could be done more efficiently with a graphical interface.

I'm perfectly comfortable with a cli in general, but I also want the best tool for the job.

>>55011119
>linux is generally anti-GUI
More like it hasn't been a priority. The paid linux devs are focused on servers.

>>55011081
>History browsers exist standalone,
I'll take a look, I guess

>>55011098
why not?
>>
>>55011796
>I can't do simple math
try filling an array of length "(int) sqrt(INT_MAX) + 2" elements with the value "(int) sqrt(INT_MAX) + 1" and call your avg
you like the taste of big dick, faggot?
>>
>>55011862
That's because C is used in embedded systems, where the job titles probably don't have the words "software" or "developer" appear anywhere in them.

Fiddling statistics is extremely easy, why do you think dense politicians are so good at it?

Also to consider is that picking up C is relatively quick, so a company may not care if you already know, or they may just flat out assume all CS grads have a basic enough understanding.

Whereas Java and C# have such large fucking libraries that they want someone who really knows what they are doing specific to that language, because you will be in so deep you'll never see the light of day again.
>>
Im new to C++ and am trying to make a DLL for something else that just returns the Windows Personalization color. I think this should work but I get the error:

1>main.obj : error LNK2019: unresolved external symbol __imp__DwmGetColorizationColor@8 referenced in function _GetCol

Anyone know why?
Heres my source:
#include <windows.h>
#include <dwmapi.h>
#include <gdiplus.h>
#define DLLEXPORT extern "C" __declspec(dllexport)

DLLEXPORT double GetCol(void) {
Gdiplus::ARGB colord = 0;
BOOL opaqued = FALSE;
HRESULT result = DwmGetColorizationColor(&colord,&opaqued);
return colord;
};
>>
>>55011883
>using a language with a phallic mascot
>>
File: gittools.png (59 KB, 773x337) Image search: [Google]
gittools.png
59 KB, 773x337
>>55011913
Visual Studio has a GitTools plugin that adds a GUI/command line hybrid interface.

You can use one or the other, or both at the same time to manage your branches and commits.

Maybe whoever developed GitTools has something linux-flavored.
>>
>>55011943
If you have any resources that show C having more than a fifth of the openings of something like Java or C#, feel free to post them.
>>
File: 1465541344958.png (321 KB, 480x650) Image search: [Google]
1465541344958.png
321 KB, 480x650
>>55011078
But he is not gay, actually he did it because some kind of trauma, not to fuck boys or some shieet
>>
>>55011945
#pragma comment(lib, "Dwmapi")
>>
>>55012019
It's like you didn't even read my post or something:
https://www.sitepoint.com/best-programming-language-learn-2015-job-demand-salaries/

Just because a job description doesn't mention C specifically, doesn't mean that they may not just expect you to know it on top of the stated requirements.
>>
why does this not compile?
int total = 0
for (i = 0; i < 58352; i++)
{
total = total + i;
}
>>
File: c_mistake.jpg (211 KB, 587x551) Image search: [Google]
c_mistake.jpg
211 KB, 587x551
>>55012141
>show up for Java interview
>you are grilled on C89 standard for 3 hours
>>
>>55012179
Dunno, what does the compiler say?
>>
File: download.jpg (17 KB, 300x168) Image search: [Google]
download.jpg
17 KB, 300x168
>>55012187
I think the biggest mistake for C was not sacrificing even more safety for speed
>>
>>55012179
because u didnt declare i
>>
>>55012179
Missing semicolon on first line.
>>
>>55012216
Error: line 1 - cannot find symbol - variable i
>>
>>55010528
C doesn't have integers
>>
>>55012141
Most programmers do not know C.

This is just a silly assumption.
>>
>>55012221

What safety does C have, exactly? What more could it possibly give up?
>>
>>55012248
Do not underestimate the incompetence of recruiters.
>>
File: bread3.png (301 KB, 450x450) Image search: [Google]
bread3.png
301 KB, 450x450
>>55012133
Wow holy shit that worked. Thank you so much anon :)
Any chance you would know how to then convert the color to a COLORREF?
>>
>>55012246
>I don't know C: the post
>>
>>55012221
>C
>speed
B and C originally compiled to threaded code.
>>
>>55012248
>>55012260

That's why anybody answered to this guy?

>>55010834
>>
>>55012179
int total = 0;
for (int i = 0; i < 58352; i++) {
total = total + i;
}


Let's save everyone the time and effort and just spoonfeed them.
>>
>>55012266
show me where C provides integers, not something that it calls integers but aren't
>>
File: 1463520751007.jpg (426 KB, 1030x1500) Image search: [Google]
1463520751007.jpg
426 KB, 1030x1500
>>55007919
Damnit, I'll start crossdressing. Too bad I'm kinda ugly and not exactly young anymore...

Made this the other day to test PBM tool suite:

use warnings;
use strict;
use autodie qw(:all);
use v5.16;

my $w = 800; my $h = 600;
my $p = 64;

my @matrix = (0)x($w*$h);

for (my $i = 0; $i < $h; $i++) {
for (my $j = 0; $j < $w; $j++) {
my $c = ($j + ($i % $p) + $p) % $p;
$matrix[$i*$w + $j] = $c;
}
}

my $fd1;
open($fd1, '|pnmtopng|feh -');

print $fd1 "P2\n$w $h\n".($p-1)."\n";
for (my $i = 0; $i < $w*$h; $i++) {
printf $fd1 '%3d ', $matrix[$i];
if (($i+1) % $w == 0) {
print $fd1 "\n";
}
}

my $fd2;
open($fd2, '|pnmtopng|feh -');

print $fd2 "P2\n$w $h\n".($p-1)."\n";
for (my $i = 0; $i < $w*$h; $i++) {
printf $fd2 '%3d ', $matrix[($i+321*50+230)%($w*$h)];
if (($i+1) % $w == 0) {
print $fd2 "\n";
}
}
>>
>>55012288
>where
in the standard, there's plenty of them
>>
>>55012275
Nobody answered them because the faggot didn't even bother to put it inside code tags.

Also I've been too busy shitposting about politics to actually answer any programming related posts.
>>
>>55012253
Pointer aliasing
>>
>>55011919
BTFO
T
F
O
Thread replies: 255
Thread images: 30

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.