[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

/dpt/ - Daily Programming Thread

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 320
Thread images: 51

File: weebs_pls_leave.png (1MB, 8192x8192px) Image search: [Google]
weebs_pls_leave.png
1MB, 8192x8192px
What are you working on, /g/?

Previous thread: >>61225466
>>
First for D.
>>
File: 1476428102389.jpg (61KB, 500x375px) Image search: [Google]
1476428102389.jpg
61KB, 500x375px
>>61233495
Second for anime
>>
>>61233495
At least make it programming related ffs
>>
File: anal beads.png (2MB, 2000x2000px) Image search: [Google]
anal beads.png
2MB, 2000x2000px
>>61233495
That's pretty rude, OP.

I bet you don't even program in C#.
>>
File: 1469824733039.jpg (83KB, 448x490px) Image search: [Google]
1469824733039.jpg
83KB, 448x490px
>>61233495
main = putStrLn "Hello, reddit!"


>>61233520
dumb frogposter
>>
what side project can I make in 2-4 weeks to put on my resume to get an entry level job?
>>
>>61233582
A CRUD application that works with a database and makes calls to some sort of public API.
>>
>>61233582
Fizzbuzz in Haskell.
>>
>>61233495
We don't fuck anime around here, we just masturbate to it.
>>
>>61233518
It's sad that Rust gets more attention than D. Fuck you Reddit.
>>
>>61233592
That does what exactly? Isn't this too easy?
>>
>>61233651
>Rust gets more attention than D
On /g/ maybe. In the real world, D is several orders of magnitude more relevant than Rust.
>>
/dpt/ what is the proper way to type? asdfjkl; or aetbnip[shift]?
>>
>>61233666
It could be anything.

You'd be surprised at the number of applicants I get that don't know how to properly read/write data from a database, or utilize REST APIs.
>>
>>61233678
Point taken. Though it's still not in the top 20 of programming languages.
>>
Made a thread about MiniMax algorithm, though I'd like some more answers.>>61233447

I've seen it implemented in games like Tic Tac Toe using two functions, heuristic and MiniMax. I have trouble understanding the point/score system specifically. How do I assign points to what and should I do it during the game (for turns) or after a game ends (for wins/loses).

I can read pretty much all languages save for the obscure ones. I have already made a very small Tic Tac Toe game that didn't take long so it's a bit messy. All I need is to implement an AI that's not stupid.
>>
File: anime8.jpg (73KB, 512x600px) Image search: [Google]
anime8.jpg
73KB, 512x600px
thank you for using a non-anime image
>>
>>61233694
>aetbnip
what
>>
>>61233694
>/dpt/ what is the proper way to type?
On a keyboard.
>>
>>61233694
That second one doesn't feel right at all, who the hell does it?
>>
>>61233495
Making a deep learning app that identifies intimate interracial relationships using photos on social media
>>
>>61233726
I do
It's pretty comfortable actually but you have to have been doing it since you first started using computers and never actually learned how to type the other way
>>
>I’m not a woman in tech

what does /g/ think of this article?

https://communequation.wordpress.com/2017/07/05/im-not-a-woman-in-tech/
>>
>>61233701
I should mention that I made the program in Visual Basic.
>>
>>61233696
Alright well I always wanted to learn Node.js

What do you recommend for generating SVG's ? Vue.js ? D3.js ?
>>
>>61233790
Why are you asking me about webdev shitlangs?

>>>/g/wdg
>>
>>61233776
>article
>wordpress
>>
>>61233714
>On a keyboard.
pleb
>>
>>61233694
statically
>>
File: 1498108612020.webm (924KB, 600x336px) Image search: [Google]
1498108612020.webm
924KB, 600x336px
What you porting to python this week, anon?
>>
>>61233797
well shit what do you work with?
>>
>>61233836
the illiac suite, unfortunately
i would much rather be doing it in c
>>
>>61233836
the motion looks like shit

is it just linear interpolation?
>>
File: 1499080673335.webm (2MB, 640x440px) Image search: [Google]
1499080673335.webm
2MB, 640x440px
>>61233836
linux kernel
>>
>>61233845
C#
>>
File: old_hag_langs.png (173KB, 600x355px) Image search: [Google]
old_hag_langs.png
173KB, 600x355px
>>61233495
Implementing QCPMC in Fortran for fun.
>>
why cant I put the access modifier in front of every individual member and function like in java in c++?
>>
File: woman-in-tech.png (206KB, 696x468px) Image search: [Google]
woman-in-tech.png
206KB, 696x468px
>>61233776
I nearly bought her story until I saw this.
>>
>>61233873
wtf I also work with C# for around 2 years now, fuck you're dissing web dev for?
>>
>>61233883
You can if you want, you just need a colon.
class MyClass {
private: int x;
private: int y;
public: MyClass(int, int);
public: int sum();
public: int product();
public: int difference();
public: int quotient();
public: int remainder();
};

That would be pure autism though.
>>
>>61233912
I do backend dev with C#, not webdev.
>>
>>61233924
meh the colon makes it really nasty. without I would do it
>>
>>61233932
So what counts then ? I have a web app, it has a database, API calls, bunch of code, ASP.NET MVC and all that, hosted on Azure, does that not count?

do you use WPF or UWP ?
>>
File: LOLIDONTCARE.png (38KB, 1037x243px) Image search: [Google]
LOLIDONTCARE.png
38KB, 1037x243px
LOL I DID THIS.
My solution is bloated as fuck kek, but I dont even care.
#include <stdio.h>

int is_pandigital(int fact[]);
int add_product(int product);

int products[100] = { 0 };
int endsum = 0;
int count = 0;

int main()
{
int sum = 0;
for(int i=1; i < 100; i++) {
for(int j = 1; j < 10000; j++) {
int fact[] = {i, j, i*j};
if(is_pandigital(fact)) {
add_product(i*j);
}
}
}
printf("sum: %d\n", endsum);
return 0;
}

int is_pandigital(int fact[])
{
int has_num[9] = {0};
for(int i = 0; i < 3; i++){
while(fact[i] > 0) {
int rem = fact[i]%10-1;
if(has_num[rem] == 0)
has_num[rem] = 1;
else
return 0;
fact[i] /= 10;
}
}
for(int i=0; i < 9; i++) {
if(has_num[i] == 0) return 0;
}
return 1;
}

int add_product(int product)
{
for (int i=0; i < count; i++) {
if(products[i] == product)
return 0;
}
printf("new product: %d\n", product);
products[count++] = product;
endsum += product;
return 1;
}
>>
>>61233957
>I have a web app, it has a database, API calls, bunch of code, ASP.NET MVC and all that, hosted on Azure, does that not count?

This would be fine; a project encompassing all of this would put you miles ahead of 90% of all other developers looking for jobs.


>do you use WPF or UWP ?
Neither, most of the time. I do create simple WPF applications for people from time-to-time, but most of my dev work is purely backend automation, such as creating Azure infrastructure based on on-prem data that needs to be modified, and then system-versioned in the cloud.

Are you french? Stop putting a space before your question marks.
>>
File: scr.png (115KB, 1680x1050px) Image search: [Google]
scr.png
115KB, 1680x1050px
>>61233495
>What are you working on, /g/?

Exploring the darkest corners of Racket.

I am trying to find a way to produce a spiral of numbers without the need of an array/buffer.

A spiral like these

1

1 2
4 3

1 2 3
8 9 4
7 6 5

1 2 3 4
12 13 14 5
11 16 15 6
10 9 8 7

1 2 3 4 5
16 17 18 19 6
15 24 25 20 7
14 23 22 21 8
13 12 11 10 9

1 2 3 4 5 6
20 21 22 23 24 7
19 32 33 34 25 8
18 31 36 35 26 9
17 30 29 28 27 10
16 15 14 13 12 11


I heard there is a solution in The Art of Computer Programming but i have no copy here.
>>
File: 1498849890697.jpg (72KB, 960x656px) Image search: [Google]
1498849890697.jpg
72KB, 960x656px
Okay this is a stupid question but I've never had to do it before. What's the syntax in C for a string literal that isn't just the string in quotes. I'm forced to use this editor that doesn't display unprintable characters at all, I want to pass ASCII character 31 + the null terminator to strtok as a literal, in Vim I can just insert the character and quote it, it looks like "^_" but as 1 character, in this other editor it literally just looks like "", the character is inside the quotes but it looks like it's an empty string. Is there another way to form a string literal composed of 2 characters? I don't want to use a variable just for this.
>>
>>61233495
>What are you working on, /g/?

an optimizing drawing and coloring trainer
>>
I'm just starting learning C
I'm trying to make this program print me the lesser of two entered numbers.
When I run it no matter what two numbers I enter I just get 0.00000.
(Example, First number is 2 and second number is 3, it prints out "The smaller of the two numbers is: 0.0000)

#include "stdafx.h"
double min(x,y);

int main()
{
double x, y, z;
printf("Enter your first number\n");
scanf("%lf", &x);
printf("Enter your second number\n");
scanf("%lf", &y);

z = min(x,y);
printf("The smaller of the two numbers is %lf : ",z);
return 0;
}

double min( x, y)
{
if (x < y)
return x;
else
return y;

}

>>
>>61234008
Alright well will try to focus more on those things in my resume I guess.
No I'm not French, its just a habit of mine

Does your company do A/B testing?
>>
>>61234048
works on my machine
#include <stdio.h>
#define min(a,b) ((a) < (b) ? (a) : (b))

int main()
{
double x, y, z;
puts("Enter your first number");
scanf("%lf", &x);
puts("Enter your second number");
scanf("%lf", &y);
z = min(x, y);
printf("The smaller of the two numbers is : %lf", z);
return 0;
}
>>
>>61234048
stop trolling you mongoloid.
If no troll, then read k&r again.
>>
>>61234048
For starters:
>double min(x,y);
>double min( x, y)
In C, you need to specify the types of function parameters. If x and y should be doubles, you need to specify that they should be doubles. Otherwise, they're treated as ints.

I wouldn't think this would be your problem, since casts between double and int are well defined, but try fixing it first and see if it helps.
>>
>>61234048
Forgot the types and ordered wrong, my compiler complained about all this when I compiled your program.
#import <stdio.h>

double min(double x, double y)
{
if (x < y)
return x;
else
return y;

}

int main()
{
double x, y, z;
printf("Enter your first number\n");
scanf("%lf", &x);
printf("Enter your second number\n");
scanf("%lf", &y);

z = min(x,y);
printf("The smaller of the two numbers is %lf : ",z);
return 0;
}
>>
>>61232992
No, I'm just wondering how it's so technologically hard and why nobody has managed to decentralize it and so on. It seems very, very easy to do.
>>
>>61234048
>not using the ternary operator
double min(double x, double y) {
return x < y ? x : y;
}
>>
>>61234120
>import
Nobody make fun of me, I had too much coffee today.
>>
>>61234140
2 late fgt
>>
>>61234140
*makes fun of u*
nothing personnel kid
>>
>>61233582
>make github account
>find random project
>look at issues until you find one which seems easy to fix
>fix it
>do this three times a day so the activity thing is dark green
There's a tool that makes backdated commits to your own repositories so you can fill out history, even for before the account was made.
https://github.com/avinassh/rockstar
>>
>>61234099
It's literally my first week in a programming class and i've never coded in my life, so relax.

>>61234101
>>61234120
Wow I just had to specify that x and y were doubles within the argument parameter. I was trying to figure that out by myself for a good 15 minuets now.

Thanks guys!
>>
>>61233701
Anyone?
>>
>>61234185
Then grab a copy of K&R, read and take notes to remember stuff. Also do the tasks inside the book.
>>
>>61234140
GCC actually had an alias to
#include
for it.
>>
>>61234186
you wan to implemnt min max?
>>
>>61233694
left hand - caps lock, wef (just in the general wasd area really)
right hand - kop] (doesn't matter as long as it's on the right side, it moves a lot anyway
for space use right hand index finger or lefthand thumb
>>
>>61234196
The professor i'm taking instructs out of "C Primer plus 6th edition" and its only a 6 week course so he's skipping tons of shit.
But thanks, I'll look into that aswell.
>>
>>61234208
Sure. But I'd like to see it implemented in a pseudocode so I could understand it better.

Like I said, mostly the point/score system.
>>
File: 1491985076255.png (44KB, 254x252px) Image search: [Google]
1491985076255.png
44KB, 254x252px
>>61233495
anime website
>>
File: 9780934613101-us-300.jpg (10KB, 300x462px) Image search: [Google]
9780934613101-us-300.jpg
10KB, 300x462px
>>61234186
I remember getting a good understanding of a*, alpha beta pruning and minimax from picrelated, it was long time ago thou
>>
File: ,.png (168KB, 727x682px) Image search: [Google]
,.png
168KB, 727x682px
>>61234304
fren website
>>
>>61234306
Thanks anon. Curiously, does it have examples?
>>
>>61234035
In case anyone was wondering, I just had to do "\037" I was hoping there would be a way to do it using decimal instead of octal or hex though. I'm really surprised visual studio doesn't just print a character for the literal though.
>>
File: anal beads.jpg (18KB, 366x380px) Image search: [Google]
anal beads.jpg
18KB, 366x380px
>>61234211
>for space use right hand index finger
>>
>>61234035
https://stackoverflow.com/questions/1421811/how-do-i-represent-a-unicode-character-in-a-literal-string-iso-ansi-c-when-the-c


For UTF8, you have to generate the encoding yourself using rules found, for example, http://www.cogsci.ed.ac.uk/~richard/utf-8.cgi?input=e9&mode=hex here. For example, the German sharp s (ß, code point 0xdf), has the UTF8 encoding 0xc3,0x9f. Your e-acute (é, code point 0xe9) has a UTF8 encoding of 0xc3,0xa9.

And you can put arbitrary hex characters in your strings with:

char *cv = "r\xc3\xa9sum\xc3\xa9";
char *sharpS = "\xc3\x9f";

>>61234024
http://libgen.io/search.php?req=The+Art+of+Computer+Programming&open=0&res=25&view=simple&phrase=1&column=title
>>
>>61234319
You can also do this:
char the_literal = {31, 0};
>>
>>61234318
>>61234261
http://aima.cs.berkeley.edu/python/games.html

http://www.frayn.net/beowulf/theory.html#abpruning

http://www.chessbin.com/post/Move-Searching-and-Alpha-Beta
>>
>>61234319
>>61234370
oops that's not quite right
char the_literal[] = {31, 0};
>>
>>61234382
2 late fgt
>>
>>61234387
meme
>>
>>61234128
>not doing it branchless with bitwise operators
#define min(x,y)((-(x<y)&x)+(-(x=>y)&y))
>>
>>61234370
>>61234382
The compiler complains: "too many initializer values" when I try to use it as an argument, I want to avoid assigning it since there's no reason to.
i.e. like this
function(const char *parameter) //signature
function({31, \0}) //does not work
function("\037") //does work
>>
>>61234420
>wasting clock cycles doing retarded shit
don't call us. we'll call you
>>
>>61234337
that's not even the worst of it all, ring and pinky are almost never used except for hitting something when the hand is at the wrong side of the keyboard (i.e. left hand is on srth and I need to type shift)
Can you repair your muscle memory and relearn typing?
>>
>>61234372
Thanks a lot.
>>
>>61234424
Try this
function((char[2]) {31, 0});
>>
File: file.png (165KB, 576x324px) Image search: [Google]
file.png
165KB, 576x324px
reminder that carpal tunnel will take your livelihood and then you'll be homeless
>>
>>61234463
>try being a massive faggot
how about no?
>>
>>61234432
In a non-optimizing compiler this is the fastest way lad
>>
>>61234424
Continued from >>61234463 : I just tested this myself, it works
You can also do this:
function((char[]) {31, 0});
>>
Still working on my SDL OpenGL bindings for OCaml.
>>
>>61234424
see>>61234357
>>
>>61234489
>non-optimizing compiler
hmmm
>>
>>61234475
>"\037" is better
>>
>>61234473
Not if you regularly workout.
>>
File: licecap.gif (15KB, 358x276px) Image search: [Google]
licecap.gif
15KB, 358x276px
>>61234463
No luck, I tried casting it earlier but it expects an expression after the cast before the braces.

gif for reference, ideally I'd just use the literal unprintable character, it's still there but the editor doesn't show it. I might just do that and add a comment about it. What a dumb editor.

>>61234490
That's weird mine won't let me do either cast, I'm stuck with the msvc compiler which may be why.

>>61234357
>>61234503
That's what I'm doing for now >>61234319

>>61234510
Just fyi that guy isn't me.
>>
>>61234536
Ah, yes, the good ol' Mongolian vowel separator issue.
>>
>>61234506
Everything is the same in an optimizing compiler, nothing matters anymore
>>
>>61234494
Isn't there already bidings for opengl for ocaml?
Also SAD.
Ocaml isn't even standardized language so you are making bindings for just one implementation.
Ocaml doesn't support native threading because of the design of the garbage collector.
Also ocaml has fucking ugly C interface.
>>
>>61234559
>nothing matters anymore
true
>>
>>61234536
This is best practice:
#define MONGOLIAN_VOWEL_SEPARATOR '\037'

function(MONGOLIAN_VOWEL_SEPARATOR)
>>
File: 1408727826956.jpg (44KB, 513x488px) Image search: [Google]
1408727826956.jpg
44KB, 513x488px
Anons, I need some C++ help.

I'm using a function from a library (nftw from ftw.h, to be specific) that calls multiple times some function that I pass to it. That function I pass needs access to some variables, but I don't really want to use global variables (even though I will need access to them from other places).

What's the neatest way of wrapping it?
The way I understand it, I can't make it call a non-static method of an object, so there's no point in wrapping it in a class. So do I have to put it all in a namespace and use global variables anyway?
I might be misunderstanding this C-like way of handling things.
>>
>>61234516
I'm not suer that's true.
>>
>>61234564
>Isn't there already bidings for opengl for ocaml?
Probably, but I like mine because they're designed for my use.
>>61234564
>bindings for just one implementation
Yes, but if one day there is another OCaml implementation, I will provide a second set of C bindings (it's not a huge work).
>Ocaml doesn't support native threading because of the design of the garbage collector.
That's not really a problem for me.
>Also ocaml has fucking ugly C interface.
You don't do it everyday so it's OK. It's usually a very small part of your code.
>>
>>61234556
>2017
>we are still having text issues like this
I hate this OS, I hate everything about pre-utf8 text, I hate unicode anyway too because of all the stupid additions they make, I just hate.

>>61234583
The problem with that is that I need a literal string, not just the character, even though the string is only going to consist of that character.
I wish I could do some bullshit like this '31' '\0', C will automatically concat 2 string literals together into a bigger string "ab" "cd" == "abcd", I wish 2 character literals next to each other turned into a literal string. As in 'a' 'b' == "ab"
>>
>>61234691
'a' + 'b' gives 'ab', no?
>>
>>61234701
It would just add them together and result in a single char. i.e. 31 + \0 = 31.

  char a = 31;
char b = '\0';
char res = a+b;
printf("%c\n", res);
>>
>>61234420
Fuck, my mistake. Here's a faster version:
(x & -(x<y)) | (y & -(x=>y))
>>
http://sijinjoseph.com/programmer-competency-matrix/
>>
>>61234756
Use strcat?
>>
>>61234756
Does C not have an equivalent to
new string(char[])
?
>>
File: 1482815152543.png (34KB, 246x232px) Image search: [Google]
1482815152543.png
34KB, 246x232px
>>61234762
>2^n on several questions
>>
>>61234777
>>61234787
The whole point is to avoid allocation when a literal will work just fine, the problem is not in C but the editor not displaying ASCII 31 (see gif here >>61234536)

I'm just looking for the best way to represent it, currently that's like this
"\037"

In a better editor you just do this (4chan filters out the symbol) https://ghostbin.com/paste/feh6o, in vim that looks like "^_", you can see in the gif, except it's one character, it's only represented as 2 visually.
>>
>>61234787
Nope. C doesn't even have an equivalent to string. Your only type for representing readable text is char[].
>>
>>61234820
Compiler will optimize it.
>>
What are some good resources to learn how jvm/.net machines work?
>>
>>61234836
It's easier to just type "\037" than all that would be required to concat 2 chars into a string.
>>
File: lolimdumb.png (28KB, 1018x275px) Image search: [Google]
lolimdumb.png
28KB, 1018x275px
What the fuck.
I am retarded.
How do I find the sum off ALL numbers which fullfill pic related? What is my upper limit?
>>
>>61234828
char * are strings in C
>>
File: what.png (19KB, 741x218px) Image search: [Google]
what.png
19KB, 741x218px
>>61234892
woops. That was the wrong pic.
>>
>>61234897
If we're being pedantic that's not true, C strings are character arrays, an array will decay to a pointer (for strings, a pointer to the first character) but they're not the same thing. In practice this makes little difference with strings but can be important for other things.
>>
File: 14978229842750.jpg (391KB, 784x983px) Image search: [Google]
14978229842750.jpg
391KB, 784x983px
Does anyone have a solution to this?

https://stackoverflow.com/questions/36141324/bootstrap-how-to-directly-link-to-an-anchor-tag-within-a-specific-tab
>>
>>61234908
it likely stops being possible at some point
>>
>>61234908
>>61234947
just checked

there are only four such numbers including 1 and 2
>>
>>61234937
Stupid Ranposter
>>
>>61234908
999,999,999 has 9 9!'s, which only adds up to about 3 million. that should be an easy upper limit.
>>
>>61234983
Bububu. My main tools are C and python, I have no intentions of learning bloatscript.
>>
>>61234947
>>61234984
Just looked up the upper limit because I need to sleep in a few minutes.
It is 9!*7, because 9!*8 has only 7 digits too
>>
>>61234937
>jQuery

Just learn a proper compile-to-js language and a proper view library senpai.

Also learn CSS, stop using "CSS frameworks", you don't need anything more than OOTB pretty buttons.
>>
File: Touhou.full.1332787.jpg (884KB, 800x1131px) Image search: [Google]
Touhou.full.1332787.jpg
884KB, 800x1131px
>>61234937
>JS
I did not give you permission to post pictures of my wife you falseflagging brainlet.
>>
File: 1423810207817.png (500KB, 987x766px) Image search: [Google]
1423810207817.png
500KB, 987x766px
>>61233694
I actually have my fingers positioned on SDF and JKL because I got into the bad habit of raising my pinkies a bit from my retarded parents training me to drink tea properly.
And I was born/raised in California not England. Yes, my parents were that fucked up. Fucking post-hippy stoner idiots that listened to too much Alan Watts.
>>
>>61234762
data structures: n
algorithms: n
systems programming: n^2
source code version control: n^2
build automation: n
automated testing: n^2
problem decomposition: log(n)
systems decomposition: log(n)
communication: n
code organization within a file: n
code organization across files: log(n)
source tree organization: n
code readability: n
defensive coding: 2^n
error handling: 2^n
IDE: n
API: log(n)
frameworks: 2^n
requirements: n^n, i'm not even at the "code to spec" level, i'm at the "what the fuck is a spec why is this man in a tie telling me to do things" level
scripting: log(n)
database: n^2
languages with professional experience: n
platforms with professional experience: n^2
years of professional experience: n^n, i've never worked
domain knowledge: n^n what is a domain
tool knowledge: n^2
languages exposed to: n
codebase knowledge: n^n what is a codebase
knowledge of upcoming technologies: 2^n
platform internals: n^2
books: n^n i don't read
blogs: n^n i don't know what a fucking blog is

/dpt/ how employable am i
>>
>>61234892
let rec sums answer accu left coins =
if left = 0 then
begin
List.iter (fun c -> Printf.printf "%d " c) (List.rev accu);
print_newline ();
succ answer
end
else
match coins with
| [] -> answer
| c :: coins ->
let rec use_c answer accu left =
let answer =
if left >= c then
use_c answer (c :: accu) (left - c)
else
answer in
sums answer accu left coins in
use_c answer accu left
;;

let answer = sums 0 [] 200 [ 200; 100; 50; 20; 10; 5; 2; 1; ];;

Printf.printf "answer %d" answer;
print_newline ();
>>
>>61235047
;;
>>
>>61234933
No C strings are char pointers. You just have an implicit casting of char arrays to C strings.
>>
>get an idea for something
>start writing a spec to see if it's feasible
>autism out over some detail
>lose interest
>repeat
What do?
>>
>>61235062
How constructive!
>>
>>61235097
>autism out over some detail
don't do it for the love jesus

proper way:
>get an idea
>shit out a n^n abomination of a solution
>see how it goes
>optimize
>>
You have 24 hours to write a visual language that doesn't suck.
>>
>>61235047
that coins problem is old, m9. here is my solution:
#include <stdio.h>

int coins[] = {200, 100, 50, 20, 10, 5, 2, 1};
int max = 200;
int count[200+1];

int main()
{
count[0] = 1;
for(int i = 0; i < 8; i++) {
for(int j = coins[i]; j <= max; j++) {
count[j] += count[j-coins[i]];
}
}

printf("count: %d\n", count[200]);
return 0;
}


Here is also the solution for this one: >>61234908
#include <stdio.h>

int fact(int n)
{
int prod = 1;
for(int i=2; i <=n; i++)
prod *= i;
return prod;
}

int main()
{
int upper = fact(9)*7;
printf("upper: %d\n", upper);
int sum = 0;
for(int i=3; i < upper; i++)
{
int tmp = i;
int tmpsum = 0;
while(tmp > 0) {
int j = tmp%10;
tmpsum += fact(tmp%10);
tmp /= 10;
}
if(i == tmpsum) {
printf("found curious num: %d\n", i);
sum += i;
}
}

printf("sum: %d\n", sum);

return 0;
}

>>
>>61234473
I'm 34 and I've been coding everyday since I was 18. No signs of carpal tunnel, but then again I practice good posture (sit up straight and push my shoulders back) and take short breaks every hour or so.
Another thing is that I keep one of those workout toys in my bag all the time, the one you're supposed to squeeze really hard to build forearm and wrist strength. I heard those make a big difference, so if you're having bad circulation or something maybe try that out.
>>
File: 1496046880397.jpg (53KB, 1024x578px) Image search: [Google]
1496046880397.jpg
53KB, 1024x578px
>>61235047
>let rec
>end
>;;
>Printf.printf
>>
>>61235175
We have the exact same solutions. I just keep more stuff to be able to print different sums.
>>
File: 1480676588288.jpg (50KB, 834x431px) Image search: [Google]
1480676588288.jpg
50KB, 834x431px
>>61234762
>All around n^2 with very few n
>Checks out with years of professional experience
>>
How do I write this?
char *var;
while ( (var = function()) != NULL){...}

Like this?
while ( (char *var = function()) != NULL){...}

Should I just do
while (char *var = function()){...}
?
Even still what's the syntax to check the assignment return on a pointer without declaring it beforehand, can you?
>>
>>61235178
Please insert argument.
>>
>>61235161
>a visual language
No. I'm not a disgusting microshill.
>>
>>61235134
Or I just autism out properly. What's the cheapest way to sign something? RSA is slow. Is there anything with hashes?
>>
>>61235019
Eat shit, dipshit retard.
>>
>>61235206
let rec argument =
begin
Printf.printf "Printf.printf.Printf.printf.Printf.printf.Printf.printf.Printf.printf.Printf.printf"
end
;;
>>
>>61233495
I have little to no programming experience, I'm trying to make a simple script in python that iterates through each character in a string that's 12 chars long, on each iteration, it should compare the character in each position against a list of 10 possible values, if one of the character matches, it should be added to a new string or list, then, just continue onto the next character position and do the same.

Basically, I have an encoded string, and I would like to decode that string using 12 lists, one list for each character position in the string, the encoded lists have 10 alphanumeric entries, I would like to use the encoded list index to get the decoded value.

encoded_string = "4d40X6LIXKOQ"

encoded_values_0 = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
encoded_values_1 = ["D", "b", "f", "d", "Z", "A", "Q", "W", "S", "C"]
encoded_values_2 = ["R", "e", "x", "1", "2", "3", "4", "5", "6", "8"]
encoded_values_3 = ["N", "4", "5", "6", "7", "8", "R", "9", "0", "Y"]
..


With the example above, the operation should convert "4d40" into "4368" using the index of encoded_possible_values_in_position_x, so far, I've managed to iterate between positions 0-12 and print them, but I have issues when I loop each position looking for the 10 values in my lists:

encoded_string = "4d40"
to_decode = list(encoded_string)
decoded = []

for i, char in enumerate(to_decode):
for c, val in enumerate(encoded_values_0):
if (val == char):
decoded.append(c)
for c, val in enumerate(encoded_values_1):
if (val == char):
decoded.append(c)
for c, val in enumerate(encoded_values_2):
if (val == char):
decoded.append(c)
for c, val in enumerate(encoded_values_3):
if (val == char):
decoded.append(c)
print decoded

this scrip seems to loop encoded_possible_values_X over the 4 positions in the list to_decode, instead of just one position, where am I fucking up?
>>
>>61235208
Maybe not, but you're certainly stupid if you think "visual language" is referring to something made by Microsoft.
>>
File: brainlets_on_suicide_watch.png (761KB, 1186x860px) Image search: [Google]
brainlets_on_suicide_watch.png
761KB, 1186x860px
>>61235228
You mad, pajeet?
>>
>>61235202
>while ( (char *var = function()) != NULL){...}
No, that's invalid syntax.
>while (char *var = function()){...}
That's also invalid syntax.
>Even still what's the syntax to check the assignment return on a pointer without declaring it beforehand, can you?
while(function())

If you have to actually use the return value as well, unfortunately you can't do that. You have to declare it first.
Or you could do:
for (char *var; *var = function();) {...}
>>
>>61235256
How is it stupid to believe something which is true?
"Visual language" is referring to something made by Microsoft, by the way.
You're just trying to convince me it's not, because you're a disgusting microshill and you want me to unknowingly disgustingly microshill.
>>
>>61235219
How long time does it take to verify a RSA-4096 signature? Are there any shortcuts you can use?
>>
>>61235264
>>
>>61235291
the Poe's law is strong with this post

https://en.wikipedia.org/wiki/Visual_programming_language
>>
>>61235295
I can use a Merkle tree, and then sign the data with RSA-4096 as well for posterity. I then sign the merkle tree with the RSA-4096 key as well. But this adds complexity, which is bad.
>>
>>61235308
I'm not clicking your leftist microshill links, disgusting microshill.
>>
wow, some of those project euler problems are way too fuckin easy in python. I should do more with C when it comes to so large numbers. Either try it myself or use gmp library.
#!/usr/bin/python3

sum = 0
for i in range(1, 1001):
sum += i**i

print(str(sum)[len(str(sum))-10:])

>>
File: wow.png (14KB, 564x190px) Image search: [Google]
wow.png
14KB, 564x190px
>>61235343
forgot picture again ;_;
>>
File: 媽的智障.jpg (114KB, 392x470px) Image search: [Google]
媽的智障.jpg
114KB, 392x470px
>>61235343
>>
>>61235357
#include math.h

int mask = 10^10;
int lastDigits = 0;
int main() {
for (int i = 0, i > 1000, i++) {
lastDigits += pow(i,i) % mask;
lastDigits %= mask;
}
}
>>
[Python]
I have seen very aesthetic way to populate an array, but I forgot it.

Lest say I have function that takes int as argument and inside this function I want to create an array of this size.

ie
for arg 4
arr = [0 ,1 ,2 ,3]


Now I know I could use just
for i in range(4):
arr.append(i)



but I have seen very elegant "oneliner" for populating an array.

Any ideas how to make it shorter?
>>
>>61235435
stop trolling.
>>
>>61235295
Ah nevermind, it's all in the range of milliseconds anyway
>tfw your posts never get any (you)s
>>
>>61235485
W-what did I do w-wrong?
>>
>>61235443
There are several ways.

In Python 2: range(4) returns a list
In Python 3: list(range(4))

What you have probably seen is a list comprehension although it isn't necessary for this problem

[x for x in range(4)]
>>
>>61235495
>pow(i,i)
does return a double which is WAY off when calculating 1000^1000
>>
>>61235271
>No, that's invalid syntax.
I'm asking what valid syntax would be for that expression.

>That's also invalid syntax.
It's working for me, I'm using C++, is it invalid to do that in C?
Shitty demo: https://repl.it/JPIf/0

>You have to declare it first
I don't mind declaring it but I just want it to live in the scope of the while loop only, I could just add braces but I feel like there's a way to do this in the condition that would be better.
>>
>>61233495
>hating anime on anime website
God I hate summer fags
Go install kali on your laptop hackur boy
>>
>>61235511
>is it invalid to do that in C?
I checked, it is.
The variable has to be declared for the condition to work.
  char *var;
while (var = function()) {


I guess I'll just declare it and enclose the declaration + loop in braces so it compiles in either and doesn't escape that scope.
>>
>>61235497
Thx, yup I have seen the last one somehere.
>>
>>61235202
char *var;

while(TRUE) {
var = function();

if(var == NULL) {
break;
}

/* code goes here */
}


Bring on the hate.
>>
File: 1476127404848.png (3MB, 1920x1200px) Image search: [Google]
1476127404848.png
3MB, 1920x1200px
Are private or protected functions different in any way from public functions once your code is compiled? Or are they just flags that your compiler looks to see if you are breaking?
>>
What is the smallest bittorrent implementation? Doesn't need to be very standards compliant or have DHT, PEX, or other fancy features, just something you can experiment with.
>>
>>61235745
At least, there's less risk to screw up the while test expression this way. But the TRUE macro is fatal bad taste to me.
>>
>>61235763
I'd say rtorrent, but this is /dpt/ here.

>>>/g/ptg
>>
>>61235782
Your mom is a macro.
>>
>>61235745
char *var;
var = TRUE
while(var) {
var = function();
/* code goes here */
}
>>61235791
I meant BitTorrent library.
How many sloc is libtorrent-rakshasa (rtorrent)?
>>
>>61235745
I'd probably use it if I had to check for anything besides NULL, but the issue is scoping var to only live inside of while. In actuality I'd probably just use the one that checks for NULL as well as throw a condition inside the loop for whatever else I was checking for.

I'm just really surprised you can't check the return value of an assignment when it's paired with the type declaration, and I don't think you can separate the 2.

It sucks that neither of these are legal.
while (char *var; (var = function()) != *some condition that isn't null*) {
while (char *var, (var = function()) != *some condition that isn't null*) {
>>
>>61235807
wew lad, not sure you get the (You) >>61235791
>>
>>61235808
What you are trying to do is exactly what the "for" statement in C99 is for. >>61235271 already gave you the solution (even though it's "var=function()" instead of "*var=function()").
>>
literally just
for (char *var; var = function();) {...}
>>
Would anyone be able to help me convert a C++ program to a basic C?
>>
>>61235930
Whoops, you're right. My fault, I don't know how I missed that.
https://repl.it/JPIf/1
It works with != so I can check for things besides NULL, even though in the demo it would work without the != operator, and it works fine in standard C not just C++.

Thanks >>61235271
>>
>>61235973
post your favourite anime image and we'll talk
>>
>>61235973
Why do you need to downgrade it?
>>
Reminder that this disgusting garbage is a valid sepples program
int main(){[](){[](){}();}();}
>>
>>61236037
thats also valid C
>>
>>61235973
why would you do that? anyway, if the C++ program is not too advanced, you can just change classes to structs (move member functions outside the "class" and pass a pointer to the struct), typedef your structs, change constexpr to static const (or something)
>>
>>61236058
what th efuck no it's notr
>>
>>61235973
Use the Comeau compiler.
>>
>>61236058
Valid C doesn't exist
>>
>>61236037
Reminder that this is valid Python:
property([]).__init__()
>>
What's a good quick rundown on vim? Gotta do some stuff over SSH and I'm already sick of push/pulling everything via git after doing it three times.
>>
>>61236074
with a return 0 in there, yes it is.
>>
File: Brook_vs_Big_Mom.png (454KB, 1096x644px) Image search: [Google]
Brook_vs_Big_Mom.png
454KB, 1096x644px
>>61236002
>>
>>61236107
open vim
type :help
read and do it
>>
>>61236120
no
it's not
int main(){[](){[](){}();}();return 0;}

this is not valid c
>>
>>61235747
>Are private or protected functions different in any way from public functions once your code is compiled?
No. The only difference is effectively in flags to say "this method is only callable from *these* contexts", and the generated code doesn't really give a fuck about those.

What language are you talking about? Not that it changes the answer...
>>
>>61236133
>post your favorite anime image
>posts a manga image
>>
>>61236107
use vimtutor
>>
File: Wikia-Visualization-Add-1.png (498KB, 670x499px) Image search: [Google]
Wikia-Visualization-Add-1.png
498KB, 670x499px
>>61236154
Slip up
>>
>>61236107
I use it, I like it. I'd never recommend it or any other editor because an editor is highly subjective and a highly customization one is even more subjective. See if you like the core concepts of it and if you do give it a try, then wonder about customizing and extending it to better suite your needs, it takes time but eventually you get an editor that was custom made by you for you. Most people seem to think it's not worth the time investment.
>>
>>61236140
oops, my mistake, still, you can do the same clusterfuck in C, especially common with pointers.
>>
>>61236138
>>61236170
I'll do both of these, thanks.
>>61236182
So is there anything essential missing from the default configuration of vim? The idea of just sticking to that kinda appeals to me since then I'll just have a good editor no matter what computer I'm on.
>>
>>61236186
asd.c: In function ‘main’:
asd.c:1:12: error: expected expression before ‘[’ token
int main(){[](){[](){}();}();return 0;}
^
>>
>>61236186
That is true, C has its own clusterfucks
But you would be hard pressed to find any as fucky as C++'s lambda syntax
>>
Doing my first serious C++ project and I just learned about bind, which is pretty neat. Any other functional-ish C++ features I should know about?
>>
>>61236224
C++ Templates == JS's """""""types"""""" > C++ Lambdas >
>>
>>61236037
>>61236094
>a language allows you to do retarded shit
Why is this a bad thing? You don't *have* to do it, it's just included in the specification.
>>
>>61236073
its a little lengthy
>>
Why are there not more good languages whose syntax consists entirely of indentation and keywords with literally no non-alphanumeric symbols?
>>
>>61236316
ArnoldC?
>>
>>61236316
Thatd be awful.
>>
Working in C.

I have a file, which I read into memory. I find a particular string in the file I need to replace. How would you go about doing this?

What I'm doing is:
-read file1 into memory
-find where string1 terminates
-rewind to where string1 begins
-copy the memory from before string1 starts to another buffer, x
-append my string, string2
-set file pointer in file1 to where the string1 terminates
-read file1 into memory2
-append memory2 to x

Any proper design suggestions?
>>
Working in C.

I have a file, which I read into memory. I find a particular string in the file I need to replace. How would you go about doing this?

What I'm doing is:
-read file1 into memory
-find where string1 terminates
-rewind to where the string begins
-copy the memory from before the string starts to another buffer, x
-append my string
-set file pointer in file1 to where the string1 terminates
-read file1 into memory2
-append memory2 to x

Any proper design suggestions?
>>
I am considering dropping out of college and starting to work in an IT trade.
Btw, I live in Germany.
While I recognized that I still love coding and want to work in IT, I was running from an assignment to a job, while doing another assignment, while jobbing and I just felt miserable.
It took 4 years inclusive a mental breakdown, depression and a couple months long sessions with my CS friends to recognize how far deep I went:
I gained a lot of weight, stopped working out, stopped eating regularily.
Rather, I mostly ate to emotionally cope.
And the financial situation of living under the rules of a very traditionalistic immigrant family since years took the toll on me.

I want to take a step back and work on myself and my passion. I need a routine.

I would be glad about some additional advice from you so I can draw a better picture of my situation.
>>
>>61236346
That sounds fine, now stop spamming the thread
>>
>>61236207
>So is there anything essential missing from the default configuration of vim? The idea of just sticking to that kinda appeals to me since then I'll just have a good editor no matter what computer I'm on.
So this is actually why I use and prefer Vim, but not stock Vim. Despite all my addons it still works exactly the same on every platform as long as I have git installed o nthat platform, and git runs on everything. When I move ot a new computer, I download my vim config, and run vim, vim fetches all the plugins I use and I'm not good to go, it works just like it does on the rest of my machines. Vim came stock even on my chromebook and it worked fine there, although I did have to recompile it with Python support for one of my unnecessary scripts but most platforms have that already.

That being said though stock Vim is very powerful and can do a lot of shit on its own, and you can still configure it to act exactly how you wish.
This is a boring but neat video on some common things people usually install plugins for that stock vim can do.
https://www.youtube.com/watch?v=XA2WjJbmmoM
>>
>>61236392
Is studying part-time an option for you? I'm working part-time as a programmer (1 or 2 days a week depending on how busy I am) and the rest for study, it's pretty comfy. Here in holland it's no problem if you just stretch your university education out over a few more years.
>>
>>61236412
Was fixing stuff for clarity.
Sounds a bit inefficient eh idk
>>61236392 isn't me (>>61236366
)btw
>>
>>61236433
What are you even trying to do?
>>
>>61236433
no, you can use short circuit evaluation to make the compiler optimize it
if file[i+0] == string1[0] && file[i+1] == string1[0] && (...) {
>>
>>61236388
Mean this guy isn't me (>>61236366)

>>61236448
see >>61236366
>>
>>61236433
Protip, write something then read it back before posting it, if you find any mistakes correct them and read it again, repeat until ytou can read the whole post without finding a mistake. Don't fucking edit a million times I hate this, if you post and it's wrong either reply to it and clarify or wait until someone replies expressing something is ambiguous then clarify to them.
>>
>>61236435
The university I am studying at doesn't support part time studying.
I also do not want to cut a degree out of my life.
Rather, i want to go back and have a back up plan, spend some time on getting my shit together.
I love to learn, but it wears me down having to barely jump from one module to the other and never really have time and in the end the energy to make the knowledge stick.

Maybe going to a trade might give me a predictable routine in my life that I can build on
>>
>>61233495
That picture. Finally someone else gets it.
>>
>>61236455
dude just stop deleting and then re-posting all your posts, if you care so much about efficiency
>>
>>61236455
>>>61236448 (You)
>see >>61236366
Yea I know what you typed, but describe what you want to do in abstract terms.

>>61236470
Well if you're currently in a burnout/breakdown type of situation of course sorting that out should be your first priority.
Also your uni should have counselors for this shit, talk to one of them, I've found some of them to be genuinely helpful.
>>
>>61236507
>>61236476
Basically I have a huge file (~80mb) and need to replace certain entries (non are identical) with new entries (non are identical).
>>
File: 1498419683608.jpg (26KB, 247x404px) Image search: [Google]
1498419683608.jpg
26KB, 247x404px
Gay thread
>>
Vim help says:
Jump to a subject:  Position the cursor on a tag (e.g. |bars|) and hit CTRL-].

But when I do that I either move my cursor down (as if I had just pressed J) or it creates a line break. So what does the help mean here?
>>
>>61236507
I am on pills and therapy right now.
The thing is, I just want a roof on my head, doing what I learned to love.
Which has become programming through working with it a lot.
I don't even dislike what I am studying right now.

I just feel so....lacking?
It's like I had the stubborness, but lacked the fitness to get through it.

And now?

I have a debt I want to pay back, I want to save money, want to live somewhere where I can have a safe haven to return back to and enjoy the progress of learning and doing.
Defining my goals for the long term without intrusion into my life and privacy.
>>
Somebody post one of those programming challenge roll pics.
ez1 plsz
>>
>>61236645
what's your situation mate?

i'm dying to get back into programming, i'm just sorting my life out after a heroin addiction, am doing very well in terms of fitness, socially and mentally doing excellent, even better financially, but i need to kick my career a fucking kick up the ass....
>>
>>61233495
What are some good applications for linux to brainstorm medium/large projects before starting them? Any free mindmapping applications? I would like to become more structured planning the inheritance ect before going balls deep.
>>
can anyone here hop over to sqt real quick and help me with my probably not stupid enough for sqt but not competent enough for this thread question thank... i have a feeling it will go unanswered
>>
I took a test for an entry level C# job, where one of my tasks was to write a function, which, given the radius of a circle N and assuming center at (0,0) gets the number of lattice points inside of it. It was required to be no harder than O(n) and return -1 if the result was greater than 1,000,000,000:

public int Solution3(int N)
{
int sum = 0;
for (int i = 1; i <= N; i++)
{
sum += Convert.ToInt32(Math.Truncate((Math.Pow((N * N - i * i), 0.5d))));
if (1 + 4 * N + 4 * sum > 1000000000)
return -1;
}

return 1 + 4 * N + 4 * sum;
}


This was my solution. Can it be improved?
>>
>>61236531
Why not sed?
>>
>>61236741
someone got it thank
>>
File: 1499291293133.jpg (94KB, 960x600px) Image search: [Google]
1499291293133.jpg
94KB, 960x600px
>>61233495
I reverse engineered the app itself to reveal all the answers to me.

http://media.jaguarlandrover.com/news/2017/06/jaguar-land-rover-and-gorillaz-seek-new-engineering-talent-alternate-reality

Expecting their phone call tomorrow or Friday
>>
>>61236693
emacs org-mode
>>
>>61236746
By lattice points you mean integer coordinates? Also, is the border included?
>>
>>61236752
It would take a LOT of time given that each entry is unique and to be replaced by a unique entry itself. Also there are many such very large files that need to undergo this process.
>>
Assistance required, interviewing for a Java position soon. Need a quick refresher on Java as I haven't done it in ages.

Recommended courses/links/other/
>>
>>61236746

Oh, and I also know that the exit from the for loop could be at i<N, since at i=N i just add 0 to sum.
>>
>>61236785

Yes, only integer coordinates, border included, range of N was to be 0-20000.
>>
>>61236579
You need to actually generate a tags file, did you do that and is it up to date?
>>
>>61236682
27, 10.000€ college debt, it's a state loan that is given out to those whose parents aren't rich.

I live in a household of a traditionally turkish family.
I am learning Java and do the assignments for now.
It is fun, even if I don't have always someone to answer my questions.
I kept myself up with cleaning jobs, newspaper.
Now I work in the gastronomy as a helper for a guy who works all over Germany.
As an example, I am gonna travel to my job tomorrow and work ten hours a day for two weeks.
And try to do my assignments while I am at it, and prepare for my exams.

I tried some drugs in the past, but it's a waste of money for me.

I dunno, what exactly are you asking for?
>>
>>61236746
Find an expression for lattice points given area, then simplify
>>
>>61236914
curiosity i guess, you posted something earlier and I was just interested
>>
>>61237106
Fair enough.
>>
go cry on reddit you fucking roach, this isnt your blog
>>
>>61234762
Half of the log(n) are really too easy, like the entries for systems programming, or problem decomposition, or "languages exposed to"
>>
>>61237158
>reddit
>roach
>blog
kys m8
>>
>>61236270
should still be easy, just change new to malloc etc
>>
In need of Java tutorials/guides.

I just need a refresher, as I have an interview soon, but haven't done Java in over 2 years. Any help?
>>
File: 1481272428929.jpg (74KB, 1280x720px) Image search: [Google]
1481272428929.jpg
74KB, 1280x720px
>>61236151
Thanks if you're still here. I left the thread and came back.

>What language are you talking about?
A C++ project is when I thought of it. But it's not even my preferred language, was just curious.
>>
>>61237390
Sir i have attached the code please kindly do the needful
>>
>>61237486
>everyone on /g/ is a shill or a poo in loo
>>
File: 1499126249021.png (2MB, 1353x766px) Image search: [Google]
1499126249021.png
2MB, 1353x766px
>>61233495
>FUCK ANIME
I'll be glad to
>>
>>61237460
in C/C++, as long as your algorithms and data types are in check, the compiler is usually smart enough to optimize it well, and e.g. private vs public is for the programmer's sake, not for the compiler
>>
>>61237390
https://docs.oracle.com/javase/tutorial/
>>
>>61237586
vigne best dropout
>>
What is the smallest bittorrent library?
>>
>>61233495
terrible OP
>>
>>61233738
You could sell it to >>>/pol/ !!
>>
>>61233738
>>61238104
you could sell it to both sides and independently develop different advancements for both apps, creating a kind of software war in which you are the sole manipulator and profiteer
>>
what does /dpt/ think about deckle-type?
for (decltype(v.size()) i; i < v.size(); i++)
>>
>>61233495
Structs in C are a little weird. Seems like there are multiple ways to create them and it's a bit confusing. Wish I could understand the syntax better.
>>
>>61236037
someone learned about lambdas
>>
>>61238431
This is a type, you can put it anywhere a type goes:
struct { int x; }

This is also a type, you can put it anywhere a type goes:
struct wrapper { int x; }
>>
>>61237586
What enime is this?
>>
>>61238431
>Seems like there are multiple ways to create them
No, there's only the one way.
struct some_name {
// Here, you just put things like normal variable declarations
int a;
float b;
char *c;
};

struct some_name variable;
variable.a = 10;
variable.b = 0.5;
variable.c = "hello";
// Or more succinctly
struct some_name variable2 = {
.a = 10,
.b = 0.5,
.c = "hello",
};
>>
>>61238431
(((structs)))
>>
>>61238431
>>61238482
You can also typedef it like with any other type if for some reason you want to or need to.
typedef struct LongStructTypeName {
int a;
float b;
char *c;
} ShortStructTypeName;

struct LongStructTypeName x;
ShortStructTypeName y;

The only difference is that you don't have to specify that "LongStructTypeName" is a struct with the struct keyword to use it, you can also omit "LongStructTypeName" if you never intend to use the struct alias.
>>
>>61238482
>// Or more succinctly
D E S I G N A T E D
>>
>>61238482
>>61238499
>>61238554
I should have clarified, I meant typedef structs. For example,

typedef struct{
Node* Next;
Node* Back;
int Value;
}Node;

This won't compile

typedef struct{
struct Node* Next;
struct Node* Back;
int Value;
}Node;

This won't compile either

typedef struct Node{
struct Node* Next;
struct Node* Back;
int Value;
}Node;

Oh, but putting "Node" right after the "typedef struct" makes everything cool. I guess I'm just confused why the previous two methods make the compiler eat shit. I wish I understood why this is so particular. Has something to do with calling the Node structure inside but I don't want to just accept it as a random rule to follow.
>>
>somehow got a job being a code monkey
>its ok but want more complex stuff
get degrees kids
>>
File: GUvW23N.png (77KB, 694x801px) Image search: [Google]
GUvW23N.png
77KB, 694x801px
>>61238597
I'm at 37 degrees right now
>>
>>61238597
you won't do "more complex" stuff straight out of university
>>
>>61238633
You have to admit this is pretty clever.
>>
Should I learn Common Lisp or Scheme?
>>
>>61238594
What's you're essentially doing in the first 2 is this.
typdef struct {
MadeUpType x;
} Node;


Notice how MadeUpType is not defined, when you give the struct an alias (which is essentially a typedef inside the struct namespace) it is now defined and thus it can embed itself inside, before it's defined it has no idea what a Node is. This should be valid as well.

typedef struct Node Node;
struct Node {
struct Node* Next;
struct Node* Back;
int Value;
};

int main(void){
Node x;
return 0;
}


structs are just types, does this example explain it? If not, what's still confusing?
>>
>>61238568
>implying they even know what that means
>>
>>61238713
http://wiki.c2.com/?LispSchemeDifferences

Give it a read and choose.
>>
>>61238594
>>61238715
Breaking this down too
>typedef struct Node Node;
typdef type typealias;
typedef (struct Node) [Node];
where () is the type, [] is the alias you want to give to that type.

struct Node {...};
This defines what a (struct Node) is, like another form of a typedef, you can think of it like this

(struct Node) is of type: struct { Next, Back, Vale}
Kind of like how function signatures are and how you alias those, struct signatures are similar.

I think the thing that trips people up is that it's not just a single word but it's still a single type.
>>
>>61238594
Remember that these are both types:
struct{
Node* Next;
Node* Back;
int Value;
}

and
struct{
struct Node* Next;
struct Node* Back;
int Value;
}

And remember that a typedef has the following form:
typedef ExistingType NewNameForType;

So in both examples, NewNameForType is Node, and ExistingType is the "struct {}" and everything inside it.

The problem with the first one is that the type to which you're trying to assign the name Node (the type "struct { ... }") has to already exist before the name Node will. But it can't, because you use the name Node in that type. That's what's called a circular typedef, and it's certainly conceivable that it could work, but C does not support it. Typedefs cannot refer to themselves, because that would require the typedef operation to actually build the type, but all it's capable of doing is assigning a name to a type which already exists.

The problem with the second example is that
struct{
struct Node* Next;
struct Node* Back;
int Value;
}

and
struct Node

are two different types. Namely, the first one is self explanatory as long as struct Node exists, and the second one, struct Node itself, does NOT exist. You're not defining struct Node there, you're just defining an anonymous struct type and trying to typedef it the name Node.

The reason the third example works is because you are defining struct Node, and struct definitions, unlike typedefs, are allowed to be circular -- but the struct type has to be named for its definition to be circular, because otherwise there's no way to refer to the same struct type.
>>
File: oldmanwhat.jpg (21KB, 384x313px) Image search: [Google]
oldmanwhat.jpg
21KB, 384x313px
What's the most sneaky way to trick normalfag phone users to do a grabcut for image segmentation?

>drag a box around the foreground object
>color in the foreground object
>tap a few points on the foreground object
Any other ideas?
>>
Hypothesis: C programmers use C so that GCC will accommodate to their shitty, inefficient algorithm.
>>
>>61233790
https://vimeo.com/216330850
>>
>>61238715
>>61238805
>>61238822
I think this is making sense. From what I can gather, 1 and 2 are a bit circular in logic. No structure called "Node" exists so the compiler doesn't know what to do with it even though it is inside the Node structure.

So here is where I also scratch my head:
typedef struct Node{
struct Node* Next;
struct Node* Back;
int Value;
}Node;

Why does "Node" have to be defined twice? For example, if I did

typedef struct {
struct Node* Next;
struct Node* Back;
int Value;
}Node;


or

typedef struct Node{
struct Node* Next;
struct Node* Back;
int Value;
};


It won't compile either. I guess it just bugs me because defining it twice doesn't look very clean. Does anyone have any online recommendations as to some good C learning sources? I'm currently just skimming http://www.learn-c.org and I can tell there is a lot of shit that I'm being left out of.
>>
>>61238667
I tried to be at least a little witty.
>>
>>61239085
how do you guys make those fancy code boxes
>>
>>61239041
>reddit
You should leave.
>>
>>61239085
>https://vimeo.com/216330850
kek

>>61239085
It doesn't have to be defined twice, what you're doing is 2 different definitions, in your broken examples they're broken because you're asking to define 2 things with 1 definition.

broken 1 is equivalent to this:
typedef UndefinedType TypeAlias
^undefined type is undefined ans thus not valid to use, you can't alias something to nothing.
broken 2 is equivalent to this:
typedef DefineType
^ notice the missing alias

In the complete example you have a valid structure type (struct Node) which is assigned to an alias of just "Node" which remember is not the same as (struct Node), even though that's 2 words, it's 1 type, and once the typedef is complete "Node" just because an alias which you can think of like a define "Node" gets expanded to "struct Node", this is an oversimplification though, it has to do analyses on the types during compilation, it's not just string expansion.
>>
>>61239161
We are just using the code tag. Almost the same shit as the spoiler tag.

Look up the rules for the /g/ board if you have no idea what I'm talking about.
>>
>>61239161
leave newfag
>>
>>61239041
>youtube
You should leave.
>>
File: peens.png (69KB, 640x610px) Image search: [Google]
peens.png
69KB, 640x610px
>>61239166
Obviously meant to quote >>61239078

>>61239085
>>61239166
I should clarify this because it may help.

>In the complete example you have a valid structure type (struct Node)
The type is more like this (struct Node{...}) where the ... is the members, that whole thing is a type, like how function signatures include the types of the parameters but a function signature results in a single type.

>once the typedef is complete "Node" just because an alias which you can think of like a define
Typo
>just becomes an alias

Also refer back to this post>>61238554 to see, they don't even have to have the same name, they often do but they don't have to, this might better exemplify it.

>>61239161
image
>>
>>61239041
Welcome to the retard zone fellow retard.
>>
>>61239041
fuck off andrei
>>
File: 1485262515835.jpg (76KB, 1065x859px) Image search: [Google]
1485262515835.jpg
76KB, 1065x859px
>>61239085
Don't typedef structs.
>>
>>61239041
hypothesis: shitlang programmers use shitlangs because they're too gay to learn a real manly language
>>
>>61233790

Oh fuck off meme developer jesus christ why won't you people just fuck off
>>
for(unsigned long i = 1; i <= LONG_MAX; i <<= 1){ 
int clz = __builtin_clz(i) + __builtin_clz(i - 1);
printf("%lu: %i\n", i, clz);
}


for(unsigned long i = 1; i <= LONG_MAX; i <<= 1){ 
int clz = __builtin_clz(i)
clz += __builtin_clz(i - 1);
printf("%lu: %i\n", i, clz);
}


Can anyone compile this code and try it? I think I'm going crazy, I get 2 different outputs, can anyone explain? No optimizations applied, gcc (Ubuntu 6.3.0-12ubuntu2) 6.3.0 20170406.
>>
How do you link in libraries in C++? The example code looks like this:
~/Documents/libtorrent/libtorrent-rasterbar-1.1.4> cat test.cc 
#include <iostream>
#include <thread>
#include <chrono>

#include <libtorrent/session.hpp>
#include <libtorrent/add_torrent_params.hpp>
#include <libtorrent/torrent_handle.hpp>
#include <libtorrent/alert_types.hpp>

They make references to a libtorrent/ directory. This is found in include/libtorrent/. How do I reference it in the source file? Do I just move the source file into the include directory?
test.cc:5:34: fatal error: libtorrent/session.hpp: No such file or directory
#include <libtorrent/session.hpp>
^
compilation terminated.
exit 1
~/Documents/libtorrent/libtorrent-rasterbar-1.1.4>
>>
>>61233696
>You'd be surprised at the number of applicants I get that don't know how to properly read/write data from a database, or utilize REST APIs.
doesn't mean they're bad programmers, just that they haven't done this specific crud/webfag shit
>>
>>61239324
>C++
Don't do this.
>>
File: CoSUP0mW8AE_Ymj.jpg (46KB, 657x634px) Image search: [Google]
CoSUP0mW8AE_Ymj.jpg
46KB, 657x634px
Anime
>>
New thread:
>>61239343
>>61239343
>>61239343
Now with anime.
>>
>>61239284
Is ok to typedef structs, what is wrong is to typedef pointers.
>>
>>61238554
>>61239247
I'm gonna elaborate again.

typedef struct StructAlias {
int a;
float b;
char *c;
} TypeAlias;


Breaking down where () is a SINGLE type just like int, float, etc.

typedef (struct StructAlias {
int a;
float b;
char *c;
}) TypeAlias;

That whole thing resolves down to a single type of "struct StructAlias" which is now a valid type, you can then alias that type like this
typdef struct StructAlias TypeAlias;
Remember it's a single type despite being 2 words. typdef (struct StructAlias) TypeAlias;
An alternate layout for that is this.

int main(void){
struct StructAlias {
int a;
float b;
char *c;
};
typedef struct StructAlias TypeAlias;

struct StructAlias x;
TypeAlias y;

return 0;
}

The reason it's usually the same name is probably for ubiquity of the long form, it usually doesn't make sense to have 2 names for the same structure when instead you could just have 1 word for both forms. Although I think historically they had to be different for a technical colliding reason, that's no longer the case though so don't worry about that.
>>
>>61239315
RTFM

>If x is 0, the result is undefined
>>
File: 1495148200907.jpg (10KB, 500x500px) Image search: [Google]
1495148200907.jpg
10KB, 500x500px
>>61239304
Nothing gay about feminine penis REEEEE
>>
>>61239358
Counterexample: you have a struct type declared in a header file, but defined in a source file. Your users have no reason to care that that type is a struct--they just get pointers from your functions and pass them around. Do you still refuse to typedef pointers to that type? Why?
Thread posts: 320
Thread images: 51


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
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.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.