[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: himegoto.jpg (407 KB, 600x800) Image search: [Google]
himegoto.jpg
407 KB, 600x800
old thread: >>51768129

What are you working on, /g/?
>>
Old thread is still on page thread, delete this.
>>
First for Adventofcode

Any ways I can make my day 9 solution look shorter and sweeter? Other than the obvious putting initializers and setters in one line

from itertools import permutations

with open("Advent9.txt") as myfile:
data=myfile.read().split('\n')

distances={}
locations=[data[0].split()[0]]

for i in data:
if i.split()[0]==locations[0]:
locations.append(i.split()[2])

for i in data:
words=i.split()
distances[(words[0],words[2])]=words[4]
distances[(words[2],words[0])]=words[4]

shortDist=9999
longDist=0

for routes in permutations(locations,len(locations)):
currDist=0
for i in range(len(locations)-1):
currDist+=int(distances[(routes[i],routes[i+1])])

shortDist=min(shortDist,currDist)
longDist=max(longDist,currDist)

print shortDist
print longDist
>>
>>51775098
*still on page 3
>>
>>51775098
Page thread? Well, this thread is on page post.
>>
first for gay D
>>
>>51775084
One day the OP pic will be programming related but I guess this is fine
>>
>>51775133
I made a typo, you posted this new thread too early.
>>
>>51775108
>Python
Cheating.
>>
Working on how a bag works in game engine I'm creating
So far its bretty gud
void RemoveItemFromBag(Items the_item)
{
if (!IsBagEmpty())
{
for (int i = MAX_ITEMS; i >= 0; i--)
{
if (bag.items[i] == the_item) // Find the slot that has the item were looking for
{
bag.items[i] = None;
bag.size--;
return;
}
else
{
continue; // Skip to the next slot in the bag from the top
}
}
}
else
{
printf("Bag is empty!\n");
return;
}
}
>>
>>51775155
x = anon==faggot
print ["Python is cheating", "Python is not cheating"][x]
>>
>>51775084
Who is this cute girl?
>>
>>51775155
>not using python
Autism.
>>
http://adventofcode.com/day/3

Where on the grid should I be starting out exactly?
>>
Whats the better VM to install linux on for programming? Zen or Virtualbox?
>>
>>51775244
Virtualbox works fine
>>
>>51775234
It doesn't really matter mate, solution will always be the same. Just set it as 0,0
>>
>>51775258
Problem is that gives me a range violation because it goes out of the bounds of my array.
I just started at the center, gave me the correct solution
>>
>>51775234
i made a 500x500 array and placed santa at position 500/2 for x and y.
>>
>>51775273
>using an array
You could just use a set of coords, which is the most efficient, or a dictionary otherwise
>>
>>51775084
Anons, what can we do about this anime problem?

It's ruining my chan experience.
>>
>>51775234
Python is cheating:
def day03(data):
def solve(moves, house=(0,0)):
move = lambda (x,y), d: {'^':(x,y+1),'v':(x,y-1),'<':(x-1,y),'>':(x+1,y)}[d]
houses = set([house])
for direction in moves:
house = move(house, direction)
houses.add(house)
return houses
print("Part 1: {0} different houses".format(len(solve(data))))
print("Part 2: {0} different houses".format(len(solve(data[::2]) | solve(data[1::2]))))

Pulled this off reddit. I don't browse the place, but it's where everyone's posting their solutions
>>
>>51775299
you can try going back to reddit
>>
>>51774697
int main()
{
ayyy(lmao);
}

void ayyy(void (*f)())
{
lmao(f);
}

void lmao(void (*f)())
{
ayyy(f);
}
>>
File: get-out.png (319 KB, 600x480) Image search: [Google]
get-out.png
319 KB, 600x480
>>51775346
If you're not a weeb, you don't belong here.
>>
>>51775299
Become one of us.
>>
Any other good short programming challenges other than adventofcode and project euler? codeforces and the like are too time-consuming and I spend too much time in my IT job to make full use of it
>>
File: GARRY.jpg (13 KB, 150x150) Image search: [Google]
GARRY.jpg
13 KB, 150x150
>>51775084
Getting over sickness, then going back to learning Java.
>>
>>51775386
codeeval is pretty nice, i've been teaching myself how to tackle problems using it.
My first attempt at the fizzbuzz challenge took me 5 hours.
The last challenge I submitted took me 4 minutes.
>>
So how good is code::blocks?
>>
>>51775415
More like code::cocks lol
>>
>>51775374
Coon, coon, black baboon
Brutal, worthless, thieving goon
Often high, thrives in jail
His welfare check is in the mail
Some 40 offspring have been had
But none will ever call him dad
And yet he hollars, day and night:
"I blame the white man for my plight.
He spreads his trash around my shack,
It's him who makes me smoke this crack
He pushed my kind to burn and loot
And sends the po-lice that we shoot
But inch by inch we're taking hold,
Like when the white bread starts to mold
We'll overrun your homes and soon
They'll only be fit for the black baboon.
>>
"
>>
File: into le trash.jpg (262 KB, 800x800) Image search: [Google]
into le trash.jpg
262 KB, 800x800
>>51775374
>you're a normie if you aren't a weeb
You don't have be weeb to be not a normie
>>
>>51775444
>>
>>51775414
I tried codeeval before, but I kept failing, with no output

How do you format your input so you get the input through correctly?
>>
>>51775426
whats wrong with it??
>>
>>51775456
Have you tried testing it on your machine?
It should work just as well using their test input.
The instructions are pretty clear.
On most challenges, the instructions ask for a command line program that accepts a filename as the first argument and reads it's data line by line.
The example code even gives you a basic template for opening a file and reading out it's contents in whatever language you want.
>>
>>51775490
Oh went on it, and it looks different to the site I couldn't work with. I'm an idiot, but thanks anyways m80
>>
I'm just getting started learning programming. Do I really need an IDE at this point?
>>
>>51775587
No, just use Vim.
>>
>>51775587
N A N O
A
N
O
>>
File: 1446590110179.jpg (219 KB, 1000x1502) Image search: [Google]
1446590110179.jpg
219 KB, 1000x1502
>>51775084
>>51775138
>>51775299
pic related

>>51775244
virtualbox works fine for me. I don't even bother figuring out what's the equivalent vmware software since there are a fuck load of different products

>>51775386
https://screeps.com/
https://www.hackerrank.com/

>>51775587
no, you need to focus on programming and not on figuring what the hundreds of features of the IDE are supposed to do
>>
>>51775587
Not really but it depends on the language.
If you're learning a .NET language there's no reason to not get visual studio right away.

>>51775612
I'm coming for you yui!
>>
post your best anti-oop memes
>>
File: 1426357554598.png (152 KB, 1948x858) Image search: [Google]
1426357554598.png
152 KB, 1948x858
>>51775673
>>
File: smileandoptimism.png (345 KB, 640x480) Image search: [Google]
smileandoptimism.png
345 KB, 640x480
>start to learn C++
>get fucking pumped, I just did a fucking calculator holy shit
>slowly realize all I'm doing is worth nothing
>look at other people's calculators and see how they made them in like 30 lines of code while mine took double the lines
>can't understand the commands they use
>can't do shit, get depressed because I'm shit at everything

I just wanted to be a dev and have fun while devving.
>>
>>51775612
>https://screeps.com/
>https://www.hackerrank.com/
top lad
>>
>>51775694
>Left pane
>What your professor told you about binary trees
>Right pane
>Putting it into practice
>>
>>51775704
I bet you can't even write a tokenizer that takes arbitrary number of numbers and operands and returns the result.
>>
>>51775704
Just write it in Lex and Yacc
>>
>>51775704
Your post doesn't make any sense.
Keep learning, google the stuff you don't know etc.
Did you seriously expect to learn everything there is to learn about programming in the weekend or whatever it took you to make a calculator?
Besides you had fun so why quit now?
>>
>>51775704
Just use Python m8
>>
>>51775704
post both programs
>>
>>51775779
Do your own homework
>>
>>51775848
I deleted mine in a heap of frustration (It barely worked anyways, so nothing of value was lost) , but let me show you the program I found this for example https://github.com/bhamodi/Matrix-Calculator/blob/master/Matrix_Calculator.cpp

It adds a crapload of shit in 300 lines while I only had the 4 basic calculation types while mine took like 70 lines and didn't even work 100% right.
>>
>>51775915
Oh wait, I actually found it in my trashcan.

http://pastebin.com/RRTGSCaQ
>>
>>51775915
That code still looks disgusting. Could probably be a quarter the lines or less of code in python

>tfw 40 line programs when I started become 1 line programs the more I learn about its core library and functionality
>>
>>51775947
Thats because python is the better language. You have to be fully autistic to use C in this day and age.
>>
>>51775929
And it didn't even took 70 lines, holy shit it took more. Fuck my life.
>>
How do I generate an md5 hash in C?
Do I just import <openssl/md5.h> or something?
>>
>>51775929
>http://pastebin.com/RRTGSCaQ
don't worry mate, everyone started out like that
keep building stuff, it took me atleast a year of building stuff to learn enough about abstractions to find atleast decent solutions
>>
Memes aside, do you believe C++ "better" than Python or the other way around? Why you believe that?
>>
>>51776002
Honestly, C/C++ is better than python. You learn a lot more from C/++ than you do for python.
>>
>>51776002
use case dependent
if we ignore c++'s obvious use cases then python would be the nicer language to program in
that doesn't mean it's the better language in every use case, though
>>
>>51775968
The problem with your code is repetition
Extract and use the common/similar parts into a central place and the number of lines (if that is what bothers you) will be reduced radically!
>>
>>51776002
I believe Python to be better for most use cases, but for the few others, using Python as an extra will only help your C++ code
>>
Doing
http://adventofcode.com/day/4

import std.stdio;
import std.string;
import std.conv;
import std.process;

void main(string args[])
{
File file = File(args[1], "w");
string line = "iwrupvqb";
int i;

for(i = 0; i < int.max; ++i)
{
file.write(line ~ to!string(i));
auto result = executeShell("md5sum test");
if(!result[1][0] && !result[1][1] && !result[1][2] && !result[1][3] && !result[1][4])
{
break;
}
file.write("\r");
}

writeln(i);
}


God bless bruteforcing
>>
>>51776053
>God bless bruteforcing
Well that's how you were supposed to approach the problem. The creator clearly wouldn't expect people to sit on terabytes of rainbow tables.

Also
>executeShell("md5sum test");
Are you retarded? Your program spends more time spawning & waiting for a termination of a process than doing the actual thing. How long does it take for it to find solution for this input? Mine does in 0.5 sec.
>>
>>51776053
>>51776100
Also
>writing to file with each iteration
Yet another pointless bottleneck.
>>
File: appenginegophercolor.jpg (158 KB, 1431x901) Image search: [Google]
appenginegophercolor.jpg
158 KB, 1431x901
Any gofags around? Need help with setting up a web server. Here's what I did so far:
>install Go
>create the following file in my workspace:
package main

import (
"fmt"
"net/http"
)

func handler(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Hello, world!")
}

func main() {
http.HandleFunc("/", handler)
http.ListenAndServe(":8000", nil)
}
>compile
>run
And now when I try to access my VPS at http://<IP-address>:8080/ all I get is ``Unable to connect'' errors.
>>
>>51776141
>8000
>8080

Gofags everyone.
>>
>>51776153
Just a typo, matey. ;^)
>>
>>51775704
don't ever get caught up on what other people are doing otherwise you'll lose focus on yourself.
>>
>>51776134
Did you implement your own md5 algorithm?
>>
>>51775084
If your language doesn't have automatic or symbolic differentiation included, it's deprecated. If your language doesn't have a differentiable renderer, it's shit. Threadly reminder: probabilistic programming languages are the future.
>>
>>51776199
No, and neither should you.

