/DPT/ - Daily Programming Thread

Previous Thread:
What are you working on, Jow Forums?

Attached: sicphave.png (603x702, 494K)

Other urls found in this thread:

dailyprog.org/
en.wikipedia.org/wiki/C_data_types#Basic_types
stackoverflow.com/questions/4264127/correct-format-specifier-for-double-in-printf
twitter.com/SFWRedditVideos

Learning linked lists.

Creating an Upwork clone that supports crypto.

Someone suggested I use a programming challenge image to help myself learn better but the only one I see that gets tossed around on here seems to be top level stuff. Does anyone have a baby-tier challenge list?

Attached: 1488522136486.jpg (720x960, 145K)

>there's also NO such reason to NOT get up
Doing things requires effort.

>Any project's you'd like to do?
Not really. I like the idea of robots but even that is just a whim or grabbing at straws.

start with fizzbuzz

Dude. That's literally baby tier

Am I thinking of a different one? If not Ill put it to the test.

Attached: programChallengesV4.png (3840x2160, 1.61M)

it really isn't though.

OP, as another beginner I suggest the easiest katas (i.e. the ones with the highest number) from Codewars

whoa never saw this one thanks

>What are you working on, Jow Forums?
Hacking the VFIO/mdev API in the kernel in order to pass through physically remote devices to a local VM instance.

Attached: Screen Shot 2018-10-27 at 11.11.16.png (2482x1960, 624K)

Wouldn't this be as simple as making an array from 1-100 and saying
for x in array
if (x % 3 == 0) & (x % 5 == 0)
print/cout fizzbuzz
elseif x % 3 == 0
print/cout fizz
elseif x % 5 == 0
print/cout buzz
else
print/cout x
?

Lol, I'm teaching linked lists! Albeit badly.

Here's the code to reverse a linked list on the off-chance one of the people I teach frequents these threads:
ListNode* reverseList(ListNode* list) {
if(list == NULL || list-> next == NULL)
return list;

std::cout next->next = front;
front->next = nullptr;
return front;


>Doing things requires effort
Doing nothing requires mental effort (consciously deciding to not do anything is still making an action).

>Not really. I like the idea of robots but even that is just a whim or grabbing at straws.
So there's literally nothing on God's Green Earth (sponsored by Exxon Mobil) that interests you? Nothing you've seen where you've been so amazed by it you think to yourself "Man, I wish I could do that"?

Lets try that again

Wouldn't this be as simple as making an array from 1-100 and saying
for x in array
if (x % 3 == 0) & (x % 5 == 0)
print/cout fizzbuzz
elseif x % 3 == 0
print/cout fizz
elseif x % 5 == 0
print/cout buzz
else
print/cout x
?

Trying to go through Cormen while writing tests for my data structures. Unfortunately, Im' having a bit of an issue with actually writing the Makefiles.

Here's the structure of my folder:
--HeapFolder
|- Heap.cpp
|- Heap.h
|- Heap_Testbench.cpp


All I want to do is say "Heap_Testbench" depends on the Heap.cpp class and its header file, as well as the BOOST_UNIT_TEST_FRAMEWORK.

However, when I try to compile the Makeifle below:
heap_test: Heap.o Heap_TestBench.cpp
g++ -o HEAP_TESTS -std=c++11 Heap.o -DBOOST_TEST_DYN_LINK -lboost_unit_test_framework

# Compile, but don't link the class (since there's no main function)
Heap.o: Heap.cpp Heap.h
g++ -std=c++11 Heap.cpp -c

clean :
rm Heap.o heap_test

I get an error about there not being any "MAIN" function, despite the unit test not really needing a main function

g++ -o HEAP_TESTS -std=c++11 Heap.o -DBOOST_TEST_DYN_LINK -lboost_unit_test_framework
Undefined symbols for architecture x86_64:
"_main", referenced from:
implicit entry/start for main executable
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [heap_test] Error 1


Any help?

>ListNode*
trash desu

how does one join dailyprog? dailyprog.org/

Attached: daily.png (1439x615, 16K)

Alright, Ill try it for four sets of two digits

>Any help?
You listed Heap_Testbench.cpp as a prerequisite for the heap_test target, but you're not passing it to g++ at all

looks good

This is not okay.
Does anyone actually fail at that?

Methinks there is a bit of a difference in skill level among /dpt/ers

As the scrub who wrote that, I agree. But we all start somewhere I suppose.

Not really. That's kind of the problem.

pls no bully, I need to impart the importance of good naming conventions onto future generations of pgrogramers!

Does the order in which I compile files matter?
I changed the lines to be:
heap_test: Heap.o Heap_TestBench.cpp
g++ Heap.o Heap_TestBench.cpp -std=c++11 -DBOOST_TEST_DYN_LINK -lboost_unit_test_framework


But now I'm getting linker issues (It recognizes that I have a constructor that takes in a function and a vector, but doesn't find the implementation)

