/dpt/ - Daily Programming Thread

What are you working on, Sup Forums?

Previous Thread:

Bootstrap website

Trying to learn OpenGL.

Is he correct?

About stack smashing: I realize why it happened. I had an int main() and I forgot to return a value. I guess g++ does something weird then.

Yes.

I can spread nonsense there without anyone criticising me. Some even agree.

No they're not a reliable source for anything.
As for that particular post it's portraying C as a language that's not something most programmers you should care about don't already know.

pls give me a DES hash of a 4 letter combination
can have upper and lower case letters

She looks disfigured in that picture.
Well done artist.

she? its a blank picture user

>no anime pic
shitto tsuredo desu

ayy boys i made a simple win application

shit tier engine

static void RenderCharacter(
AkarinBackBuffer *buffer,
int x_origin,
int y_origin
) {
int x_size = 40;
int y_size = 80;

//this is how long the width of the window's RGB value

unsigned char *row = (unsigned char *)buffer->memory;

for (int y = 0; y < buffer->height; y++)
{
unsigned int *pixel = (unsigned int *)row;
for (int x = 0; x < buffer->width; x++)
{
if ((x > x_origin) && (x < x_origin + x_size) &&
(y > y_origin) && (y < y_origin + y_size)
) {
*pixel++ = ((255

Working/procrastinating on making a simple turn-based board game in C.
Currently have implemented loading the game board data into a simple linked list. Each node has a list of pointers to other nodes. The board looks a bit like pic related (Scotland Yard), but A LOT smaller and simpler.

Using HMH?

Teach me C++.

I have this:

class MainClass {
void loadMyClasses();
private:
std::list myClasses;
};


I want to access it from a method like this:

void MainClass::loadMyClasses() {
myClasses.push_back(new MyClass("whatever));
}


But it segfaults on me. What do I need to do to be able to intialize and use the myClasses list?

I missed a " in my post, but that's irrelevant to my problem that.

a paint clone in qt

When does the segfault occur exactly?

How does this make you feel?

Indifferent after seeing it n + 1 times already

Nothing because it's not anime.

It doesn't as twitter posters do not qualify as humans.

Somewhere in stl land during the push_back statement.

It's fake. But it's fairly believable because it portrays a novice programmer presenting something to non-programmers.
What's lacking is comments from a bunch of other novice programmers who don't know that they should stay out of those conversations.

This was proven to be fake, so it makes me feel like you people are dumb fucks for believing it.

bored, I've seen this fake shit like 934 times before

based karlie

half
c is important for many things but those things are things that already exist and are documented.

c will be relevant for a really long time so its still smart to learn depending on what you wanna do

no for webdev but working with systems kernels and compilers languages like ocaml sml and c should be necessary

>/* */ comments on single lines
AAAAAAAAAAAAAAAAAA

>Not using /* */ comments for a single line
What a fag.

shit this actually has me lost

shit taste

except groovy doesn't do nested comments so it's actually cancer if you want to comment out a whole lot of code

int i;
for (i = 0; /*no_limits*/; i++) {
if (fact(i) == x)
return 1;
}

It runs fine like this

#include
#include
#include
using namespace std;

class MyClass {
public:
MyClass() {};
};

class MainClass {
private:
std::list myClasses;
public:
void loadMyClasses();
};
void MainClass::loadMyClasses() {
myClasses.push_back(new MyClass());
}

int main()
{
MainClass mainc;
mainc.loadMyClasses();

return 0;
}

Is this true?

Yeah I got it working again. I don't even know what I changed honestly.

What exactly are "property" classes in JavaBeans?

What is meme lately where Sup Forums are discussing languages just so they can ask for opinions on every single Sup Forumsdpt thread?

what if you're using the one true language?
// is a C++ abomination.

>std::list
>Myclass
>new MyClass

that was probably your problem.

Its the same faggot. Every time.

lines = int(input("Please enter length of X"))

for i in range(0, lines):
if i < lines // 2:
print((" " * i) + "x" + ((lines - (2 * (i + 1))) * " ") + "x")
elif i == lines // 2:
print((" " * (lines // 2)) + "x" + (" " * (lines // 2)))
else:
print((" " * (lines - i - 1)) + "x" + (((2 * i) - lines) * " ") + "x")

// was in BCPL.

and ; was used in ALGOL 60.
B used /* */ and thus C used it, The One True Language.

whats an HMH?

Nah, it compiled fine I was just a bit sloppy when I copied it down to post here.

I think I had a pointer to MainClass that wasn't set properly, so it freaked out when I tried to dereference it.

I presume its "handmade hero". babbys first video tutorial into game dev.

well yeah i did follow him but im planning on doing a different game that doesnt use any artwork at all. possibly just square boxes flying around.

// comments do not originate from C++. They originate from C's distant ancestor, BCPL.
Go complain about const if you hate everything that came from C++.

Where did I state that // originated in C++? C99 adapted it after gnu99 adapted it from C++. gnu99 didn't look to "ancestors" for comment syntax, but rather to the "new kid" on the block.

>// is a C++ abomination.

You need to implement new language and it can't have anything that's in C++, what does your language have?

obviously directed towards

C++ is great, with the exception of all the inheritance shit and it being a bit overengineered...

nothing
is that the punchline?

What i mean is, while the code may not be pretty in some cases, the runtime performance against other languages is simply enough of a reason for me to use it.

Just looking for new features that C++ needs

> void
kys.

Just don't use inheritance. I'm not even using it often in C#, why would i use multiple inheritance in C++.

It's just pain in ass

Oh i know, i have used inheritance once so far. I have a Renderer class which i have split in three to wrap my mind around it more easily. But it doesnt impact runtime performance since it doesnt use virtual or other shit. So i use it purely as syntactic sugar :3

MODULES
CONCEPTS
METACLASSES

NOW, C++ COMMITTEE MEMBER-user

first of all use shared_ptr or unique_ptr instead of raw pointers (Myclass*)

assuming the list owns those objects

Don't blindly follow what others tell you to do.

I'm not entirely sure what you mean by "owns" in this case, but they are of no use on their own and will always be accessed through the list. When they are dropped from the list they will be deleted. So I guess unique_ptr makes sense.

should i read K&R before learning c++?

C++ is difficult because it's a clusterfuck. You should learn C (through K&R) and Java before learning C++, and even then you should try to avoid writing it like either of those languages.

Learn C, then program some time in C or other higher level language like this user said don't start learning C++ if you have no experience

Been spending about 8 months making a fully automated python script which uploads DOTA 2 highlight videos to youtube. The goal is to have a passive income source through youtube ads. Its been running for about 2 month now and I have 160 subscribers. I scrape the web to find the best games, parse the replay file and detect interesting game events, use ffmpeg to cut, crossfade and merge those events, add music, generate a youtube thumbnail and upload. I can upload about 20 videos a day. The channel is called RoshanTV Pub Highlights. Will this secure my financial independence Sup Forums?

You should only do what and tell you if you want to be a bad c++ programmer.

x = [1, 2, 3, 4, 5]
y = [1, 3, 4, 5, *x]
y[-1:-3] = 3, 4
print(*y)


What is the output /dpt/?

didnt expect to get non meme answer.
i will read K&R then. thanks.

my longest experience's +-2 month on python, modifying bit of maths and adds some feature in stock analysis program originally by someone else.

currently on lippman's primer, and pointer stuff baffles me.

Well i started with C++ and so far i'm doing ok :3

Also if you want to program high level you probably shouldnt do java... i'd recommend python maybe?

Almost finished codecademy's Python course. Will skim through a few books before I start solving topcoder/hackerrank problems. how long will it take me to git gud on those sites? I plan on learning C and C++ at the end of the year.

recommending python without a meaningful math library like numpy / pandas / jupyter notebook is dooming people to fail.

You either learn python to do serious shit or you're just another faggot copying scripts from stackoverflow

>:3
Found the crossdresser.

unique_ptr would cause the list to own that pointer.
and shared_ptr would be the same (conceptually) as myclass* where once the list deletes it, it'll just remove one from the ref count. but myclass* won't be deleted until the last ref is removed.
weak_ptr is another option, but it depends on if he needs the address, or will just be using it as a reference. and how temporarily the myclass will be in the list

also you should probably never use std::list (a dlist / doubly linked list). std::forward_list (a slist / singly linked list) is what you probably want. but still, you probably should be using an std::vector because it has better cache locality and provides efficient iteration.

Lambdas in C++ look confusing compared to C#

they're not that bad though

learning C won't make learning C++ easier.
K&R will teach you a lot, but it won't be that helpful in learning C++ unless you're totally new to programming

if you plan to only use C++, learning C will be pretty much a waste of your time. if you want to learn C++ pick up a copy of "A Tour of C++" by Bjarne Stroustrup. Or his book "Programming: Principles and Practice using C++". Or "Accelerated C++" by Koenig and Moo.

but if you're learning about programming, and want a good introduction K&R2 is an excellent book. plus, you'll learn C which is quite useful in itself.

I want to go back to using lisp. Now, I'm more of a scheme guy since lisp is pretty damned shit for functional programming (its support for hof is horrendous even just because of function/funcall, but that also means people have strayed away from anything hof as a result), and beside, hygienic macros are infinitely better than the almost-c-style lisp macros.

But since sbcl is otherwise so good and racket is so shit despite being the best scheme implementation (notable mention: chicken, though), I can look beyond that.

Instead, what I'm looking for, is better control over the gc. For example: is it possible to (without-gcing) the entire program and to (gc) at appropriate times inside the (without-gcing)'d program to do almost-manual memory management? Object pools seem to be extremely slow, is there a way to fix them? Are there bounded-time GC options for SBCL? Non-stop-the-world ones?

Generally yes. Though some big libraries are hard to bind to other languages and thus you need either C or C++ knowledge to work with them. In that case, though, you'd be significantly better served by writing bindings for them and using a non-shit language. In the case of rust, which is runtime-free, it is viable for all applications C is used. Even on pure technical grounds, it's often even better than C. And of course in terms of usability and programmer time it's superior always.

I switched to std::vector, and now I'm getting segfaults on program exit. Here's my main

/* ... */

std::cout

please post whole code somewhere

-w-
Oh i have no idea, i just think java is cancer :3

>And of course in terms of usability and programmer time it's superior always.
You didn't have to add this for us to notice you were baiting

Can't spell cuck without c.

found the rust programmer

My tea's gone cold, I'm wondering why I got out of bed at all
The morning rain clouds up my window, and I can't see at all
And even if I could it'll all be gray, but your picture on my wall
It reminds me that it's not so bad, it's not so bad at all

I'm trying to understand the memory usage of simple arrays. Besides the data itself, what control data takes up memory?

Wikipedia had the following to say:
>The amount of control data required for a dynamic array is usually of the form K + B ∗ n {\displaystyle K+B*n} K+B*n, where K {\displaystyle K} K is a per-array constant, B {\displaystyle B} B is a per-dimension constant, and n {\displaystyle n} n is the number of dimensions. K {\displaystyle K} K and B {\displaystyle B} B are typically on the order of 10 bytes.

i have no idea of how shit works and i thought that reading a book about "how computer works" would be boring.
in this case, i think K&R would be helpful.

>python
already i am, focused only on finance at first because currently major on it.
but then i plan doing it on C++

in what language?

>Rust programmer

Such people don't exist. Rust is a meme language not used in real life.

Some large companies such as Oracle wrote code in Rust and even published it, but guess what? Large companies do this all the time. They use new meme languages for fun.

Everyone will forget Rust and continue shitcoding in C/C++ getting segfaults. Just like it was with D and other "C++ killer languages".

Deal with it.

Good >:3

I should've mentioned: Java (not using ArrayList or anything built-in)

I'd actually use Rust over C++ but the language is far more complex than C++ itself.

>Rust is a meme language
Oh i do agree mate, played with it a bit and it simply has no future (At least as a C++ killer)

D has a forced GC, it never was a "C++ killer language". Rust is not only already faster than C++ and free of memory issues, it is also runtime-free, something that has bottlenecked C++ on small devices since the beginning.

>Java
REEEEEEEEEEEEEEEE