http://dlang.org/phobos/std_digest_md.html
>>
File: facebook frog.jpg (40 KB, 500x350) Image search: [Google]
facebook frog.jpg
40 KB, 500x350
>working on a personal project instead of studying for my exam in 12 hours
>>
How do I read Linux and Windows' system specs with C++? I want to do a simple console-based specs reader.
>>
There must be a sexier way to do the md5 problem in python:

import hashlib

i=0
while True:
string="ckczppom{0}".format(i)
m = hashlib.md5()
m.update(string)

if m.hexdigest()[:5]=="00000":
print i
break
else:
i+=1
>>
>>51776212
oh fug, thank you.
>>
>>51776141
assuming the ports are correct:
clearly not an issue with go but with your vps
try it on your machine, it works
>>
>>51776233
On Windows you need to go through MSDN and find relevant garbage from WinAPI that suits your needs, for Linux I guess sysctl will do.

>>51776268
Even if it wasn't in the standard, you'd have been better off by importing third party lib (that woulda taken less time to plug in than for your script to execute). A buddy o' mine made the same mistake, except for bash, and he needed over 7 minutes of running his script to get the correct hash, while for the same input, a simple Lua solution I wrote using luacrypto solved it in about 0.68s~ (don't even get me started on the second part of the challenge).

