/dpt/ - Daily Programming Thread

Previous thread: What are you working on, Cred Forums?

Other urls found in this thread:


First for not programming

Eclipse or NetBeans?

eclipse for sure


Uploaded a new WinAPI project I worked on for a few weeks during the summer, on my github.

What do you guys think about my epic C function call skills? github.com/Gikoskos/KiNO_Win32/blob/master/k_win32gui_main.c#L294


But it works perfectly user. The whole app hasn't got a single memory leak or invalid memory access and it's super fast.

But it makes me want to throw up looking at it.


rlx user i bet he is 10 languages hello world programmer and linux poser

this was for you not for

>some user told me to use GLEW to do pic related
>I have no idea how

not bad but you might wanna use another API, microsoft needs to get its shit together

If I added comments it makes perfect sense to see why I did that. You can check the compiled binary on Releases to understand what really goes on.

In my 2011 computer, managed languages like C# or Java that run 100 layers above the OS are extremely slow. Small apps take like 1 minute just to open on Win 8.1, Intel i5 3.2Ghz, latest Java version.

Maybe I don't have enough RAM though for the memory hungry beast that is the JVM though.

What happens if a localized string is longer than the small fixed-sized arrays you allocate for them? LoadStr does not seem to let you pass in a string length, so it'll happily overwrite your buffer, leading to all sorts of mayhem.

It won't overwrite the buffer. You're right it might seem deceptive at first but LoadStr is just a macro and can only be used on arrays (not on pointers).

It's basically a convenience wrapper for LoadStringW of Winapi which takes as argument the size of the array:

The buffer never overflows in case the localized string is longer. It just displays less characters.

Fair enough. But for the sake of all that's sane and holy, don't call it "LoadStr". It's a macro, follow macro naming rules and rename it to "LOAD_STR" or "LOADSTR". You seem to have mixed CamelCaseMacros and some UPPERCASE_MACROS. Don't do that, be consistent when naming things.

Am I understanding this right?

:(){ : | : & };:

This executes a function :(), and while it is executing it spawns children functions infinitely

so it's a fork bomb

You're right, I didn't think of it. Might change it to make it more readable. Might as well add more comments. People might start thinking that my code is complicated while it's not

In previous commits you can see the same function, and what it looks like without using localized strings. It's much more simple.

But I'm quite proud of the localization system

It was kinda tricky to implement it. It uses the satellite DLL technique that some other popular programs use like the AMD catalyst or Daemon tools

What is the most axiomatic programming language? What I mean is, what programming language works on the least amount of abstract instructions? I'm not talking about something like brainfuck, I mean an abstract language.

I meant that it was tricky because I wanted to have the runtime change language effect without having to reboot the program every time; like Skype or Notepad++ have.

Notepad++ uses XML files though, I'm using resource DLLs instead.

Can anyone tell me what that .po localization system is that I see on many linux app source codes? How does it work, what library it uses, etc?