Attached: Screen Shot 2018-10-27 at 2.20.44 AM.png (2508x2042, 661K)

The only way you can get better is if you take steps to solve a problem you've identified.
You know not caring about stuff is the problem, so just pick a random thing and mess around with it. Open a math book on linear algebra and start seeing how to optimize equations.
Take a literature course somewhere and then use your newfound appreciation of some asshole from 200 years ago to get into Natural Language Processing.

The cool thing about programming is that you can literally go anywhere with it.
You just have to pick a direction and roll with it.

How about this, are there any problems you want solved? Anything that inconveniences you?

>But now I'm getting linker issues (It recognizes that I have a constructor that takes in a function and a vector, but doesn't find the implementation)
You're mixing object files and source files, which confuses g++ (because it invokes the linker)

Do this instead:

heap_test: Heap.o Heap_TestBench.o
g++ -o $@ $< -lboost_unit_test_framework

Heap.o: Heap.cpp Heap.h
g++ -std=c++11 -o $@ $< -c

Heap_TestBench.o: Heap_TestBench.cpp
g++ -std=c++11 -DBOOST_TEST_DYN_LINK -o $@ $< -c

>Anything that inconveniences you
Not really. If there is it's usually already got a solution or I don't care enough to solve it.

Sorry, the first one should be $^ instead of $

>people want better C
Literally just C with better standard library, like define the fucking API for threading and add compiler flag for
platforms that supports it. Now do the same for directories and file paths, basic data structures for systems that
support dynamic allocation.
Maybe smarter compiler like, recursive macros and type inference.
Saner types without the _t ending so every faggot doesn't have to rename uint32_t to u32 or allow multiple typedefs.
>Solutions proposed
GC
Uglier syntax than ATS
Name mangling
nonstandard ABI
Anything but what people want from C

Employed Haskell programmer here

Attached: 1463364999713.jpg (268x237, 59K)

why are you posting smug anime pictures
this upsets me

>like define the fucking API for threading
What do you mean? Every proper OS supports POSIX threads.

Man... How bad is it?

He means something like C++11 threads (which uses pthreads under the hood), but not the miserable failure that C11 threads which no-one implements.

> every faggot doesn't have to rename uint32_t to u32
ffs do people really do this?

Ya gotta try to meet me halfway here, dude.
Have you ever wanted to make a video game? Do you like art? Do you want to make a weird Mario 64 RomHack that involves computational fluid dynamics?

You clearly don't like the state you're in, but you're not going to fix it by just moaning about how you don't care about anything,

How about this, make it a challenge to get through twenty Project Euler challenges by three days from now.
It's something to work towards, it'll keep you occupied, and you might enjoy it (couple of years ago, I started doing it and I got like 70 problems done).

I've been trying to learn to draw but it's not very interesting. I tried learning japanese but don't really care if I can or not. I've done a bunch of project euler challenges and they were fine I guess. I've been trying things and now I'm trying moaning on the internet to see if that does something.

No, because both WinAPI and sane Loonix headers already defines u32.

Attached: 1453651138545.jpg (601x577, 57K)

I don't want Wintoddlers using my program.
What are some techniques to make my open source program hard to port to Wintendo?

I have no idea what any of this means.

Hmn.... That didn't seem to fix the issue.

And it's weird, because if I place calls to the constructor in a main function in Heap.cpp, it compiles fine... It's just something going on with the linking process that I can't get g++ to work with properly...

Unix utilities man... Can't live with 'em, can't live without them.

Attached: Screen Shot 2018-10-27 at 2.35.09 AM.png (1706x1032, 266K)

Use a bunch of POSIX features, such as pthreads and Berkley sockets. Rely on POSIX file semantics and paths.

You need to clean up the object files first, because it's directly skipping the compilation step.

seek help user

>i don't want sane people using my program
way to go senpai

Use function names that conflict with standard Windows API functions, e.g. "WinMain"

>senpai
Consider suicide.

Okay, that makes sense. I'm beginning to see how to read the output log of make (which isn't quite as good as getting it to work properly, but it's a start!)

So now all the object files are being removed with "rm *.o" and subsequently being recompiled, and the same issue persists.

Attached: Screen Shot 2018-10-27 at 2.41.36 AM.png (1680x1246, 321K)

do not bully your kohai

Attached: 1517689595831.gif (512x512, 639K)

C11 exists.

but I like living and programming an shit senpaitachi