>>51776254
Something like this?

import hashlib
input = 'ckczppom'

for i in range(__import__('sys').maxint):
if(hashlib.md5('{}{}'.format(input, i)).hexdigest()[0:5] == '00000'):
print('Solution: {}'.format(i))
break


>>51776167
So was that the actual problem or just a typo in your post?
>>
Realistically speaking, what are the chances that I can get employed as a developer if I'm self taught python and objective-c/swift? I have a university degree in political science and have been programming for some time now but don't have a cs degree.
>>
Am I misunderstanding AoC day 4?
The instructions say the hash of "abcdef609043" should start with 5 zeros, but all I get is
$ md5sum <<< 'abcdef609043'
db7c07cb46dff89d8118d537336303ed
>>
>>51776336
>maxint, and the rest
Off fucking course, forgot to use it on the latest day 9 challenge too, using an arbitrary 9999 instead. Thanks m8
>>
Haven't programmed much after graduating. I got a job on wing field entirely and been too lazy to do something about it. Now I'm trying to get back in the game. I try to come up with projects to work my skills. Some things come back easily, others I need to really work. At the moment working on how make an object to follow mouse pointer. Time is scarce resource, because of work and a baby, so progress is slow. Well I need to first work out the math and basic order of things to happen so I can work on those anywhere really.
>>
1 MONTH
1 PROJECT
1 C++

WHAT SHOULD PROJECT BE
NOTHING BEGINNER OR BORING


thanks,
>>
>>51776328
Figured as much. Stopped the firewall and it works like a charm.

>>51776336
>So was that the actual problem or just a typo in your post?
It was just a typo. The problem turned out to be the firewall. I have to configure it properly now.
>>
>>51776444
>baby
kek
>>
>>51776444
>graduating
>baby
congrats

What language/library?
Just having something follow the mouse pointer should be really simple unless you're using a very barebones approach, like just using xcb and opengl
>>
>>51776444
>cumming inside
>ever
at least you have trips
>>
>>51776454
A fully functional operating system based on GNU Hurd.
>>
>>51776444
Learned embedded-C and Symbian, but the latter died very quickly after graduating (am a Finn-fag, so it was all the latest hot thing with Nokia, but they ditched it for windows and then ditched the whole phone industry). I'm going to get pi-zero when they get those restocked and try get something done with that as well.
>>
>>51775929
add=lambda x,y:x+y
subtract=lambda x,y:x-y
multiply=lambda x,y:x*y
divide=lambda x,y:x/y
power=lambda x,y:x**y
funcs=[add,subtract,multiply,divide,power]

print "1 - Add"
print "2 - Subtract"
print "3 - Multiply"
print "4 - Divide"
print "5 - Raise X to the power Y"
print "\n0 - Quit"

while True:
selection=input("\nEnter a selection, please: ")
if not selection:
break