0. Set up GLFW
1. Generate GL loader with glad.dav1d.de/
2. Include in build
3. ???
if (!glfwInit()) {

GLFWwindow *window = glfwCreateWindow(800, 600, "GLFW + GLAD", NULL, NULL);

if (!window) {

/* glfwSwapInterval(1); */

if (!gladLoadGLLoader((GLADloadproc) glfwGetProcAddress)) {

4. Ancient meme!

:() opens the declaration of a function called :
The brackets {} contain the function body
the function body executes the : function and pipes the result to another : function
& means it's done in the background (essentially, new thread/process)
; closes the function definition
: immediately launches the function

I was asked to do my first freelancing job as a programmer (C/C++). I've never worked before in this field and I'm still studying computer engineering. What do I charge? What are your experiences on the field?

They all look like dorks but holy shit I'd cum in the third one from the left's boypucci

Debugging code i wrote last night while drinking. and just generally unfucking it

That's gay.

If anybody can guess what the marked function does I will literally give him 3 (You)'s

Do you guys have twitter? do you post programming related stuff?

Netbeans if you're not a fedora tipper


can someone write a twitter bot for me which retweets popular content and sometimes flat out steals it?

Thanks in advance

You need to specify a bit but I think youre close

That's the best I can do.

Just tell me what you mean by in bounds

fuck off you fucking retarded faggot

wow rude reported

You are very lucky. I'd kill to have a freelancing job that's C/C++ and not webshit or databases.

what kind of freelancing job do you do?

Whatever I can get, so mostly web stuff now. But I could do science stuff or whatever in C++.

what's your background?

What's those string prints that can fail and are always checked for errors?
Have you considered using a macro to avoid having to write those failure cases like that?

There's some ogl extension header generator somewhere which I'd recommend you use.
Do it yourself.

I have a university degree in applied math.

but how do you advertise yourself?
you got a website or something?

>doesn't have a single invalid memory access or memory leak
Either of those can be considered fatal errors. If you normally get this then consider simplifying your use of the language.

It checks if the click occurred in the empty tile.

> how do you advertise yourself?
I don't advertise, there are websites where you can find such jobs.

It actually kind of does the opposite
*Hint: A tile is 100*100 pixel

What language is this that forces you to write private and public everywhere?



The YMCA of modern era.

Can you really learn programing with no computer and just SICP? Lets say someone were planning to hike the appalachian trail for 6 months and didn't have access to a computer. Could I bring this book, study each day, and know how to program after I'm finished reading?

>xda developers

It teaches you programming but not how to use any of the tools. Imagine you're a carpenter and read about how you make constructions stable and the properties of wood.

What was the commit message?

>fix big breach in security

Whenever I'm given a programming assignment I usually start by working out a plan of what data structures, functions, etc I'll need and how they will all interact together basically using the principles of top-down design I learned in my first semester computer science class.

However when I go to code it, I always end up just doing trial and error shit to get the program to work and it ends up looking a lot different than my plan. This is fine for small simple problems but as we're getting into more complex programs with many more "moving parts", I'm finding I really need to get the design process down.

Are there any tips that anyone can offer me to that end? I'm in second semester programming now and we're using C/C++.


Disable mmap entropy boot abort

(the correct way to fix that is to cherry-pick some kernel changes made by google)

read some books about design pattern and good software architecture.

So realistically, no? yes?

Thanks for the quick response. Are there any particular books you would recommend?

I like Head First design patterns. Gave a lot of good practical advice with good examples etc. Easy enough to digest.

Up front planning is kinda bad because for programming when your plan is done you've already written the program, just in a different language, without any sort of reality checks and without regard for what a computer actually is.

Another approach is to write the program bit by bit as you go. Basically just write your code and presume the functions you need exist when writing. You can write the declarations and definitions later. Usually when you do it that way you end up with the minimum amount of code you need to write and you get a good data flow because you're only passing what you need to the places you need them.

Well you'd have to fiddle with your tools later. You can't expect to sit down and write something after that immediately. But you have a very good starting point.

>Up front planning is kinda bad
You wouldn't happen to work for Microsoft would you?

I don't want to hardcode a specific API in.
And I'm using GLEW, not GLAD.

Design patterns are awful. They're either very narrow in how they're applicable, which make them work well for certain problems but not others. But usually there's no guidance on when to use it because advocates advocate for it absolutely.
Or they're too general and don't really assist your development. Often they just add more to think about for very little reason. They can cause you to do extra work (because you're 'planning ahead' for things that might not happen), make your code less tolerant to changes (the worst imo) and make you less ready to change things because you may have to break the pattern or work without it.

This is what Web Devs actually believe

Nice response to the argument.
I think what I said there in the first paragraph is simply true because planning means you intentionally keep yourself blind. The positive of planning is really that you're writing pseudo code. Which may be more speedy. But for any serious programmer the difference is negligible and if there's situations where you'd wish to do that you can still do that while programming.

Feel free to use whatever OpenGL platform abstraction library, GLFW is just one of them.

On the other hand, GLEW is not that great.
Its generally considered better to use a loader generator and get a consistent set of function for the OpenGL version you're targeting.
GLAD is one such loader, and you can ask it to include all extensions if that's your thing.

>this is what a moron who has never written software on his own and only making 'plans' for his triple digit LOC changes in existing code bases.


You would just end up skewed. Like a pianist who knows lots of music theory, technique, proper form, etc, but has no muscle memory.

Their still useful for lots of kinds of problems. You don't need to overthink them. DOn't expect them to solve every problem elegantly.

Their only awful if you expect too much from them.

>but for any serious programmer the difference is negligible and if there's situations where you'd wish to do that you can still do that while programming.
you sound like a terrible programmer. If you're starting a 10k+ loc project, it's worth spending some time planning out what you dependencies will be. Define clearly what you're trying to achieve. Work out what components require what kinds of state to be shared etc.

Planning doesn't stop you from being flexible when you start writing the code, being a shit programmer does that.

/dpt/-chan, daisuki~

Ask your much beloved programming literate anything (IAMA)

Learn to program by design (HTDP).

Nobody should start to undertake a large project. You start with a small trivial project, and you should never expect it to get large. If you do, you'll just overdesign and generally think it is more important than it likely is at that stage. Or worse, you might be scared away by the sheer size of the work you envision. So start small, and think about the details. Don't think about some big picture and fancy design. If it doesn't solve some fairly immediate need, it's almost certainly over-designed. And don't expect people to jump in and help you. That's not how these things work. You need to get something half-way useful first, and then others will say "hey, that almost works for me", and they'll get involved in the project.



>that vid
just wait until they explain to that kid that life ends


>Composition over inheritance when inheritance is the logical thing to do.
Quite possibly the most retarded thing someone could do.

>abstract class GameObject : IVisible, IUpdatable, ICollidable {
private readonly IVisible _v;
private readonly IUpdatable _u;
private readonly ICollidable _c;

public GameObject(IVisible visible, IUpdatable updatable, ICollidable collidable) {
_v = visible;
_u = updatable;
_c = collidable;

public void Update() {

public void Draw() {

public void Collide() {
Literally pants on head retarded.


The fuck?

Working with a codebase with with deep nested inheritance hierarchy's and bloated classes with bizarre edge cases is such fun!

And does GLAD work for pretty much all operating systems?

Inheritance is just a very specific and limiting kind of composition, made by OOP programmers who didn't know what they were doing

that's not really how you do composition.

>it's worth spending some time planning out what you dependencies will be.
Oh yes sure. Decide if you're gonna use external tools or not is one thing. That's not planning _your_ software though.
>Define clearly what you're trying to achieve.
Oh yes. Of course you should know what you're programming. You're not gonna sit down and write something and then somewhere in the middle figure out that you actually didn't want to write a DSP but rather you wanted to write a videogame
>Work out what components require what kinds of state to be shared etc.
You see how you're being sneaky here I hope. Because these things aren't known when you plan.

Software is supposed to be malleable. If you plan and don't immediately throw it to the side you're putting on a blindfold. You cannot be sure about how your program should look when you start because the information is so limited. The best way to navigate is to keep your eyes open and be ready to change direction. Which a plan doesn't help you with at all really.

Knowing what your program is supposed to do is another thing. I don't think anyone has trouble with that type of 'planning'.
You didn't address the cultural problems with them. Where do you find out when it's applicable or not? Can you define a set of applications where they're useful? Can you define a set of functions where they're useful? can you define a set of circumstances within your software which would make the DP applicable or useful?
It's a waste of time user. It makes as much sense as considering a linked list for every single time you allocate memory.

As long as you have a OpenGL context, its platform agnostic.

1. Write an assignment statement that might be used to implement the following
equation in C.
q = kA(T1 - T2)

>inherits from IVisible, IUpdatable, ICollidable
>complains about composition

I'm redoing my emacs configuration. I also plan to learn some elisp and add some stuff like irony mode.

>Decide if you're gonna use external tools or not is one thing. That's not planning _your_ software though.
No, i mean breaking up you project into modules/classes/functions etc at a high level. Figure out what depends on what. What aspects of each dose each other module need to depend on. Does any of this sound familiar to you? Have you red anything about software design?


So it checks if the clicked tile is swappable with the empty tile, then (that is, it is its neighbor)?

I'm at my universities hackathon, /dpt/. Give me your award winning ideas. I'm full stack

>Have you reAd anything about software design?
I have.
>i mean breaking up you project into modules/classes/functions etc at a high level.
So you mean you're gonna tell yourself "I'm gonna have audio output". Does that help you?
And you're not responding to my argument at all you're just repeating yourself.

You can't really have written any large project without having to have thrown a plan to the side. Assuming you're not re-scoping your project to fit what it became.

I have nothing against thinking about the problem, which I think maybe people confuse with planning.

over L*

>I'm full stack
What does this mean?
You claiming to be a girl or something? Why should that matter at a hackathon?

q = (k*A*(T1 - T2))/L

means I can do front and backend web dev.

And no, I'm a boy with a below average sized penis if you must know

A real time youtube to ascii video converter.

So people can watch youtube on their phones without draining data, or watch livestream on the darkweb where there's limited bandwidth.

>web dev

how do you store −0.42E7 in C? is that a floating point value?

Quake with Multiplayer over WebRTC

Why not just compress it more strongly and limit the bitdepth?

float or double

>So you mean you're gonna tell yourself "I'm gonna have audio output". Does that help you?
You sound like you've never written anything big before.

If you're going to have sound output, you consider what kind of code structure would support the need for sound output well. Maybe the audio in your project might be complex enough that something like a SoundManager module/class etc might be justified. If it is, then what does the SoundManager need to know about? In a game for instance, maybe the SoundManager needs to know a lot of information about the current level and camera location, to help calculate how to play sound effects well. Maybe it's better if it doesn't know anything about the level, and instead other code outside the sound manager just tells the sound manager when and how exactly to play sounds without letting it know why they are being played in a certain way. In this case the SoundManager doesn't need to know what a Level is, and this can simplify the code dependencies in the project and make it more maintainable going forward. This are good considerations to make before you write a whole load of code that you can't change easily. Macro-architectural decisions like this are not easy to change after to start writing code and deserve some careful consideration in the preplanning stages.

>I have nothing against thinking about the problem, which I think maybe people confuse with planning.
Making a plan doesn;t mean you have to follow 100% or at all.

Yes, and use a double.

Would that save bandwidth? a group of like, 7x14 pixels would take up 1 byte, so probably? Idk much about compression. I've worked on something similar before, though: a program which converts 32 bit bmp images to ascii. It was early on when I was a freshman so the code is shit:


I see your confusing function call and raise you whacky printf format specifier.

Ok so you're clearly beyond saving. Good evening.
>Making a plan doesn;t mean you have to follow 100% or at all.
So what was the point of the plan? What you just did was think about the problem. Not making a plan. When you've abandoned the plan the use of a plan was just thinking about the problem.

Terrible programmer.

>In my 2011 computer, managed languages like C# or Java that run 100 layers above the OS are extremely slow. Small apps take like 1 minute just to open on Win 8.1, Intel i5 3.2Ghz, latest Java version.
Lies. I have a 2010 laptop with a Core 2 Duo and 4 GB of RAM and most Java apps are almost indistinguishable from native apps in speed, maybe except for the launch time. This is 2016 and Java (and .NET) have JITs and are fast enough. Plus the developer productivity is greatly increased with these, which is another thing to consider. If you said I have a 2006 computer with a Core Solo I would have believed you.

Now don't get me wrong, if you like C and low level APIs are your thing go ahead, the industry needs low level developers too. But the speed argument is a meme.

>So what was the point of the plan?
To explore the problems you might be facing when you make the problem, and try to pick out the best ones to start with. As you start coding you will almost always learn about new things you need to consider and maybe new requirements, and so you have to adjust your plan. But it's never easier to make changes to the overall architecture than it is before you start, so it's worth making a decent effort to make a pretty decent overall design for the codebase at the beginning if you can.

Almost no plans are followed 100% in any aspect of life. I don't know where you got that autistic definition from.

>Terrible programmer.
Apart from disagreeing with your definition of the word "plan", how am i a terrible programmer?

When will the dynamic typing meme end?

d = {0: 'abc', False:'xyz'}
d[0] # returns 'xyz'

I made an IRC bot.
Not sure if I'm doing certificate verification correctly, and I still need to do hostname validation.

Ask other people what a plan is and if you throw it away at the first inconvenience do they also consider it a plan?
>How am I a terrible programmer
Well if you've written moderately sized projects as you claim (though 10k+ LOC is really a stretch to call moderately sized. It's still small if written in an imperative programming language). And you have the idea that a plan helps you if you follow it then you're objectively a bad programmer because you don't consider the problem first and foremost. You've put the plan in front of the program and as soon as you do that you've made your program worse.

Either way, as described before you don't know what your program is supposed to be from the outset so planning like that

>But it's never easier to make changes to the overall architecture than it is before you start
Yes, this is true. But you don't know what the overall architecture should be when you start. A plan is a guess at that point. Why would you work in one direction when you don't know what's right? Any decent programmer knows and has felt that they know when they're going wrong more and more the further down the wrong road they're going. If your plan takes you there then yeah you can give up.

But as far as guesses go just writing the simplest possible thing and being ready to change your direction would be many times better than sticking to a plan. Better than sticking to it any amount.

It's not bad to stop in the middle of a project and think "where am I? where do I need to go? what is bad right now?". That's proper planning. Planning when you have information.

fucking javascript...

Every night I pray that TypeScript will take off : (

Could someone please explain to me how conversions/promotions work in C++?

>>Either way, as described before you don't know what your program is supposed to be from the outset so planning like that
is pointless beyond the 'thinking about the problem' part.

is it true american software companies don't hire americans to write the code itself? my software development teacher says they outsource the development itself, and the american employees just come up with the requirements and test it

Do you crossdress while you program?

What is there to show?

That happens in some crappy places, but I don't think it's the norm.

Your little magic rabbi won't grant you any wishes, christcuck.

They damn well don't hire fucking filthy frogposters

No, but sometimes I use the trans bathrooms at my university and dream


Well it's not always true at least. I have some contact with engineers at GE that are writing software.

Thanks. I'm learning C++ for the first time and I'm working on a small program that takes the average of 3 numbers, but I want to try and make it as memory efficient as possible.

Poltards confirmed to be tipping fedoratards.

Microsoft, facebook, etc. all abuse the H1B visa system so they can import programmers which they pay way less than Americans. Others will outsource their coding to the Philippines or India.

I'm no Christcuck. Everyone knows Anders Hejlsberg is the true son of God.

TypeScript will save us. And the dynamic types will be let burn in hell (which is just using JavaScript for everything).

No, the only son of God (the lambds cube) is Simon Peyton Jones.

>but I want to try and make it as memory efficient as possible.
It's too small to really have any issues with that.
You can put bounds on what's allowed to be input (only accept numbers from 0-255 and you can use char, one byte, to store the numbers).
But beyond that there's no way unless you're being extra inefficient. The simplest solution I can see you doing is as memory efficient as I can think it would be.

Assuming you're not gonna get rid of the C standard library.

>Develops "Useless" language
>Son of God

>a small program that takes the average of 3 numbers
now i find that hard to believe

So is it possible to automatically change the variable type into an int when the input is greater than 255?

Write a program that stores the values 'A' , 'B' , 19 , and −0.42E7 in separate
memory cells that you have declared. Use an assignment statement to store
the first value, but get the other three values as input data from the user in C


>Averaging numbers

pls explain

how do I get the other three values as input data? Use a scanf and ask them to input the values 'B' '19' and '-0.42E7' in char b, int c, and double d respectively.

Need ideas for a uni project in C# which would involve networking. Any ideas for an interesting project?

What you can do is read the number as an int, store it in a dynamically allocated int. Compare it to see if it's bigger than 255. If not allocate 1 byte for it. Store it in the byte. Read the next two into the old integer you read into and do the same for them. That was you'd keep the minimum amount of memory allocated unless you do the average as you get the integers and just store the average. But it's all pointless.

And i don't advise you to try any of this yet. It's rather pointless and if you wanna get better at programming you should just accelerate your learning than wasting time on this.

This isn't how memory optimization is done either way.

Chat room

For java shit i think it happens.
When you need quality or code that can't be written by any retard like c++ that can't happen.

A decentralized VPN.
Take a few pointers from Tox.

As someone who generally avoids proprietary software, please tell me what use I would have for C#

C/C++ guy here too; how'd you get your gig?

Got it. I'll just finish this and move on.

MonoDevelop. VIsual Studio, Xamarin Studio or Visual Studio Code would be smarter ideas though.

are you being sarcastic with the c++ thing? C on the other hand, the only people i see who program in C at major companies are pasty white guys. have yet to see a single "diverse" C programmer

Chat room for whom? People on the same local network or on the web?

Basically a college near me offers a programming certification. You have to take C++, Python, and C#. I basically dont even want to do it because of the requirement for C#. But if it has uses in my Linux ecosystem I would be OK with it I guess

chat system without "normal" minimize, maximize, close"

bonus for playing web and or mp3 sounds

WOW, we thought the same idea

Whatever you like. I made a web based one years ago. Was fun.

MonoDevelop and/or Visual Studio code then.

daily reminder get used to not using an IDE if you're going to be interviewed

lol what

>using anything but ed and gcc

It happens in other countries too. The main company makes specifications, those get sent to some Pajeet in India and after a month you'll get some code back.

Might not be pretty but who the hell cares as long as it runs and customer pays for it.

apparently when the resume you send to google says "proficient in x", (by x i mean java) they interpret that to mean you don't rely on drop down and autocomplete

ITT: no one can take the average of two ints in C.

I think many people already picked such chatroom projects, I need something better that no one would think of right off the bat, the decentralized VPN seems cool, but I'm not sure I'll be able to pull that off.

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);

just make a structure that holds a numerator and a denominator and some functions dealing with it

lol naruto is so retarded, i can't believe it's still going on. has it been going on for literally so long that now the characters have aged 30 years? .. there's no way naruto's been going that long i remember watching it when i was a kid and all the characters were kids...

Make a raytracer that utilizes adaptive sampling with all threads on a processor to actually make sensibly fast raytracing. Something like:

Ding Ding Ding
Here's your (You)s

Retard time: What's the best software for testing (regression/unit testing), bug tracking and version control?


Since when?

It's no longer a silly kids show with serious moments like YuGiOh or similar.
Now it's just serious all the time and the world is in danger all the time.

the story continues through boruto, the son of naruto.


R8 my implementation

int avg(int x, int y) {
return (x + y) / 2;

No i am not.
C++ can get extremely complicated extremely fast.
Do tell me why what i said previously would happen for C but not for C++, i am actually curious.

Doesn't handle overflow
int avg(int x, int y) {
return (x/2)+(y/2);

Handles overflow

Wrong result for negative numbers

since two days ago

avg(7,7);//returns 6


I didn't say i averaged integers in C.
I just handled overflow for his function.

avg(1, 1) == 0

You're lying. Stop lying liar.

>drop down and autocomplete
Why does this matter at all? It's editor features. Not language features.

They assume things about editors when you talk about a language?
Incredibly arbitrary.

how about
int avg(int x, int y) {
long i = (x + y) / 2l;
return i;


int avg(int x, int y) {
return ((x+1)/2)+((y+1)/2)-1;

long can be synonymous to int.

I made a program who thickens borders and pixels in general, from a bmp map. (in C)
It was a way to improve the bad scan of my map.

Difference is seen with 100% zoom tho.

Oh, the pic is just a sample, the input is the whole map of course (600 mb)

So you basically implemented dilation?

return ((x

Maybe, it loops on every white pixel, if 5 of its neighbors are black, the pixel is set to black. Naive.

>if 5 of its neighbors are black, the pixel is set to black. Naive.
Sounds like the housing estate i lived in during college

do you do 1 pass or more than 1 pass? mind trying to do multiple passes to see if it gets better?

Yes, that's dilation.
I laughed, thanks.

They should have had him burn on a candle and unsummon.

Do it in a swirling pattern from the center.

in haskell this is just
average x y = (x + y) / 2

yep. you're not allowed to use an ide, they let you use a text editor and that's it

>you're not allowed to use an ide
Ok? That wasn't relevant to my post at all though.

a demoscene!

This is a good idea.
Easy to do and just some raymarching would impress all the girls.

It's the equivalent of playing the guitar.

>impress all the girls
>the equivalent of playing the guitar

>This is a good idea.
so this imply you know what is it.

hmmm interesting

>It's the equivalent of playing the guitar.

top sys

Here :
#include "qdbmp.h"

#define NB 8

struct pixel {
unsigned char r;
unsigned char g;
unsigned char b;

unsigned int average(struct pixel *);

main(int argc, char* argv[])
unsigned int i;

BMP* bmp;
unsigned long int x, y;
unsigned char r, g, b;
unsigned long int width, height;

struct pixel t_average[NB];
/* Array for looping on neighbors */
int nx[NB] = {-1, 0, 1, 1, 1, 0, -1, -1};
int ny[NB] = {1, 1, 1, 0, -1, -1, -1, 0};

if (argc != 3) {
fprintf(stderr, "rescan: %s \n", argv[0]);
return 0;

bmp = BMP_ReadFile(argv[1]);
BMP_CHECK_ERROR(stdout, -1);

width = BMP_GetWidth(bmp);
height = BMP_GetHeight(bmp);

for (x = 0; x < width; ++x) {
for (y = 0; y < height; ++y) {
BMP_GetPixelRGB(bmp, x, y, &r, &g, &b);

/* White pixel */
if (r + g + b != 0) {
for (i = 0; i < NB; i++) {
BMP_GetPixelRGB(bmp, x + nx[i], y + ny[i], &r, &g, &b);
t_average[i].r = r;
t_average[i].g = g;
t_average[i].b = b;
if (average(t_average))
BMP_SetPixelRGB(bmp, x, y, 0, 0, 0);

BMP_WriteFile(bmp, argv[2]);
BMP_CHECK_ERROR(stdout, -2);


return 0;

unsigned int
average(struct pixel quad[])
unsigned int i;
unsigned int min_n = 0;

for (i = 0; i < NB; i++) {
if (quad[i].r + quad[i].g + quad[i].b == 0)

if (min_n >= 5)
return 1;
return 0;

If there's cringy shit in it, say it. Really.
And an other sample, pic related.

Not really useful on its own and I'm not sure it fits because I need the network component.

Of course I know what a demoscene is. Who doesn't know what a demoscene is?
It's commonly known even among normal people.
Just have the users of the website each control elements of the scene demoscene.

i forgot about this
a multiplayer nethack game?

Anyone else working this weekend? I'm taking the time to carefully review my code. All my diff requests have tons to review ):

The demoscene is the generalized group of demo makers, as in like second reality, crystal dream 2, heaven 7, etc.

Mathematica seems to deliver more readable text.

Erosion instead of dilation because it treats white pixels as true and black as false.

Maybe there's an open source mathematical morphology library for C out there you could look to for methods.

>Just have the users of the website each control elements of the scene demoscene.
That's the thing I don't think I want to do a web service, just a classic desktop app that would use some web API.

demo as in like second reality*

it's cool user

Wow, that's a very good result. I was giving it a go with my own filters, but didn't get anything measurably better.

I have kind of a stupid question, because i think i already know the answer, but i'd kind of like a second opinion.

1>------ Build started: Project: MyExecRefsLib, Configuration: Debug Win32 ------
1> MathFuncsLib.lib(MathFuncsLib.obj) : MSIL .netmodule or module compiled with /GL found; restarting link with /LTCG; add /LTCG to the link command line to improve linker performance
1>LINK : warning LNK4075: ignoring '/INCREMENTAL' due to '/LTCG' specification
1>main.obj : warning LNK4075: ignoring '/EDITANDCONTINUE' due to '/OPT:LBR' specification
1>MathFuncsLib.lib(MathFuncsLib.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
1>MathFuncsLib.lib(MathFuncsLib.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in main.obj
1>LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library
1>C:\Users\Whitewolf\Documents\Visual Studio 2015\Projects\Test Chamber\Debug\MyExecRefsLib.exe : fatal error LNK1319: 2 mismatches detected
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

What does this mean, and what do i do about it?

Now you're just being picky user. A demo is obviously also a rendered scene, a demo scene in singular.

I'm fairly certain user wasn't talking about the demoscene in that sense. It doesn't even make sense.
You don't have to make excuses, you can say no. Because there's no reason you couldn't do something with a webapi

C people halp pls


This is basic stuff user

I know. It sounded cool when i was 15, and since then it's just stuck.


Jesus, it's amazing.
I'm going to test the speed with the whole map. Thanks user

in sohphomore year of highschool i was on a viking kick and i had wrote in viking runes the word for "elder wolf" on the side of my note paper and the girl behind me in class who was super cute asked me what it was and i told her. i didn't even just brush it off and avoid the question, i told her it was the viking word for "elder wolf"

>Java is one of the most popular languages
how do we fix programming?

at least it's not blackwolf

It's a bit ambiguous. −0.42E7 is probably float and not the string "-0.42E7". So here:
#include "stdio"
int main(){
char a = 'A';
char b;
int n;
float f;
printf("Put B: ");
scanf("%c", &b);
printf("Put 19: ");
scanf("%d", &n);
printf("Put -0.42E7: ");
scanf("%f", &f);
printf("We now have: '%c', '&c', %d, %f\n");
return 0;

I dunno if scanf interprets -0.42E7 as a float or not. If not you need to do more work.

Alright alright, just to clarify, my stupid username is not the bit i'm having issues with, believe it or not.

>printf("We now have: '%c', '&c', %d, %f\n");
Oops. Obviously
printf("We now have: '%c', '&c', %d, %f\n",a,b,n,f);

you're american, what are you doing trying to relate to vikings anyway

You probably didn't even spell it correctly.

Hi guys, I was asking for a good IDE for Java yesterday. I'm a totally newbie but I tried some languages, Java between them, and I think is not bad to start with.

I used Eclipse in the courses, what do you like?

It seems to be your most pressing issue right now user. As it's preventing people from helping you.
What does that have to do with vikings? And anyone if free to write using the runic alphabet. Vikings are inclusive like that.

I'm not, i'm not, and i'm not this guy

net beans

yes you are. i'm your subconscious, kyle. your id


>It seems to be your most pressing issue right now user. As it's preventing people from helping you.
So it seems. This fact is sillier than the username itself.

At least you don't own a $200 plushie of a pony like SOME people in this thread.

So, I have a file with several double values separated by \t (and \n at the end of each line)

How can I make a C program to read each number into a 2 dim array? fscan doesn't work with the \t and \n

well I'm working on my shitty first site.... burn me nisanbahce.com and tell me how can i carry this site to googles first page while throwing bad design issues at my face

>This fact is sillier than the username itself.
No, I disagree. The name is still very silly compared to this situation.

Netbeans and Eclipse are the only i know

i don't know, i ain't a pro Java

I'm messing with /dev/fb0 to do various effects(working on plasma right now, but I can't figure out what format the framebuffer is(might be big endian, since it's an ultrasparc T2 machine.))

How do you know?

rainbow effect

The whole file is too huge sadly

Because he would never forget his trip

What? There existing a plural of $200 plushie ponies in the world is too horrible to consider?

You literally wrote a different function that outputs different values.

Yeah? Well you're a faggot anyway so it doesn't matter what you think.

not an argument

: )


int main()
char a = 'A';

char b;

int c;

float d;

printf("Input the value B ");
scanf("%c", &b);
printf("Input the value 19");
scanf("%d", &c);
printf("Input the value -0.42E7: ");
scanf("%f", &d);
printf("We now have the values '%c', '%c', '%d', and '%f'\n", a, b, c, d);

I get the idea now. In the scanf is the & followed by the variable signifying that this is where we want to store the value?

I know :(
The book is really old though, they give somewhat most ambiguous task with terrible word choice to throw you off. I'm trying with the help of dpt and other supplements

Well, here's another attempt. Still not as good as an erosion filter, though.

Yeah, but the text is far more readable than mine.

How did you do it ?

The & is the 'address of' operator.
You give the address of the variable to scanf so it knows where to put the information it gets back.
It's used in many different situations though. So beware.
&& is logical and
a&b is bitwise and
&a is address of a.
A bit confusing.

I'm not sure what the book had intended for you to use to get input if you don't know about addresses/pointers already.

maybe try with a spacial index and so something like

-insert pixels
-for every white pixel if black pixels in radius > threshold make it black

it's going to be nlogn but maybe going from a square neighbour to a radius search might help

look at nanoflann on github if you need a spacial index for c++

>Hmm I wonder how the standard library does this
>Like how do you use the tools java gives you to read images
>Better look it up
>It's all interfaces and abstract classes
Seriously every fucking time. Does anyone know some blog or youtube channel or something that explains that sort of stuff

That one was a 3x3 blur kernel then a hard B&W filter.

This one is inv -> 3x3 dilate ({0, 1, 0}, {1, 1, 1}, {0, 1, 0}) -> inv.

Sort of the same effect as Mathematica, except a less intense filter (not all 1s) and also not technically an erosion.

Very cool, I'll try in C

Mine is written in C#, but writing a function to apply a 3x3 kernel should be pretty much straightforward.

There was a good page for it, I'll post the link if I can find it again.

I want to check if a number is a prime number

What I'm thinking is check if a number is divisible by 1 and by 2 and nothing else

Is this possible or am I retarded

In java btw

If it's divisible by 2 (and it isn't 2), it's not a prime number

Just check for all previous primes instead of all numbers before it

Whoops is right of course

>there are people right now on this board who aren't using go

Oh yea I meant to type "itself "

They're called "good programmers"

Here's the page on 3x3 kernels: foundalis.com/res/imgproc.htm

do you prefer java and ruby?


!'0' # returns false
!!'0' # returns true
'0' == true # returns false
'0' == false # returns true

>duck typing

You're retarded. Every number is divisible by 1, and if a number's divisible by 2 it isn't prime.

that's weak typing

A friend did an evaluation of go. His conclusion was that it's good for concurrency, and not much else.

Would this be

(number % 1 == 0 && number % number == 0 [What would I put here] )

Trying to figure out this ELK stack bullshit. Thinking about using it for an IoT application.

It is of course possible, the naive / slow algorithm would be to gather all the primes below that number and then check none divide it (and have a base case, e.g. 2 is prime)

I think I know my problem.
I'm a uni dropout (only got to 2nd year), and the uni I went to was very rigorous...
now I can't get shit done without thinking "I should learn things *properly* before doing anything of value", so in the end, I do nothing, because "doing things properly" actually takes time, effort, and doesn't even assure good results.
in short, I can't do things fast because I have a sort of guilt for not knowing things, and can't learn things, because I feel I could be wasting time. the contradiction is killing me.

# isn't a comment in C

Many thanks

Ya'll need to learn about wheel factorization.


it's neither.

>duck/weak typing

>tfw tomorrow I have to give my report about implementing the sieve in a distributed system

Sounds like you're making excuses.

>the naive/slow algorithm

Yes. C is a weakly typed language. All of user's examples are the same for C.

no, it's weak typing.

University is bad at teaching you how to make software well.

>I can't do things fast because I have a sort of guilt for not knowing things, and can't learn things, because I feel I could be wasting time. the contradiction is killing me
there's no contradiction here

I don't see the problem here.

weak typing is when you are breaking the type system. it's not the case here.

>weak typing is when you are breaking the type system
No it's not

>weak typing is when you are breaking the type system. it's not the case here.

>Many thanks

You really ought to thank the guy who brought up erosion/dilation, he was really the winner here.


>These terms do not have a precise definition, but in general, a strongly typed language is more likely to generate an error or refuse to compile if the argument passed to a function does not closely match the expected type. On the other hand, a very weakly typed language may produce unpredictable results or may perform implicit type conversion.

Thanks for the citation user

like i said, it's weak typing

Why do they have whiskers?


Because they can.

Not really. In C, '0' == 48, which is not equal to false/0.

he was posessed by a demon fox

so you're saying that '0' == true returns true?
how intuitive



The fact that would can compare those two different types for equality demonstrates that C is weakly typed.

Does naruto babies have baby foxes in them?
Well he did say false/0. So false in conditional usage and 0 in reality.

c99 has booleans

>something equal to false is truthy, not falsy
Yeah, nothing wrong here

'0' == 0
This always returns false in C

that's not weak typing otherwise operator overloading shall be considered as weak typing.

Weak typing is about if you can circumvent the type system or not. Here an example in C

char b[4] = {'a','b','c','d'};
float *f = b;

The contract that *f is a float and that f is a pointer to float is broken. The soundness of the type system is no more guaranteed, the type system is considered weak.

What PL ?

No they aren't.

Try running Hotspot, Skype, AutoCAD or any other big unmanaged program you know, under drmemory/valgrind and if you don't see a ton of memory leaks and invalid accesses I'll stop doing drugs.

They're not different types. Chars are 8-bit integers in C.

>that's not weak typing otherwise operator overloading shall be considered as weak typing.
It is if it's built into the language, jesus christ. If a language implicitly converts types between each other a lot, it is weakly typed.

In a strongly typed language '0' == 0 would not compile.

if ('0')

if ('0' == true)

These do different things.

I need to make a custom project configuration for Visual Studio, that compiles a library with both debug and release RTLs in one go.

How do?

if (!x)
if (x == false)
should do the same thing

lmao '0' is 48
true is 1
ofc they won't be equal, but '0' evaluates to a true statement

>If a language implicitly converts types between each other a lot
what is "a lot" ? how do you measure that ?


>a evaluates to true
>a == true evaluates to false

depends the semantics of the programming language.

>'0' is equal to false
>'0' acts like true, not false, in conditional expressions

fuck you

>what is "a lot" ?
when most primates can be implicitly converted between one another, it's a lot.


Oh, that IS stupid.

> 1 year into programming
> C#, spent a couple of months trying out C++, C, Python, Java, D, and Go.
> I can now read code and figure out what is going on, at least to a basic degree.
> I am now getting to the point where I can practice on my own and begin to transition into turning my ideas into working code
>Suddenly almost overnight CODING IS FUN

jesus christ what a rush.

Chars are a subset of ints. Of course they can be implicitly converted into ints.

and what are your friend's credentials?

Anyone who thinks unit testing is useless has never written anything past fizzbuzz.

im 1 yo old too
yeah feels ok, though it hits me hard theres so much i dont know

False is synonymous with 0. You just overwrote the key.
>>> int(False)

i know

>False is synonymous with 0
>>> False is 0

>doesn't know how is works
Nice try

no it's not. What made you think that?

new thread when?

>1 year
>6 languages

i wish do things like that

print False*1000

Because that's literally how it works.
>>> d = {0: 1, False: 2}
>>> print(d)
{0: 2}

Bool is a subclass of int
>>> isinstance(False, int)
>>> isinstance(0, int)

this is the last one

New thread:

False gets implicitly converted to a number in order for that to work.

Same here. False is being implicitly converted to a number, because you can't use a boolean as a key in an object.

Please learn programming before coming into these threads.

print True + True == 2

its True

He's very friendly.

Again, True is being implicitly converted to a numer. "+" does not work on booleans, so JavaScript converts the booleans to something it can use "+" on, which is in this a number.

try "String" + True + True in JS. Should come out as "StringTrueTrue" if I'm not mistaken, because the implicit conversion will convert them to strings instead.

In Java I'm supposed to create a program that prints pic related

Am I stupid or is this not possible

I've not figured out a way of writing automated game tester.
Though i've heard the No Man's Sky team have.

This is Python.

nah mate, True is literally an int, as much as it is an object

that's why + works, it's a method

i don't know about javascript



>prime numbers
>that are also divisible by 3 and 5

If it weren't for it's retarded userbase, I might actually try java.

i have one week experience in java a year ago

print 5
print 3


>3 and 5
>prime numbers
>burger education

>3 and 5 aren't prime

Okay so it must have been a trick question or something

Inb4 I fail the assignment

Javas userbase is a reflection of the language.

The assignment said divisible by 3 AND 5 AND a prime number

This. Any Java programmer smart enough to be aware of all the inherent flaws in Java and know about the alternative options, is no longer a Java programmer.

this is a ripoff of /dpt/ prime fizzbuzz

but 3 and 5 are divislbe by 3 and 5
3 is divisible by 3 and 5 by 5

They want a list of primes that are divisible by 3 and divisible by 5, or do they want the union of a list of primes that are divisible by 3 and a list of primes that are divisible by 5.

In the first case {}, in the other case {3, 5}

3 is not divisible by both 3 and 5

>3 is divisible by 5
you wot mate?

I'm almost 100% sure it's the second one

Instead of putting system.out.print("") ;

I put

for(int number = 1; number < 100 && number >= 1; number++){

if(number % 3 == 0 && number % 5 == 0){


//the assignment said prime numbers 1-100 and is also divisble by 3 and 5 which is not possible so i think its a typo


Get a trip so I can block you

What's it like working on a flight simulator?

It's like a big warm apple pie.
PS: this thread is dead