I mean, I don't know what to say. Usually when I'm feeling down, exercising regularly and setting realistic, short-term goals helps me stay busy while I find the next thing to focus on.

Try reading a nonfiction book about birds. You might find something you like. It's either that or re-reading SICP, so choose wisely.

Or better, read SICM!

Attached: sicm.jpg (550x818, 92K)

The compiler hasn't created these symbols. This is a sepples/boost thing now, not something I know anything about.

It basically says that Heap_TestBench.o is calling functions that are declared (in some header or whatever), but that aren't compiled or linked correctly.

Have you forgotten to specialize Heap for ints?

>kohai
>senpaitachi
What the fuck? Go neck yourselves

Use autoconf. They'll commit sudoku before they even launch ./configure.

>Usually when I'm feeling down, I masturbate and do a whole lot of drugs
>got fired from two jobs without warning
>parents won't talk to me
it's like an infinite loop...help me

don't be a retard, everyone writes code in ansi-c and most microcontrollers don't support new standards

ever masturbated in the office my dude?

Attached: 1469324638746.gif (281x281, 743K)

no, but in office restroom

I am actually trying to use hip words like faam and faams, not a weeb

But I heard that anime makes you a better programmer so I am planning to start watch desu.

yes, I've done that
nothing can beat that feeling
masturbate and enjoy a hot cup of coffee doing nothing

>anime makes you a better programmer so I am planning to start watch desu
I need sauce on this one.

You're gonna laugh at this:

I think that because I'm using templated classes, I need to include BOTH the header and the implementation. I'll make an SO post about it, but I just find it funny that simply adding
#include "Heap.cpp"

made it work.

Thanks for all your help, man! I really appreciate it!

Attached: Screen Shot 2018-10-27 at 2.55.47 AM.png (2504x1502, 413K)

what do you nerds think of slavehack 1/2?

jokes aside, the popularity of anime among programmers is truly a social phenomenon that needs to be researched

Alright, made a functioning FizzBuzz in C++. Took me a second to realize I was retarded and found out how to fix it.
#include
using namespace std;

int main()
{
int FB = 0;
while (FB

Anime is popular with lonely people
Programmers are usually lonely
Programmers like anime

i wouldn't say lonely people, i know tons of social people who watch anime

it's usually two types of people

a) the group who tries to fit in with the anime dweebs and ends up enjoying it
b) the group who spends enough time on the internet to force themselves to watch a few eps and become addicted

not really, anime is just popular among internet users in general.

>Programmers are usually lonely
NO!
You've to take this back.
Most of the programmers between age 24-40 I know are married and have couple of kids.

Personally I only sort-of like Anime, have only watched a few Ghibli films.
... but I absolutely love how Anime reaction images subtly triggers some peoplem because it has become associated with narcissism and smugness

Attached: 1539464759703.jpg (838x638, 145K)

I'm bored. Suggest a project I can do that incorporates the C programming language and anime.

{
auto a = mk_unique_foo();
a = mk_unique_bar();
/* ... */
}

doc says that unique_ptr's get destroyed when it gets out of scope. I know bar will be destroyed at the end, but what about foo? Does it also get destroyed when out of scope? Does it get destroyed the moment we assign a with bar?
I would test this myself, but I can't really come up with an idea on how I would test this.

>Programmers are usually lonely
Nah, man.

I think it's an age thing. I'm a boomer (32 year old millennial) and only two-three of my friends I studied with would watch anime. Two of them have since "grown" out of it.

It seems to be very popular among new students (aged around 19-20) though.

Neural network that recognizes Anime and replaces it with pictures of frogs
Add a public API that takes an image URL and returns a different one
Then make a Firefox add-on

Attached: 1486442355985.png (630x630, 88K)

dumb frogposter

Dumb frogposter.

stupid frogposter

Dumb "dumb frogposter" posters

Attached: 1537960079223.png (427x576, 310K)

Attached: a meme.png (400x364, 319K)

...

roll

Why doesn't this work?
int main(void)
{
double fuck;
scanf("%lf", &fuck);
printf("%lf\n", fuck);
return 0;
}

Fuck is a reserved word.

Attached: Capture.png (559x219, 9K)

what's the use of scanf?

en.wikipedia.org/wiki/C_data_types#Basic_types

Is %lf not the correct format for doubles?

Replace %lf with %f

stackoverflow.com/questions/4264127/correct-format-specifier-for-double-in-printf
Learn to google.

Now with
int main(void)
{
double fuck = 1.0;
scanf("%f", &fuck);
printf("%f\n", fuck);
return 0;
}

It outputs 1.0 no matter what.

Show input.

Attached: Untitled.png (288x95, 2K)

The scanf was fine.

Then why is every nigger trying to correct it?