print "\nYour choice is: "+["ADD","SUBTRACT","MULTIPLY","DIVIDE","RAISE X TO THE POWER OF Y"][selection-1]
num1=input("Please choose your first number: ")
num2=input("Please choose your second number: ")
print "Your result is: {0}".format(funcs[selection-1](num1,num2))
>>
>>51776493
too hard
>>
>>51776481
C# with visual studio. So all the bells and whistles for starters. Graduated 8 years ago and baby is 7 months now.
>>
>>51776454
AI for the game Go
>>
Anyone else often find themselves wanting to program but lacking motivation? I can never seem to finish any of my own projects, I just get bored before it's done.

I can't sit down and code all night like I used to be able to, it just feels so lonely now... Maybe if I find some open source projects to contribute to or something.
>>
>>51776559
YOu have to have project ideas that you are passionate about; that's one reason why asking for ideas online isn't a good idea, as one is usually more passionate about their own ideas

>>51776549
sounds boring
>>
>>51776559
Define a scope for your projects that fits a 1-dev team. For the scope think how long the project will take you and multiply it by 2.5. If the time to complete it is too long, narrow down the scope. This way you get a project which you'll actually finish.
>>
File: gnu.png (81 KB, 800x472) Image search: [Google]
gnu.png
81 KB, 800x472
Playing with Boost.Coroutines. Boostfags caring to reproduce my bug?

#include <boost/coroutine/all.hpp>
using coro = boost::coroutines::symmetric_coroutine<void>;
int main() { coro::call_type([&](coro::yield_type& yield){ yield(); })(); }

ends in
terminate called after throwing an instance of 'boost::coroutines::detail::forced_unwind'
on Parabola GNU/Linuxlibre x86_64 with Boost 1.58 and g++ 5.2.0 (C++11). This happens when the temporary coroutine object is destroyed, it seems. Normally, Boost should catch their own fucking exception internally, as it is just meant to unwind the user's stack, as the name implies, but when using the void specialization, it goes all the way up and I don't see why.

When using the base template, the program terminates :
#include <boost/coroutine/all.hpp>
using coro = boost::coroutines::symmetric_coroutine<int>;
int main() { coro::call_type([&](coro::yield_type& yield){ yield(); })(42); }


And if I throw the exception myself, it apparently catches it :
#include <boost/coroutine/all.hpp>
using coro = boost::coroutines::symmetric_coroutine<void>;
using boost::coroutines::detail::forced_unwind;
int main() { coro::call_type([&](coro::yield_type& yield){ throw forced_unwind(); })(); }


But I can catch it myself :
#include <boost/coroutine/all.hpp>
using coro = boost::coroutines::symmetric_coroutine<void>;
using boost::coroutines::detail::forced_unwind;
int main() { coro::call_type([&](coro::yield_type& yield){ try { yield(); } catch(forced_unwind) {} })(); }


I tried following the program with gdb, but the throw expression seems fine, yet it doesn't ever reemerge under the catch. What is going on, /g/?
>>
>>51776584
Exciting for me, still learning Go though.
>>
I'm not a hardcore programmer but I'm on a project that consist of obtaining a heart rate measurement from an analysis of the rgb planes of a persons's forehead. I'm rather stuck at the fft and filtering. Its on C and C++ and its based of a paper from MIT. I use some algorithms (namely ICA and some opencv processing for detection). I cant seem to find a suitable library with fft and bandpass butterworth filtering. And I suck at coding math algorithms. Dammit. Also opencv's dft() is either disfunctional for nonimage processing or I just dont get how to use it. Damn late year projects.
>>
nothing, waiting for saturday to go to my commencement, then waiting for advisement for master's program

dunno if prof wants to continue research through the winter break or not, probably though, hope so, it'll give me something to do
>>
Holy shit, why is Qt so great to program in?
Every line I write just feels so yummy, and the resulting program always looks so polished. WPF programming in C# never felt this good, even though C# was much better to write than C++.
>>
>>51776706
What are you working on?
>>
>>51776706
Ever tried QML senpai?
>>
>>51776721
A simple text editor (nothing fancy [yet!]) just to get myself familiar with the framework, and I'm loving it so far.
>>
>>51776214
this

its a compsci exam too
>>
>>51776738
Noice.
>>
>>51775970
Yes, but MD5 sucks/has known collisions. If you can, use SHA-256 or SHA-512.
>>
>>51776756
All right theory time.

If you theoretically had two messages that had the same MD5 sum, would the base64 encoded versions of the original messages also have the save MD5 sum?
I assume not, right?
>>
>>51776779
No unless by some miraculous conicidence they happen to also collide.
>>
File: iDidAThing.png (36 KB, 576x412) Image search: [Google]
iDidAThing.png
36 KB, 576x412
Why do you guys hate Python? It's not perfect but it's not shit either, it's actually pretty comfy.
>>
>>51775084

WHO IS THIS EJACULATE EXTRACTOR

Give source?
>>
>>51776833
Only some people hate Python, and only some people pretend to hate Python. I write Python 3
and C and they're both good in their own ways.
>>
>>51776833
RE LEVANT
E
L
E
V
A
N
T

WHITESPACE
H
I
T
E
S
P
A
C
E
>>
>>51776833
import program
program()


Look mom I'm a programmer!
>>
>>51776875
Epic meme
>>
I'm working on a Plex/Backup server from old spare parts I have.

I've got an old PC based camera server that died. The case is rack mountable, is full of fans, and has plenty of room for adding HDDs.

It had a a 1 TB and 250 GB HDD in it, but I'm pretty sure they are fried. Both the mobo and PSU were completly shot, and the HDDs aren't showing up on the PC I'm testing them in. I'm guessing there must of been a surge that went through and fried everything in it.


I did swap out the board and could get a liveUSB to boot, so I'm getting somewhere. I might have to stick with a couple crappy small HDDs for now though.
>>
>>51776875
>reinventing the wheel
>>
import std.stdio;
import std.conv;
import std.digest.md;

void main(string args[])
{
string line = "iwrupvqb";
int i;

for(i = 0; i < int.max; ++i)
{
ubyte[16] result = md5Of(line ~ to!string(i));
if(!result[0] && !result[1] && !(result[2] & 0xF0))
{
break;
}
}

writeln(i);
}


Literally a 1000 times better
>>
>>51776894
>buying a car and saying you built a wheel yourself
>>
>>51776899
is this go or rust?
>>
When will the fucking "Language A vs Language B" meme fucking die off?

Seriously, both C hate and Python hate are annoying as fuck.
>>
>>51776917
D
>>
and I'm an idiot, didn't realize this was a programming thread
>>
>>51776917
That's D - the superior alternative to both Rust and Go.
>>
>>51776902
>being concerned about how special others think you are rather than getting things done

There's a time for implementing new shit in C and Python, and there's a time for importing that shit and actually using it. Both are completely legitimate depending on what you're doing.
>>
char cmd[100];
sprintf(cmd, "%s %s%d | %s | %s", "echo -n", key, num, "md5sum", "awk '{print $1}'");
FILE *shell = popen(cmd, "r");


Why am I getting a "warning: initialization makes pointer from integer without a cast" on the popen?
>>
>>51776899
I can do you one better.
Public Sub Main()
Dim line As String = "iwrupvqb"
Dim I As Integer
For I = 0 To Integer.MaxValue Step 1
UByte(16) Result = System.Text.Encryption.Encryptor.MD5(line)
If Not Result(0) = DBNull And Not Result(1) = DBNull And Not Result(2) = DBNull Then
Break
End If
Next
System.Console.WriteLine(i)
End Sub
>>
>>51776894
>Try to make a basic console-based system stats reader
>spends hours trying to find how to do it con C++
>say "fuck it" and try with python
>import platform
>import sys
>import os
>get it done in minutes

Fuck you and your "BUT I CAN SHOW OFF I MADE IT MYSELF!!!!", efficiency and getting shit done is better than spending months to make basic bullshit.
>>
>>51777011
>python
>efficiency
>>
Feeling like a king having just implemented delimited continuations in my language. Was tough as fuck though, the whole CPS transformation thing and so on.
>>
>>51777023
>spending hours to make something basic
>efficient
>>
>>51776989
Stop using garbage language to solve a problem with garbage solution.
>>
>>51777008
That looks exactly the same as mine
>>
>>51777008
>if(!result[0] && !result[1] && !(result[2] & 0xF0))
>If Not Result(0) = DBNull And Not Result(1) = DBNull And Not Result(2) = DBNull Then

Are you sure that they even do the same thing?
>>
>>51777110
In VB.NET you can't Not a non-boolean value. Arrays start out filled with null and in VB.NET the only way to 'get' a value equal to null is to reference DBNull.
>>
>>51776989
Are you doing anything that would cause popen to not be defined in stdio.h?
"-std=cXX" or compiling on Windows etc.
>>
>>51777049
Not making something is in no way more efficient than making something slowly.

By python users' logic, downloading Windows is a more efficient method of system programming than writing a kernel in C.
>>
>>51777148
I'm using -ansi flag.
>>
File: Capture.jpg (103 KB, 872x1074) Image search: [Google]
Capture.jpg
103 KB, 872x1074
Assembly Language.

I'm having trouble understanding why I'm having a conflicting parameter definition error. Anyone care to point it out to me? And for reference, the point of this program is to get 3 numbers, compare them, and if any of them are the same then move 0 into EAX. Otherwise, move 1 into EAX.
>>
I can't into tkinter

Help
>>
>>51777161
Then glibc isn't going to show the POSIX functions.
Add -D_POSIX_C_SOURCE=200809L or something to your compile command or something.
>>
>>51777214
Use Qt.
>>
File: 1418666399599.png (264 KB, 1000x1000) Image search: [Google]
1418666399599.png
264 KB, 1000x1000
What language should I use?
I want something that could be used with everything.
I also want something that isn't complicated like C.
>>
>>51777226
C isn't complicated.
>>
>>51777226
>I also want something that isn't complicated like C.
C is not complicated at all. In fact, it's pretty simple.
>>
>>51777226
python
>>
>>51777226
C is actually one of the easiest languages. The stdlib is so small, you memorize every function it has. Unlike what others say, pointers are really easy to understand.
If you want to be a normie, go for C#.
>>
>>51777226
C is one of the simplest languages out there.
Any simpler and you might as well be using Scratch.
>>
>>51777220
yeah it works without any errors
Is this like an autistic form of -std=c11?
>>
File: 2015-12-09 15_41_53.png (103 KB, 394x369) Image search: [Google]
2015-12-09 15_41_53.png
103 KB, 394x369
Hi, dpt. I'm looking for a program that can clip an image into hexagon tiles.
I achieved pic relateds square tiles using imageMagick but as I am new to
the program and not very familiar with any graphic design software, I'm
hoping someone here will be kind enough to offer some suggestions.
>>
>>51777226
obvious answer is "whatever you need to at the moment", but i guess it won't work

Since you consider C "complicated", you probably want something that will prevent you from fucking up memory allocation and shit. Therefore, try Java. Java is more than enough for your everyday programs, and it's on level high enough that everything you need to think about is logical structure of your program.
>>
>>51777246
>>51777239
let's say I want to set a variable to say "hello"
Here's what I can do:
char * mytext = "hello";

Why should I have to do shit with the memory address I just want to use a string
char mytext[] = "hello";

a fucking table are you kidding me

it feels like I'm working directly with the processor which, surprisingly to me, the processor is super dumb, and makes me appreciate the effort put into high-level languages
>>
>>51777226
Python or scheme

>>51777246
>C is not complicated at all. In fact, it's pretty simple.
>simple
you mean simplistic
>>
>>51776989
Either key or num are ints, and you're trying to pass them as a character pointer. You have a five format specifiers there but you have only supplied four on the right hand side. You should be getting a warning about format strings not matching.
>>
idea for website, game, utility
>>
>>51777299
>Why should I have to do shit with the memory address
Because strings have variable length.

>a fucking table are you kidding me
People typically don't use array syntax when they mean pointers.
>>
Why isn't this code working?
void MainWindow::on_Save_clicked()
{
QFile file(path);
QByteArray data;
if(!file.open(QIODevice::ReadOnly | QIODevice::Text)) return;
char dataArray[this->ui->editorWindow->toPlainText().length()];
memcpy(dataArray,this->ui->editorWindow->toPlainText().toStdString(),this->ui->editorWindow->toPlainText().toStdString().length());
file.write(dataArray,this->ui->editorWindow->toPlainText().toStdString().length());
}


The error is: ``cannot convert 'std::string {aka std::basic_string<char>}' to 'const void*' for argument '2' to 'void* memcpy(void*, const void*, size_t)'''

What am I doing wrong?
>>
>>51777299
Because in C, strings don't exist.
They're just arrays of chars.
Your bottom example initializes a char array with the string "hello".
>>
File: IMG_20151209_134617.jpg (2 MB, 4160x3120) Image search: [Google]
IMG_20151209_134617.jpg
2 MB, 4160x3120
C is not complicated, but people can do silly things with it.
>>
>>51777172
Copypaste the output error dude. I'm not a frriggin compiler. Line?
>>
>>51777291
>Hi, dpt. I'm looking for a program that can clip an image into hexagon tiles.
Imagemagick
>I achieved pic relateds square tiles using imageMagick but as I am new to
the program and not very familiar with any graphic design software, I'm
hoping someone here will be kind enough to offer some suggestions.
read the documentation or some tutorial and learn how it actuallly works
>>
>>51776833
It's absolute garbage. It's inconsistent as shit, it's slow as shit, it's slow in inconsistent ways (code in function followed by function() is much faster than code in file; comprehension is much faster than loops), it does retarded shit such as for loops and comprehension capturing and modifying variables in the enclosing scope as part of the initialization-test-incrementation constructs when it should make its own namespace and so on and so forth.

Also, FUCKING WHITESPACE. If you think whitespace is good in any way, you have never worked with other people on python code, or even across different tools.
>>
>>51777283
No. The GCC -std=cXX" options won't show the functions that are not part of standard C (POSIX functions for example) and will turn off most GCC extensions. If you use -std=gnuXX", those other functions and extensions will be enabled.
That thing I gave you just told the preprocessor that we want POSIX functions (the 2008 version specifically).
>>
>>51777316
>camel case mixed with snake case
>character arrays
>memcpy
I feel slightly upset.
>>
>>51777321
>>51777315
All this pointer and memory address stuff still confuses the shit out of me. Are any tutorials recommended that are not done by some 15 year old NEET in their parents' house?
>>
>>51777299
What is complicated about the C string model? It's literally as simple as possible. Could you describe a string model that is simpler?
>>
>>51776927
They're both legitimate because both python and c are garbage. It's not our fault you like garbage languages, anon-chan.
>>
>>51777226
Church. Don't listen to the dinosaurs telling you to use languages that employ deprecated paradigms like functional, procedural or object-oriented.
>>
>>51777343
UpperCamelCase is standard for QT functions. I use lowerCamelCase for my own stuff so it's easily differentiated.

I don't want to be using memcpy but for what I want to do it doesn't look like there's any other way.
>>
>>51777344
>15 year old NEETs
>>
>>51777344
>All this pointer and memory address stuff still confuses the shit out of me
It's really easy, just think in terms of memory.
It's all laid out linearly.
*(arr+i) is just as valid as arr[i] because the latter is just syntactic sugar for pointer arithmetic.

>Are any tutorials recommended that are not done by some 15 year old NEET in their parents' house?
You know what, fuck you.
>>
>>51777349
by "C" I meant the entire C family, anon.

And I'm talking about talking shit about languages in general, please stop putting words in my mouth.
>>
>>51777291
Like, this kind of tiles? I don't think such a program exists. If i'd have to do it, i guess i'd write it in java - working around java bufferedimage class is super easy for me.
>>
>>51777377
What about that?

>>51777370
>Church
Boy, that's gonna be fun to debug when I'm searching on Google. That's the problem with languages like Go, Rust, Ruby, etc etc
>>
>>51777344
KILL YOURSELF
I
L
L

Y
O
U
R
S
E
L
F
>>
>>51777316
You should use QTextStream instead.
QTextStream out(&file);
out << ui->editorWindow->toPlainText();
>>
File: www.png (148 KB, 400x313) Image search: [Google]
www.png
148 KB, 400x313
>>51777391
>super easy for me
I dislike you.
>>
How can I read the user's OS details with C++? I want to play around and try to make some fancy-looking-but-still-barebones code.

Will it be too hard for a beginner?
>>
Pointers are fucking easy. Memory addresses are linear. I swear to god you can be bad at programming and that's fine, but if you don't get pointers right away you are some kind of subhuman.
>>
Really though, can someone recommend C tutorials?
>>
File: DzfSDtx.gif (652 KB, 480x270) Image search: [Google]
DzfSDtx.gif
652 KB, 480x270
>>51777446
>mfw i just think it's pretty intuitive to work around it but i didn't wanted to trigger anyone with somehow obnoxious non-imo "hey it's easy, come on, don't tell me you think it's hard" and yet someone disliked me anyway
life is suffering
>>
>>51777508
wikibooks
>>
>>51777508
C Primer Plus by Stephen Prata
>>
File: 1448990015755.png (252 KB, 455x633) Image search: [Google]
1448990015755.png
252 KB, 455x633
>>51776618
Trying to Boost my question. Would anime pics work?
>>
>>51777508
The C Programming Language by Kernighan & Ritchie.
>>
>>51777416
Compiles without error but now it isn't actually writing anything. Any ideas why? It's reading it just fine...
>>
Whiny faggots, just buy yourself a Lego Mindstorms or something.
>>
>Read entire book on C++
>Do all of the exercises there
>Can't do shit because I'm anything but creative

FUCK

I mean, I love programming, but I just CAN'T come up with an idea for something to do as practice.
>>
>>51777566
Open it with QIODevice:ReadWrite
>>
>>51777582
>I mean, I love programming, but I just CAN'T come up with an idea for something to do as practice.
No, you are just lazy, stupid or both.
>>
How long did AoC Day4 part 2 take for you?
>>
>>51777615
>No, you are just lazy, stupid or both.

He's just not very creative, and/or hasn't developed the skills needed to think of new projects.

Stop being such an asshole.
>>
>>51777582
if you're so bored, write everyday program. Text editor, image processor, whatever.
>>
>>51777615
So I'm either stupid or lazy because I can't come up with an idea for something to do because all the basic bullshit was already covered by the book?

Thanks anon, that's really fucking helpful.
>>
>>51777582
>I mean, I love programming, but I just CAN'T come up with an idea for something to do as practice.

Copying existing things is probably the best way to develop skills. You have to reach some level of competency before you can do anything meaningfully creative.
>>
>>51777508
C Programming: A Modern Approach
>>
>>51777623
Oh shit, there are part 2s?
Took literally a second to fix though
>>
File: Capture.jpg (172 KB, 872x1074) Image search: [Google]
Capture.jpg
172 KB, 872x1074
>>51777324

Sorry. I snipped the error and put it next to the line.
Also I'm aware that in the code, EAX won't display 0 if any of the numbers are the same. I fixed it after making the screenshot. Thanks for your help by the way.
>>
>>51777683
yeah but how long does it take to find a hash with 6 leading zeros?
>>
>>51777699
Takes me ~12 second
>>
>>51777324

Also, the line where the error is at is literally where I commented "ERROR". Just for reference.
>>
>>51777699
With my inefficient algorithm on python, like 14ish seconds
>>
>>51777582
Rewrite GNU and put it in the public domain to stop the oppression, man
>>
I still don't really understand what QT is...
>>
D
>>
>>51777774
c
>>
>>51777764

I think its like bootstrap but for programming?
>>
>>51777582
It's an application framework. Like GLib and friends, but with less library sprawl.
>>
>>51777691
Wait is this a full screen picture? You already defined numbers on top (numbers: DWORD)
>>
>>51777764
It's a GUI framework as well as a rather large library.
Think of it as like WPF + Mscorelib but cross platform and way better.
>>
alright, my bash solution is taking too long
What's the library linker name so I can import #<openssl/md5.h>?
>>
>>51777691
Also why dont you send parameters through the stack and just call the routine??
>>
isPrime=lambda x:sum(i for i in range(2,int(x**0.5)+1) if x%i==0)==0


r8 h8 masturb8
>>
>>51777393
> when I'm searching on Google.
Might I suggest you find a comparison of Anglican and Church, then?
Good luck :^)
>>
>>51777508
1- uninstall c
2- install a good language
>>
>>51777968
>uninstall c
>>
>>51777968
>install a good language
>>
>>51777968
>install a language
this, just consider compiling better architecture before you start installing new language
>>
>>51777553
This, the book is still very relevant.
>>
>want to make a notepad
>can't find any open source c++ simple notepad I can use as example

Fugg
>>
>>51778044
>C++
>needs "simple examples" to figure out how to do anything
>>
>>51778076
>He was never a newbie
>>
>>51778044
why

i mean seriously, where is fun in solving every problem with someone else's code

not to mention that if you'll pick any big popular window-thingie library, your notepad will be matter of textbox+save/load buttons around it, it shouldn't be this hard
>>
>>51778089
I needed tutorials when I was a kid.
>>
>>51775160
anyone else REALLY like 'short-circuiting' code? eg like the following:
void RemoveItemFromBag(Items the_item)
{
if (IsBagEmpty())
{
printf("Bag is empty!\n");
return;
}
for (int i = MAX_ITEMS; i >= 0; i--)
{
if (bag.items[i] != the_item) //go to next item if this isn't the right one
continue;

bag.items[i] = None;
bag.size--;
return;
}
}
>>
>>51778126
Why are you using the max size instead of the length of the items?
>>
File: 91i+g38v9eL._SL1500_.jpg (229 KB, 1143x1500) Image search: [Google]
91i+g38v9eL._SL1500_.jpg
229 KB, 1143x1500
>>51778044
just grab a shit of paper and start thinking about you have to implement, think about what notepad does.
The most obvious part you have window, generaly with some black or white background and a you can write in it and the text will be displayed ina contrasting colour.
When you write text, the text is displayed.
There you go, now you know what to implement and you can start looking up how the things you'll have to use to achieve this work.
So reading input you should know by know how to do it. Next you just have to look for a simple library to make UIs, I can't name any because I don't use C++, but judging by its size, QT will likely be an overkill for your needs
>>
>>51778126
>O(n) implementation
literally strln but shittier
>>
>>51778163
>QT will be overkill

I disagree. I'm writing a text editor in Qt right now and it's just perfect.
>>
what happened to 4senpai
>>
>practicing malloc
>accidently use strcpy instead of strncpy to move one string into another
>oh shit overflow
>accidentally overwrite part of 4chan's source code
Sorry lads
>>
>>51777879
>>51777930

I do apologize, I would've replied earlier but the site went down for an hour or two. And yes that is the entire program but it's not full screen, just a snippet.

Anyhow, I'm trying not to use the stack so I can get used to INVOKE. Calling a procedure is fine and all, but if you have to pass references or values then INVOKE would be the better option and less lines of code.

>You already defined numbers on top

I thought that was suppose to be necessary? So should I get rid of it?
>>
>>51778156
i was editing the quoted poster's code. but this is clearly something like an inventory (fixed number of items, see MAX_ITEMS). that means that there are gaps in the list with 'empty' (null) spots.

>>51778175
wanna enlighten me about how to find and remove an instance of an item from an unsorted, fixed-length list in better than O(N) time? fucking retard
>>
>>51775915
How long have you been coding? If it's less than 4-5 months, then shut up and keep learning (and enjoy the ride, of course), you have a long way to go to see amazing results. If longer than that, then stop nagging about how shitty your code is, and do something about it. Lurk on /g/ to get good books on C++/whatever_programming_language, watch youtube guides, ask a more seasoned programmer for stuff you don't understand. But, for fuck's sake, stop bitching and face your problems head on. /rant
>>
What language is 4chan written in?
>>
>>51778306
Thanks anon.
>>
I'm downloading qt for the first time.

Is there any pros and cons list about qt anywhere?
>>
>>51778314
nippanese
>>
>>51778314
Love
>>
>>51775210
>girl
>>
File: trap.png (7 KB, 215x383) Image search: [Google]
trap.png
7 KB, 215x383
>>51775210
>>51776856
>girl
>>
>>51775084
Losing my fucking shit having to refactor this fucking atrocious code I was pressured into writing by my boss because "muh speedy production". Then he fucking changes how every single thing is calculated and expects me to go in and make these changes. In half a day. Over 20,000 lines of code.
I'm not even being paid well. This is truly hell if there ever was a thing.
>>
File: memes.jpg (50 KB, 696x434) Image search: [Google]
memes.jpg
50 KB, 696x434
>>51778371
>20 000 lines of code
>>
File: 9780321992789.jpg (38 KB, 372x400) Image search: [Google]
9780321992789.jpg
38 KB, 372x400
error: cannot convert 'int' to 'Month' in assignment

enum class Month
{
Jan = 1, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec
};

int main()
{

Month m;
m = int(Month::Dec);

return 0;
}


I'm doing exactly what pic related is doing yet this doesn't work. Anyone know why?
>>
>>51778294
I'm not entirely sure of the way INVOKE works but it should be defined like this:
DifferentInputs PROTO dword: numbers

; other stuff

DifferentInputs PROC dword: numbers
;your procedure
ret
DifferentInputs ENDP
>>
>>51778375
I didn't come up with the batshit insane requirements to make a one-to-one perfect mapping of excel cells to variables in C++. No arrays! If we don't use arrays in the excel spreadsheet it isn't to be used in the C++ port! Why? TO MAKE IT EASIER TO EDIT FOR PEOPLE WHO DONT KNOW C++
Only 4 more years until I off myself anyways unless something turns my life on its head.
>>
>>51778393
>I'm doing exactly what pic related is doing
I'm skeptical of this.
>>
>>51778393
int() is how you convert in C++ right? You're trying to store something of type int into a variable of type Month, if I'm reading this right
>>
>>51778409
A1
A2
A3
A4
A5
...
B1
B2
B3
...

and all strings?
>>
>>51778375
You missed another prime target
>>51778393
>>
>>51778393
>>51778426
[[Month]] m = [[int]] int([[Month]] Month::Dec);
what are you doing
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.