[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: 367
Thread images: 40

File: functional programming.jpg (64KB, 440x389px) Image search: [Google]
functional programming.jpg
64KB, 440x389px
What are you working on, /g/?


Previous Thread: >>62000152
>>
>c programming.jpg
ftfy trapfag
>>
File: 1413777090510.png (1MB, 1920x1080px) Image search: [Google]
1413777090510.png
1MB, 1920x1080px
>>
File: 1494541901812.jpg (105KB, 473x496px) Image search: [Google]
1494541901812.jpg
105KB, 473x496px
(sorry for not using an anime image edition)
>>
shouldn't java be faster than c on android?
I mean, google can optimize their java thing all they want, with jit stuff and all
>>
File: c02.jpg (194KB, 650x817px) Image search: [Google]
c02.jpg
194KB, 650x817px
It isn't fair bros.

It just isn't fair.
>>
>>62004173
The NDK documentation says not to expect C/C++ code to run faster than native Java.
IIRC it wasn't definitive either way.
>>
I hate anime
>>
File: 306607.jpg (29KB, 225x350px) Image search: [Google]
306607.jpg
29KB, 225x350px
>>62004304
But you love C++!
>>
>>62004173
Isn't the androids jvm implementation really shitty or something, at least it was before.
Anyways compiled C with proper compiler flags should never be slower than java.
>>
>>62004126
sorries not accepted
it make faggots like 62004304 to rise up
>>
>>62004313
nope, too young
>>
what does pajeet code look like?
>>
>>62004407
It varies between brilliant and total shit.
>>
>>62000211
>Paying $150 for an algorithm you can implement in 10 minutes.
>>
File: 1501345987050.jpg (250KB, 704x904px) Image search: [Google]
1501345987050.jpg
250KB, 704x904px
>>62004313
>>62004124
>>62004126
>>
>>62004420
I'm building a Qt-based application however I need some C++14 features that are not available in the versions of the compilers that Qt comes prebuilt for on Windows.
>>
Is this true, /dpt/?

>>>/v/387725251
>>
>>62004487
anime website
>>
File: 1498322546508.gif (398KB, 646x466px) Image search: [Google]
1498322546508.gif
398KB, 646x466px
int
main(void)
>>
File: Untitled.png (70KB, 1242x769px) Image search: [Google]
Untitled.png
70KB, 1242x769px
>>62004590
>>
>>62004590
yes, cawadooty is written in jaba.
>>
>>62004624
Baltics confirmed master race
>>
>>62004629
No it isn't.
>>
>>62004600
int main(int argc, char **argv)
>>
>>62004624
china wins every time because they have a fuckton of people
>>
>>62004658
void main()
>>
>>62004624
How come Ethiopia is so un-African?
>>
>>62004691
kangz
>>
Really /g/?

>>>/v/387726619
>>
>>62004749
Dumb crossposter.
The only good language is Haskell.
>>
>>62004795
you spelled Idris wrong.
>>
Seriously?

>>>/v/387726901
>>
File: over 20 hours in C.jpg (18KB, 635x500px) Image search: [Google]
over 20 hours in C.jpg
18KB, 635x500px
Ask someone who just spent over 2 hours making this anything
>>
>>62004982
Coding on Windows.
>>
>>62004982
>over 20 hours in C
Sounds about right, C is not for productivity.
>>
>>62004749
everyone hates C++, especially people who know it really well

I guarantee you that Bjarne hates it, that's why he teaches people how to rewrite it in his books (eg Estd namespace)
>>
>>62004931
Yes. We seriously cringe him a lot.
>>
>>62004994
Better yer Windows [spoiler]10[/spoiler]
>>
>>62005020
Hello /v/.
>>
>>62004600
int f(int, char*, float)
int a,
char *dst,
float coeff
{
}


The worst thing is, compilers back in 70s didn't really check what you passed to the function.
>>
I've fallen into an absolute hole after finishing my last project and have no idea what to do now. Any suggestions to get the creative juices flowing?
>>
File: tendies_98.png (15KB, 640x480px) Image search: [Google]
tendies_98.png
15KB, 640x480px
perfect modern OS simulation interface
>>
>>62005178
don't you write the name in the parameter list in the old style declarations, not the types?
>>
Was there ever a picture of an anime girl holding a copy of Homotopy Type Theory?
>>
Getting OCaml's Core installed on my rasp. pi. Having issues with `mpopcnt` (not available on pi) so having to build core_kernel from source on the latest dev build. Fortunately this fix will be in the nex release. :tada:

Fun times.
>>
File: Calculus of Maki Constructions.png (312KB, 452x355px) Image search: [Google]
Calculus of Maki Constructions.png
312KB, 452x355px
>>62005631
>>
>>62005689
You absolute saint. I'm upvoting this.
>>
>>62005673
>OCaml
Not related but for some reason I can't get the dllllvm.so to build anymore so I can use the OCaml bindings but not use them with utop.
>>
I have a space leak with my hasklel program, code related.

moveHeli :: Double -> Game -> Game
moveHeli n state = force $ state & heliPosition.bottomLeft.y +~ n
& heliPosition.bottomRight.y +~ n
& heliPosition.topLeft.y +~ n
& heliPosition.topRight.y +~ n

moveBlocks :: Game -> Game
moveBlocks state = force $
state & blocks.blockPairs.traversed.both.bottomLeft.x -~ (state^.speed)
& blocks.blockPairs.traversed.both.bottomRight.x -~ (state^.speed)
& blocks.blockPairs.traversed.both.topLeft.x -~ (state^.speed)
& blocks.blockPairs.traversed.both.topRight.x -~ (state^.speed)


As you can see, I popped a force on the front, from Control.DeepSeq, which fixes the issue, but I read it's probably not the best way to fix it.

I know the reason it's happening, because I'm doing a lot of +'s or -'s which collect as a thunk, but I'm not sure the best way to fix it, I don't really know how to use seq or something like that.
>>
>>62005822
please abstract out all that repetition
also i'm not sure if lens operators have strict variants?
>>
File: 0362.png (22KB, 202x176px) Image search: [Google]
0362.png
22KB, 202x176px
Do you program all day?

i'm more productive at night

green text what your day looks like
>>
>>62005964
Good call, I'll have a look.

Thanks for reminding me, I was just stuck this together and I wasn't really thinking what I was doing
>>
>>62005993
>wake up
>go to computer
>go to sleep
add eating wile being on the computer and fapping

I also program more at night, but all day generally
>>
>>62005993
>wake up
>browse 4chan
>write a few lines of code (optional)
>fap
>sleep
>>
int main(void)
{
int digits = 0;
int i = 981;
while (i < (int) pow(10, digits))
++digits;
printf("i has %d digits\n", digits + 1);
}


Why doesn't this work?
>>
>>62006071
nevermidn I'm retarded
>>
>>62005993
>wake up
>play a MP game to actually wake up
>if im still tired go make coffee
>check my 4chan and youtube usuals
>see where i left off in my TE, most likely a shitty bug or error i was trying to fix
>fix it and implement a new thing
>reward myself with a game
>eventually have a wank and pass out
>repeat
>>
>>62006071
int how_many_digits(int n) {
return (!n) ? 1 : floor(log10(abs(n))) + 1;
}
>>
>>62006118
this isn't pythonic enough
>>
>>62006136
def digits(i):
return len(str(i))

pythonic enough?
>>
>>62006162
this isn't type-safe
>>
>>62006175
>pythonic
>type safe
pick one
>>
>>62006175
>c
>type safe
>>
>>62006186
Javascript's children are the future of programming.
>>
>>62006071

>while (i >
>>
What's better:
1. Mailing a copy of SICP to Rust developers.
2. Submitting PRs to popular Rust repos that rewrites it to be "more pythonic"
>>
>>62004691
Actually they're the most africans of them all since euros were never able to cuck them unlike the rest of the continent
>>
What does "pythonic" even mean?
>>
>>62006297
2
>>
>>62006371
it means you create artisanal masterpieces as a pythonista.
>>
>>62006402
I don't know what that means
>>
>>62006371
bad
>>
>>62006420
it means people who use the word pythonic are also the people who call themselves pythonistas, who think they are artisanals.

same as the guy at a coffee shop thinking he's a true artist, by being a barista.
>>
File: m&w.jpg (24KB, 851x507px) Image search: [Google]
m&w.jpg
24KB, 851x507px
Do i have a promising future in the gaming industry bros?
>>
>>62004600
int
main()
{
return 0;
}
>>
>>62006444
So it doesn't mean anything?
>>
>>62006469
are you using vulcan? Lol
>>
>>62006476
life as no meaning
>>
>>62006476
(It means its with accordance to PEP 8 and blessed by the Benevolent Dictator for Life, Guido -- "The Right Way of Doing It" as opposed to TIMTOWODI or whatever.
"pythonic is the python way")
>>
>>62006491
this is false
>>
>>62006565
for you
>>
>>62004982
Wtf does it do? Why?
>>
>>62006469
that's a pretty good pic
>>
>>62006513
seems circular
>pythonic is the python way
>python is pythonic
>>

*/
LRESULT CALLBACK Win32CallBack(
HWND window_handle,
UINT message,
WPARAM w_param,
LPARAM l_param
) {}


how do i handle multiple presses? i only havev 1 w_param to parse.
>>
>>62006966
like key-repeat? or how to handle keypresses in general?
also, that wndproc doesn't really help your question
>>
>>62007006

Like in side scroller games, when you hold RIGHT and press SPACE, it wouldn't interrupt you moving right, but it still handles jumping.
>>
>>62007029
for that you'll want to use RAWINPUTDEVICE unless you want to keep an FSM to determine the key order.. but then you'll still have 20-30ms delay in the Message queue.

https://msdn.microsoft.com/en-us/library/windows/desktop/ms645536(v=vs.85).aspx
>>
>>62007029
>>62007057
also depending on how your game loop works, you could use https://msdn.microsoft.com/en-us/library/windows/desktop/ms646293(v=vs.85).aspx with the delta to determine which keys were down during that frame.
>>
>>62004818
but PHP is better guyz XDDD
>>
Test
>>
File: 4chan_despair.jpg (82KB, 924x571px) Image search: [Google]
4chan_despair.jpg
82KB, 924x571px
>>62004124
>tfw no qt vb gf
Why is she so cute?
>>
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[])
{
char ops[10]; // Contains operations.
int nums[10]; // Contains operands.
int i = 0; // Indexing.
int j = 0;

while (--argc > 0) // This loop creates two buffers for operands and operators.
{
char op = argv[argc][0];
if (op == '/' || op == '+' || op == '-' || op == '*')
ops[j++] = op;
else
nums[i++] = atoi(argv[argc]);
}

int expr = 0;
int jj = 0; // I don't really like indexing the other way around, but whatever.
int ii = 0;
printf("%c\n", ops[jj]); // This is just for testing.
printf("%d %d\n", nums[ii], nums[ii+1]);
switch(ops[jj++])
{
case '/':
expr = nums[ii++] / nums[ii++];
printf("%d\n", expr);
break;
case '+':
expr = nums[ii++] + nums[ii++];
printf("%d\n", expr);
break;
case '-':
expr = nums[ii++] - nums[ii++];
printf("%d\n", expr);
break;
case '*':
expr = nums[ii++] * nums[ii++];
printf("%d\n", expr);
break;
default:
printf("Invalid input\n");
return 0;
}

return 0;
}


output
tjh@home:/mnt/z/prog/c$ gcc 5100.c
tjh@home:/mnt/z/prog/c$ ./a.out 3 4 +
+
4 3
7
tjh@home:/mnt/z/prog/c$ ./a.out 3 4 -
-
4 3
1
tjh@home:/mnt/z/prog/c$ ./a.out 3 4 /
/
4 3
1
tjh@home:/mnt/z/prog/c$ ./a.out 3 4 *

0 0
Invalid input


Why won't it recognize *? Is there something special about that character when it comes to command line arguments?
>>
>>62007206
what shell are you using? try escaping it (\ or ^)
>>
how would you code the same effect some ebook readers have where they imitate the passing the page as if it were a real book?
>>
>>62007228
(or passing it as a string, the parsing that string by splitting on the space. its probably your shell trying to glob *, like ls *.foo)
>>
>>62007228
Nice! That did it. I'm using LXTerminal by the way.
>>
File: anime79.png (375KB, 752x588px) Image search: [Google]
anime79.png
375KB, 752x588px
>tfw solving project euler problems
I feel myself getting better.
>>
>>62007224
ur sister 2 lol
>>
>>62007250
thats your terminal. it'd be bash or zsh or dash or whatever that's doing stuff with the *

(you can check with echo $0 or echo $SHELL)
>>
>>62007224
Hacking u rite now get redy scrub
>>
File: mbb.webm (3MB, 590x720px) Image search: [Google]
mbb.webm
3MB, 590x720px
>>62007286
>>
>>62007289
Ah, I'm stupid. It's bash. Thanks again.
>>
Hi guys, I am a C newbie, working my way through K&R, and I have encountered a small road block. I currently on exercise 1-13. After I finished my own answer, I went to check K&R's answer. Their answer was WAY more complicated than mine. On the answer posted by K&R, I found these 2 blocks of code that I didn't quite understand.

 maxvalue = 0;
for (i = 1; i < MAXWORD; ++i)
{
if(wl[i] > maxvalue)
maxvalue = wl[i];
}


And this one:

for(i = 1; i < MAXWORD; ++i)
{
printf("%5d - %5d : ", i, wl[i]);
if(wl[i] > 0)
{
if((len = wl[i] * MAXHIST / maxvalue) <= 0)
len = 1;
}
else
len = 0;



I know it is a retarded question, but I would really appreciate if any of you veterans could explain to me, in detail, what these blocks of code do on the original answer. I would have posted the whole code here, for more clarity, but for some reason 4chan doesn't want to cooperate. Thank you in advance.
>>
>>62007326
first one iterates over an array and stores the greatest size.

second one iterates over an array, prints the index and value, checks if the stored value is greater than 0. if it is, it sets len to the value times maxhist divided by maxvalue. if len is less than or equal to 0, it becomes 1.
if the original stored value is less then or equal to 0, len becomes 0
>>
>>62007316
>children dressing like that
fucking americans man
>>
>>62005235
Yes
>>
>>62004590
yes, because apps are commonly developed in Java and businesses these days don't just want a website they want an app too.
>>
>>62007513
but those apps only run on pajeet phones, not the ipatrician 7s
>>
>>62007484
what are you talking about
>>
>>62007583
that webm you retard
>>
File: virgin dev.png (181KB, 1700x600px) Image search: [Google]
virgin dev.png
181KB, 1700x600px
which one are you?
>>
>>62007621
where is the child in that web
>>
>>62004996
>being unable to read
>>>/preschool/
>>
Why were the C data types short and int standardized to be both at least 16 bits?
>>
File: 0.jpg (211KB, 869x1776px) Image search: [Google]
0.jpg
211KB, 869x1776px
>>62007735
which one are you?
>>
>>62007772
It's funny because her code doesn't even work for a==b
>>
File: 1234rtyhj.png (178KB, 865x461px) Image search: [Google]
1234rtyhj.png
178KB, 865x461px
>>62007741
>born in 2004

off yourself
>>
>>62007759
because denise ridgy didn't think 17 bits was an good number
>>
>>62007798
that's because the image is fake
>>
>>62007798
what about writing 2 times the same condition?
a > b && b < a
>>
Who else /sick of shitlangs being used for everything/?
>>
>>62007801
that image is photoshopped her real birthday is 1991
>>
>>62007798
it does work for a==b. it gives you 5. its actually mislabeled, it should be: max_with_rand().
>>
>>62004107
So I got this new job as developer, junior based (1 year of exp you know) and I got tons of material to study and to get my shit together:

>Ionic
>Angular 1.x
>Angular 2.x
>RESTFul Services and HTTP Request stuff
>C#
>SQLServer

In my last job well, things got well pretty good until 3 three of my teamworkers quit the job during present year, and well, it was a fucking nightmare.

I don't want to get in detail but it was terrible, in mental and body terms, was just like BOOM or something like that. So any advice to get around with this new job??
>>
>>62007822
no it isn't
>>
File: triggered megyn.gif (219KB, 300x475px) Image search: [Google]
triggered megyn.gif
219KB, 300x475px
>>62006469
>two genders
>>
>he uses Haskell
>he has memory leaks for calculating the average from a list of a million floats
>>
Working on application that takes 4 grayscale images each representing different color channels and puts them together to preview the final output, however I am pretty clueless as to why things are not working out well.

Pic related is how my output is supposed to look like (left) and how it currently looks (right). Anyone has potential idea as to why the output looks all interlaced and disfigured? Am using libpng in C. Tried approaches such as possibly incorrect color placement or reading off-bytes, but at this point all these cases seem to be safeguarded against, yet this shit still happens.
>>
>>62007848
>3 three of my team-workers quit the job during present

hmmm why?
>>
File: bad_output.png (991KB, 1014x508px) Image search: [Google]
bad_output.png
991KB, 1014x508px
>>62007853
Goddamn, forgot pic related.
>>
>>62007851
?
>>
>>62007383
Sorry for the late reply, thank you for the answer. After running the code, I get this as an output.

This was my input:
I love you forever

This was my output:
i love you forever
1 - 1 : ***************
2 - 0 :
3 - 1 : ***************
4 - 1 : ***************
5 - 0 :
6 - 0 :
7 - 1 : ***************
8 - 0 :
9 - 0 :
10 - 0 :

I am wondering where I messed up, however, it is behaving just how I was expecting, from looking at the code. Thanks in advance.
>>
>>62007801
stop lying on the internet
>>
So, I never finished college because of personal issues. but I was able to get a job at one of the big corporations from internships. I'm very happy where I am and I can see myself doing well in the future. But the issue is that I still want to go back and just finish it. It won't do anything for my professional self, I just feel like it's something I need to do. Bad idea to waste that time/money just for a bucket list?
>>
>>62007848
>all that shitty tech
>So any advice . . .
quit immediately
>>
>>62007853
how do you combine pictures?

for example, in the position (15,30) of the image, can only be 1 pixel, so how are you combining 4 different pixels into one?
>>
>>62007772
>const threehalfs
>doesn't have a problem throwing a random hex in there though
>>
>>62007884
You'll never make it in the gymyng yndystry if you keep being cisnormative like that, anon. There are more than two gyndyrs, you knoe.
>>
>>62007848
I bet ur doing it for free too lmao
>>
File: sdxfghj.png (141KB, 801x398px) Image search: [Google]
sdxfghj.png
141KB, 801x398px
>>62007895
xD

anyways, why are you pretending she's born in 91?

are you a pedophile?
>>
>>62007912
>all that shitty tech

en light me in what good tech is

>>62007938
?
not him, but a job is job. i would prefer that instead of being NEET desu
>>
>>62007940
nah I don't even know who she is tbqh, I'm just bored. just finished a 17-hour non-stop drive to see the total eclipse
>>
>>62007958
>would work for free rather than be a neet master race
what the FUCK happened to /g/
>>
File: 1080.png (5KB, 340x340px) Image search: [Google]
1080.png
5KB, 340x340px
>>62007867
didn't realized that I repeated 3-three, sorry for that.

Why they quit you ask, well, because is in Bogotá, Colombia. Anon, they got like 5 five years of exp and got paid like fucking slaves, they got new jobs, better paid, in other cities, and very well compensated. Even when it was a good company, the shit we got here during calendary was horrific, it was, like, I need this 1-month-job in 2 weeks, you got to be til 12 PM-1AM or whatever, working saturdays and sundays, and forget about ask for holidays or stuff like that,. It was a fucking like 25/8-job.

I learned a lot of stuff in my last (and first job as developer as professional or whatever you call it), but dude, in this year, there was like 2 devs including me, and my last co-worker broke his arm and he just vanished until july, so, pretty much I was by myself from march til july.
>>
>>62007935
>There are more than two gyndyrs, you knoe.
source?
>>
>>62007913
The input images are greyscales, each representing different RGBA channel. I use the greyscale value from 3 of them to form the RGB pixel data of the output image and use the alpha image to adjust intensity of the input RGB colour data. I output each pixel in RGB format, so that the pixel at (15,30) should have 3 colour values, R from 1st image, G from 2nd and B from 3rd.
>>
File: tuvan wew.jpg (36KB, 800x600px) Image search: [Google]
tuvan wew.jpg
36KB, 800x600px
>>62007895
>>62007940
>newfag can't into inspect element
WEW
>>
>>62007958
non-C# and non-Javascript-meme-framework things
>>
>>62007984
>doesn't notice obvious irony when it is blatantly presented in front of him
i thought programmers were intelligent
>>
>>62007991
is vb .net and coffeescript meme framework shit good enough
>>
>>62007998
probably even worse tbqh
learn C and dedicate your life to the Linux kernel
>>
>>62007912
>>62007938
what are you like 15?? any reasons behind that??

>>62007958
>>62007971
these guys gets it.

I was thinking that /g/ was a decent space, well, maybe not decent, but at least not-/b/, I'm dissapointed.

Anyway if anyone got a good advice for a rookie looking for a career and just earn some money to get a fucking live, it would be apprecieated.
>>
>>62007997
Programmers often suffer from autism or stunted social development which makes detecting sarcasm/irony among other things difficult.
>>
>>62007997
You were supposed to have meme tabs open like ponies, gay porn and reddit if you wanted to joke.
>>
>>62008014
>learn C and dedicate your life to the Linux kernel

Linus and +10000 devs around the world are doing that.

it's not worthy you fucking NEET
>>
why aren't you learning hoon /dpt/?
>>
>>62008057
why aren't you learning Chinese ?
>>
>>62008067
hoon isn't that hard, and if you're really fed up with the state of computing as everyone claims to be, its really the only place to turn
>>
>>62008109
what the fuck is hoon

can't find anything on google
>>
>>62008109
why's that?
>>
File: 000109-VirtualBox.png (52KB, 922x846px) Image search: [Google]
000109-VirtualBox.png
52KB, 922x846px
roast me
>>
>>62008121
always add "lang" after the name if its not popular.
>>
>>62007853
One thing I may be wrong about is the way grayscale is stored within PNG format. Anyone knows how to read the grayscale values properly?
I was under impression that grayscale refers to color intensity and is stored as percentage ratio from 0 to 100, however upon inspecting values returned by libpng I saw values exceeding 100, which made me believe these already represent the actual color value to be used by each color channel. Am I wrong in this assumption?

I thought about converting these raw values to percentages of 255, however then I would need to revert back again to raw value as percentage of 255, so thought there is no point and just used these.
>>
help
I'm trying to install guile 2.2.2. i got past ./configure, make, and make check without error
but after running sudo make install and sudo makeinstallcheck it seems it's encountered an error

gcc -std=gnu11 `PATH=/usr/local/bin:$PATH PKG_CONFIG_PATH=/usr/local/lib/pkgconfig /usr/local/bin/guile-config compile` -c box/box.c -o box/box.o
/usr/local/bin/guile: error while loading shared libraries: libguile-2.2.so.1: cannot open shared object file: No such file or directory
box/box.c:22:22: fatal error: libguile.h: No such file or directory

trying to run guile encounters a similar error
guile: error while loading shared libraries: libguile-2.2.so.1: cannot open shared object file: No such file or directory

can't find much about this online, but it seems it isn't putting the .so where it should be
anyone know in which build subdirectory it's in, as well as where it's supposed to install to?
>>
Working on a Huffman encoder in golang.

HOLY SHIT golang's grammar is a piece of shit. It's like they're doing everything weird just to not look like Java.
>>
>>62008123
http://moronlab.blogspot.ca/2010/01/urbit-functional-programming-from.html
its a long explanation, but it boils down to defining a vm to be a standard like IP4, building the internet/os off of that, so as to eliminate the cancerous growths that come from building on shifting platforms, among other things
>>
>>62008144
>number += 1
>not number++
>number % 3 == 0
>not !(number % 3)
>number % 5 == 0
>not !(number % 5)
>#define MAX_NUMBER for litereally no reason
>the problem specifically says below 1000 and he uses a define
>int main but doesn't return int
>printf %i instead of %d
>i hate my life
>>
>>62008180
>the future are a bunch of VM's
just kill me now then.
>>
>>62008144
>number += 1
cmon...seriously??
>>
whats my syntax error on the printf line? this is driving me mad
#include <stdio.h>

int main(int argc, char* argv[]){
for(int i = 1; i < argc; i++){
printf("%s%s", argv[i], (i+1) < argc : " " ? "");
}
return 0;
}
>>
>>62008167
you need to install guile-dev
sudo apt-get install guile-dev
>>
>>62008207
You've got your ? and : the wrong way around
>>
>>62007881
You're missing the blue channel.

> 4 color channels

Alpha channel?
>>
>>62008197
Just one vm, defined as a tiny mathematical function. you wouldn't believe the things this buys you
>>
>>62008234
oh wow i'm stupid lol
>>
>>62008224
my repos don't have the 2.2.2 version available, hence why i'm building from source
>>
>>62008195
>#define MAX_NUMBER for litereally no reason
>the problem specifically says below 1000 and he uses a define
>int main but doesn't return int

Please don't roast anyone ever again, your roasted yourself already
>>
>>62008250
add a new repo then lad.
>>
>>62008262
Lol
and why's that?

what i said is correct
>>
>>62008265
but i don't wanna break my stability
>>
>>62007261
how far are you? they feel more like math problems than programming problems desu
>>
>>62008315
that's because they are math problems
>>
>>62006297
hahaha le trolle master xd
>>
>>62008286
how will a possible bad repo break your stability?
>>
>>62008241
Yeah, alpha for 4th.
Also, what exactly do you mean by missing blue? When I run it through photoshop blue channel seems to be there,

I noticed when looking at individual pixels that there seems to be pattern going diagonally every three pixels with highest intensity on those, but yet to spot something dodgy with byte ordering.
>>
>>62008121
probably the best place to start is here
http://media.urbit.org/whitepaper.pdf

warning, it is an extreme rabbit hole
>>
>>62006038
>>62006068
>>62006089
Is this life as a NEET, freelancer or work from home?
>>
>>62008144
>virtualbox
>>
>>62008347
>all that hard work that will get them nowhere

life is suffering
>>
>>62008360
the last one (Me), a NEET.
Can't be fucked freelancing desu.
>>
>>62008360
NEET freelancer working from home
>>
>>62008360
NEET here, middle one
>>
Stuck doing C# in .Net 2.0, (never touched C# before) and havign a hell of a time formatting the Array.Convertall method

https://msdn.microsoft.com/en-us/library/exc45z53(v=vs.80).aspx

I want to convert a 1-d array of strings to a 1-d array of doubles. Seems easy enough, but I can't figure out this syntax, and all of the decent examples I can find use the .Net 4.0 version with
.toDouble
which is incompatible with .Net 2.0.

Can anyone help me out here on this?
>>
>>62008382
How do I get freelance work? I have 10 years corporate experience, it shouldn't be hard but I have no idea where to find the jobs.
>>
>>62008370
I mean, it exists. It runs just fine. whether it gets adopted, is another question which must be weighed against whether the current trash stack that is the internet can last.
>>
File: 000110-VirtualBox.png (73KB, 888x890px) Image search: [Google]
000110-VirtualBox.png
73KB, 888x890px
r8
>>
>>62008435

from stack overflow
double[] temps2 = new double[temps1];

for (int i = 0; i < numsInString.Length; i++) {
temps2[i] = double.Parse(numsInString[i]);
}


or

double[] temps2 = temps.Split(',')
.Select(double.Parse)
.ToArray();
>>
>>62008471
>from stack overflow
dropped
>>
>>62004658
int main ( int arrgc, char[] *argv )
>>
File: fettucine-alfredo.jpg (78KB, 560x360px) Image search: [Google]
fettucine-alfredo.jpg
78KB, 560x360px
>>62008444
>I have 10 years corporate experience

with that experience you should be able to be very well paid.

why are you looking into the freelance route?

tired of corporate slave jobs?

there are tons of free lance websites
>>
>>62008483
why
>>
File: can be used by other program.png (10KB, 1047x66px) Image search: [Google]
can be used by other program.png
10KB, 1047x66px
SHORT WINAPI GetAsyncKeyState(
_In_ int vKey
);


is this reliable? pic related why
>>
>>62007742
Read the file name.
>>
>>62008511
That second one clearly won't work because LINQ wasn't in .NET 2. It was added in 3.5.
>>
I did it. Compiled Qt from source. The build process alone, with examples, tests and the webengine disabled took about an hour and a half on my OC'd 2500k, guess it's showing its age.

Now I just need to compile gdb and somehow figure out how to add global include/lib paths to a toolchain in Qt Creator and I'm set.
>>
File: the game.jpg (183KB, 941x588px) Image search: [Google]
the game.jpg
183KB, 941x588px
>>62008534
read the file name
>>
>>62008528
Will you be checking the least-significant bit to see if its been a repeat?
Will you have other programs using Hooks into yours?
>>
>>62008144
>online compiler
>>
>>62008573
using what?
>>
>>62008144
>using #define MAX_NUMBER 1000 instead of enum { MAX_NUMBER = 1000 }
>using uint32_t instead of int
>using a new line for open brace for loops and if statements
>using %i instead of %d
>using += 1
>using a loop variable name for a loop variable
>not returning 0
Yep, utter trash.
>>
>>62008275
implicit int return and nothing wrnog with defines.
>>
>>62008635
>implicit int return
kek
>>
>>62008633
>using int instead of size_t

ISHYGDDT

>>62008646
>kek
default return value is 0. are you retarded?
>>
>>62007848
Good developers jumping ship in short order is a bad sign. They will work you ragged if you kill yourself to take up the workload. Be warned
>>
>>62008701
did you read the rest of the posts?

they were from Columbia (3 world country)
>>
>>62008646
>If the return type of the main function is a type compatible with int,areturn from the initial call to the main function is equivalent to calling the exit function with the value returned by the main function as its argument;[10]) reaching the } that terminates the main function returns a value of 0. [...]

ISO/IEC 9899:2011 5.1.2.2.3
>>
So I created a new vector *v, how can I delete this?

#include <iostream>
#include <vector>
using namespace std;

void print_range(vector<int> &rng) {
for (int i = 0; i < rng.size(); i++) {
cout << rng.at(i) << endl;
}
cout << endl;
}

int main() {
cout << "test" << endl;
vector<int> *v = new vector<int>{2, 1, 55};
print_range(*v);
v->push_back(32);
print_range(*v);

return 0;
}
>>
>>62008372
Actually, there is a profession of getting fucked on a freelance basis. It's been around a long time
>>
>>62008781
delete v;

But why would you want it on the heap?
>>
>>62008781

>vector<int> *v = new vector<int>{2, 1, 55};
> *v
> FUCKING NEW

NOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
>>
>>62008798
your mom does it?
>>
>>62008808
>>62008807
w-what's wrong, anon?
>>
>>62008781
>push_back
why? emplace_back is far superior to it in everywhere

>>62008828
you shouldn't need to ever call "new" in C++. prefer std::make_unique and std::make_shared if you need something to leave on the heap.

but in this case, stack allocating it ideal.
std::vector<int> v{1,2,3};
print_range(&v);
v.emplace_back(32);

whenever c leaves scope (end of main here), it'll automatically get deleted, and call all dtors of its elements.
>>
>>62008828
Answer the question? Also consider using std::unique_ptr if you absolutely need it on the heap.
>>
Can int* or int& be treated as a type at all times?
>>
>>62008869
yes
>>
>>62008781
Use []operator instead of at() function if you're working within known boundaries.
>>
>>62008856
>you shouldn't need to ever call "new" in C++

what if im writing old C++ the way god intended

i basically write 15 year old c++ but cherry pick the new features i like, like lambdas

>never have issues with raw pointers
>never have issues allocating and deallocating memory
>>
>>62008858
Well, I was just learning how dynamic memory works
>>
>>62008856
fuck, my lack-of-focus grammar made me sound so pajeet.
"every way". and "live on the heap"

>>62008869
in C++? it depends, you may need decltype in some template scenarios. but yes, in general usage they are types. and can be used where other types can be used.
>>
File: 1496318958582.gif (4MB, 356x200px) Image search: [Google]
1496318958582.gif
4MB, 356x200px
>>62008807
heap is the new stack
>>
File: 20245715.jpg (20KB, 468x305px) Image search: [Google]
20245715.jpg
20KB, 468x305px
>>62008856
>std::make_unique and std::make_shared
>>62008858
>std::unique_ptr

Which one?
>>
vectors and strings belong to the heap, along with classes and everything
>>
>>62008906
std::unique_ptr<T> is the type you want to use, std::make_unique<T>(...) is the function you want to use to create an object of that type.
>>
>>62008924
Also, arrays that are known in compile time and other constants are to be stored in the stack, most of it
>>
>>62008924
They belong on the stack because their data is on the heap anyway.
>>
>>62008906
make_unique and make_shared are (newish) utilities to ease the creation of smart pointers, it reduces the boilerplate considerably.

you use unique when you want single ownership of the pointer, you use shared when you want to share ownership.

(there's also weak_ptr, but thats a more advanced usecase)
>>
What book did you guys read?
And why am I being taught to use new then?
>>
>>62008966
None, and you're reading outdated material.
>>
int inc_bazp( foo *p )
{
01331700 push ebp
01331701 mov ebp,esp
return p->baz++;
01331703 mov edx,dword ptr [p]
01331706 mov eax,dword ptr [edx+18h]
01331709 lea ecx,[eax+1]
0133170C mov dword ptr [edx+18h],ecx
}
0133170F pop ebp
01331710 ret

int inc_baz( std::unique_ptr<foo> &p )
{
00AC16E0 push ebp
00AC16E1 mov ebp,esp
return p->baz++;
00AC16E3 mov eax,dword ptr [p]
00AC16E6 mov edx,dword ptr [eax]
00AC16E8 mov eax,dword ptr [edx+18h]
00AC16EB lea ecx,[eax+1]
00AC16EE mov dword ptr [edx+18h],ecx
}
00AC16F1 pop ebp
00AC16F2 ret
>>
>>62008966
Any 'good' book written after 2011. Previous programming experience? A Tour of C++. No programming experience? Programming -- Principles and Practice Using C++. Both by Bjarne Stroustrup
>>
>>62008983
what sepples do you read after BS first book?
>>
>>62008983
Give me an uptodate material, for someone who knows just some basic programming
>>
>>62008966
dont drink the kool aid. we've been using new and delete for decades and no one has died.

sometimes it's even okay to malloc and free
>>
>>62009002
Principles and Practice Using C++ (2nd Edition)
C++ Primer (5th Edition)
Effective Modern C++
>>
>>62008983
>you're reading outdated material
Nothing wrong with using new. You can't always have your object lifetime's bound to a scope. Smart pointers are great when this is the case though.
>>
>>62009068
>You can't always have your object lifetime's bound to a scope.
How so?
>>
>>62009079
Sharing your object between different address spaces is an example case.
>>
>>62009097
I don't pretend he shouldn't use smart pointers here but there are use cases for new outside of implementing said smart pointers.
>>
>>62009079
I just did some research and you still need to use the new keyword even with smart pointers

are you slow? there's no other way to allocate dynamic memory
>>
>>62009128
How so? Can you provide an example? Or are you saying that make_shared/unique internally also use an allocator in which case yes, I'm not arguing that they're not, I'm just saying you're not gonna use new explicitly.
>>
>>62008992
inc_bar(foo*):
mov eax, DWORD PTR [rdi]
lea edx, [rax+1]
mov DWORD PTR [rdi], edx
ret
inc_baz(foo&):
mov eax, DWORD PTR [rdi]
lea edx, [rax+1]
mov DWORD PTR [rdi], edx
ret
inc_qux(std::unique_ptr<foo, std::default_delete<foo> >&):
mov rdx, QWORD PTR [rdi]
mov eax, DWORD PTR [rdx]
lea ecx, [rax+1]
mov DWORD PTR [rdx], ecx

//and
foo *f1 = new foo{};
auto f2 = std::make_unique<foo>();

inc_bar(f1);
inc_baz(*f2); // why pass around a smart_pointer, they are for storage. unless you can't pay for the dereference.. but you shouldn't be using a unique_ptr here, but rather a weak_ptr
inc_qux(f2);
inc_bar(f2.get()); // or be one of these people
>>
>>62009143
i googled the "smart pointers" and every example shows you passing a "new Whatever"

i want to allocate a 1,000 byte array. how to do without new and with smart pointer?
>>
>>62009178
auto arr = std::make_unique<type[]>(1000);
>>
>>62009198
Does that work when specifying the size at runtime?
>>
>>62009198
syntactic sugar is syntactic. make_unique is equivalent to using new with smart pointer
>>
>>62009128
>>62009178
std::make_unique<T>(...) and std::make_shared<T>(...) perfect forward the supplied arguments to a new expression for T, so you don't actually end up having to type "new"
>>
>>62009218
>auto arr = std::make_unique<type[]>(1000);
I tried and appears so. So it's indeed a replacement for the dynamic [] in C.
>>
>>62004691
Ethiopians are white. Not even mememing. I'm half-Italian/half-Ethiopian and I'm 100% white.
>>
>>62008461
>would-be single-line statement with a whole set of next-line braces
every time
>>
>>62009218
Yes.

>>62009235
So you lack reading comprehension, thanks for letting me know this discussion is pointless.
>>
>>62009178
like a byte[1000]? or a void* thats 'size of 1000 * byte' that you'll be casting to an object (say a struct, or a union?) (see code below)

>>62009198
is the standard way. but you can also do..

auto size = 1000; // can be done at 
auto foo = std::unique_ptr<MyType, decltype(free)*>(reinterpret_cast<MyType*>(malloc(size)), free);


if you're dealing with tons of C and using their shitty idea of type systems. but thats a "buyers beware" instance.

>>62009218
yes

>>62009235
ofcourse, but the point is to use a smart pointer. not a raw pointer. (unique_ptr allocates with new and new[] as stated by the spec .. no one is under the illusion that this is some magic allocation).
>>
File: nani.png (3MB, 1661x965px) Image search: [Google]
nani.png
3MB, 1661x965px
>>62009250
>>
>>62009281
i dont evne know what im arguing anymore
>>
>>62009296
Were you thinking about something like
std::unique_ptr<Class> object = std::unique_ptr<Class>(new Class());
>>
>>62009316
no because i dont use smart pointers
>>
>>62009178
 
char array[1000];

If you meant heap allocation use
char* array = malloc(1000);
>>
""""""""AI"""""""" is a total meme. the typical """"""""researcher"""""""" doesn't even recognize that dreams play a significant role. elon musk only gets the bare minimum of sleep just so that he gets more time to micromanage the daily operations of his businesses but he doesn't get enough sleep to have the most "deep" and "profound" dreams. albert einstein on the other hand had a habit of sleeping a lot and subsequently had a lot of dreams.
>>
>>62009477
>with smart pointer?
>>
>>62009477
i would use uint8_t to ensure my char is really 1 byte. not that ive ever seen a multibyte char definition, but it's possible
>>
>>62009522
See
>>62009178
>>62009128

Clearly asking for ways to do without new or smart pointers. Unless I'm reading wrong. It's pretty late.
>>
I have a question regarding C#. I'm making a program that snaps a screenshot then uploads it to my website. You can upload files privately or publicly. Since the public folder is static, I can easily push a file to it. The private folder however should create a directory named after the IP uploading to it. My issue is that I have to allow time for the directory to be created (through FTP). But the code does not wait and tries to upload the image anyway and it fails every time. Can anybody help me figure out the simplest way to wait until the directory exists? I'd prefer not to use a timer if I don't have to as thats kind of just guessing. I was almost even thinking a kind of loop that would check if the directroy exists or not and once it does then continue with the code, but I don't know exactly how to go about doing that.


if (!Properties.Settings.Default.uploadprivately)
{
ftpurl = "ftp://96.35.205.122/public/";
}
else
{
WebRequest request = WebRequest.Create("ftp://96.35.205.122/private/" + externalIP);
request.Method = WebRequestMethods.Ftp.MakeDirectory;
request.Credentials = new NetworkCredential("packlemore", "");
//This is the problem, the directory above does not exist yet. It fails to upload so I need to wait until it's there. Whats the simplest way to achieve this?
ftpurl = "ftp://96.35.205.122/private/" + externalIP + "/";
}


any help is greatly appreciated
>>
>>62009545
It'll always be 1 byte. It just might not be 8 bits.
>>
>>62009545
no it's not, char is guaranteed to be 1 byte
>>
>>62009546
/without/ new and /with/ smart pointers, the thing that person was looking for was std::make_unique/shared
>>
>>62009564
>>62009571
False

>Type char is an integral type that usually contains members of the basic execution character set — By default, this is ASCII in Microsoft C++.

it's platform dependent and arbitrary. in practice it is usually 1 byte, which is what i said, but not guaranteed. read a book
>>
>>62009561
Save it to a temporary location and have the program move the files to their correct location later. If it's just the time it takes to create a new directory then it'll be next to instantly. You can even have a separate process do that for you if you wish.
>>
>>62009604
filtered
>>
>>62009616
go back to java
>>
>>62009604
>When applied to an operand that has type char, unsigned char, or signed char, (or a qualified version thereof) the result is 1.
>>
>>62009235
>syntactic sugar is syntactic
it's semantics, not syntax

>make_unique is equivalent to using new with smart pointer
yes. you can also supply a custom deleter which will get called when the unique_ptr is reset, reassigned, assigned nullptr, or goes out of scope without being moved to another one. which is also useful. move semantics, that is. unique_ptrs can be moved but not copied (which helps naturally enforce the idea of single ownership). shared_ptrs can be copied (which increments their reference count) or moved (which moves them to another scope, but leaves the reference count the same - useful because it avoids an atomic increment. these semantics coincide with the idea of shared ownership)

make_shared, by the way, is actually more efficient than calling a shared_ptr constructor because it uses perfect forwarding to allocate the shared object and the control block in the same allocation, as opposed to one allocation when you call new to supply the pointer to the constructor, and another when shared_ptr's constructor allocates the control block

>>62009332
you might consider looking into it. they're pretty intuitive, and there's no real reason not to use them (or at least unique_ptr, which doesn't incur additional cost over raw pointers and new/delete, except maybe if you do something unusual like pass a mutable lambda as a deleter or something). custom deleter are pretty useful (you can even use them to easily implement things like scope guards, have a C library opaque pointer automatically call its destruction function at scope exit, etc). shared_ptr does however incur a cost (reference count increments/decrements are atomic), so generally it's best to bias toward unique_ptrs unless the use case particularly demands shared ownership. even if you only used strictly unique_ptrs, you'd likely still find it beneficial
>>
>>62009604
>quote
>unknown source
Learn what a byte is. Read the spec.
Thank God for filters.
>>
>>62009546
pretty sure, from the context of debating new vs smart pointers. they are on the side of new and wanted to know how you'd do an array[1000] with a smart pointer, which someone then replied with. (just pass the size to make_shared/unique). not a way to allocate memory that doesn't use new or smart pointers

(but I can see how their phrasing is a bit wrong. "without new and with smart pointer?" I read it as (without new) && (with smart pointer). I can see how you got it as (!(new && smart pointer)))

>>62009604
Sort of false, because since C++14: a char is defined to be large enough to represent any UTF-8 character.

>>62009641
Thats correct for C++11 and prior. in C its different, but C++ doesn't have the same definition of a char.
>>
File: pol_word_cloud.png (580KB, 1500x1500px) Image search: [Google]
pol_word_cloud.png
580KB, 1500x1500px
Built this Word Cloud in Python from a subset of /pol/'s current archived threads. Wasn't that hard using the available libraries out there, but still fun to do.
>>
>>62009606
Thats actually what it does now. It saves it to the users temp folder but I don't have a way for it to wait to upload. I just need to know what method I should use to make it wait. It doesn't create the folder instantly, it has to connect first which is slower than the code is running. Should I just throw it on a timer for like half a second?
>>
>>62009669
Nice picture anon.
Do it for dpt plz.
>>
>>62009657
>a char is defined to be large enough to represent any UTF-8 character
Soooo, one byte?
>>
>>62009684
Check if the file is done uploading then move it? I'm not sure I follow. It's very straightforward normally.
>>
>>62009641
quote is from MSDN

bits in a byte is platform dependent, read a book

a char can be any size, read a book
>>
>>62009715
you could have a platform with a 32 bit byte, and you would have a 32 bit char, but the char would still be 1 byte
>>
>>62009545
C++17 defines std::byte which is a type that can be used to access memory in the object representation like signed/unsigned char arrays, but is a distinct type (not a character or arithmetic type; can help avoid automatic conversion and overload resolution issues or simply clarify intent), and only defines bitwise logic operators
>>
>>62009715
Why are you repeating what he said anon?
>>
>>62009715
the "size" refers to the number of bytes, not the number of bits
>>
>>62009730
you could have a platform with a 3bit byte, but a 9bit char, char would be 3bytes.

you remind me of the retards on /g/ arguing javascript isnt an interpreted language
>>
>>62009755
no because sizeof char == 1
>>
>>62009764
sizeof(char) == 1
>>
>>62009755
>interpreted language
No such thing.
>compiled language
No such thing.
>you
Retard
>>
>>62009771
sizeof is an operator, not a function
>>
here's a fun question for the "hurr durr" C is a subset of C++.
do sizeof('a') in C and sizeof('a') in C++ return the same type? if so, what type is it? if not, what types are they?
>>
>>62009771
It's an operator not a function, syntactically.
I wonder what the point of that was.
>>
>>62009764
sizeof(char) == 1 is only true on platforms where a character is defined as 1 byte

if built-in integral types in C++ were defined by byte widths, stdint wouldnt exist

>>62009789
average /g/ programmer

>>62009796
no, it's int in C and char in C++

who says C is a perfect subset of C++?.
>>
>>62009705
Hmmm, actually it turns out its never even making the directory. No error, just doesnt do anything. I don't see why that code wouldn't work considering I've used it on a previous version. I can FTP with filezilla and create a dir in that same folder but the program will not create it. Do you have any ideas why that might be?
>>
>>62009828
plenty of retards in these threads do.

and you're wrong about >sizeof(char) == 1
from the standard:
$5.3/3
> [...] sizeof(char), sizeof(signed char) and sizeof(unsigned char) are 1. The result of sizeof applied to any other fundamental type (3.9.1) is implementation-defined.
>>
>>62009794
>>62009801
you need parens around types fucking summerfags
>>
>>62004982
I wanna see that baby launch.
>>
>>62009861
also from $5.3/3
> The sizeof operator shall not be applied to an expression that has function or incomplete type, to an enumeration type whose underlying type is not fixed before all its enumerators have been declared, to the parenthesized name of such types, or to an lvalue that designates a bit-field.

go away.
>>
>>62009869
you're reading it wrong idiot. why do you think they use parens in >>62009854
>>
>>62009828
>if built-in integral types in C++ were defined by byte widths, stdint wouldnt exist
they're defined by byte widths per platform within the constraints stated in the standard. stdint varies across platforms. also char is special, it's defined differently than signed/unsigned char
>>
File: 1499967853235.gif (90KB, 283x300px) Image search: [Google]
1499967853235.gif
90KB, 283x300px
>>62008315
not very far, only at problem 10 or so.
>>
>>62009853

Nevermind, I got it.
>>
>>62009885
yall niggas are right
>>
>>62009879
>you're reading it wrong
>"the size of operator[...]"
It seems pretty clear.
>>
>>62009918
you're being ridiculous

https://stackoverflow.com/questions/5894892/why-and-when-do-i-need-to-use-parentheses-after-sizeof
>>
>>62009924
But he's not reading it wrong at all.
>>
>>62009956
it's sizeof(char) not sizeof char

kill yourself
>>
>>62009959
That's not what that post was about clearly.
>>
>>62009972
yes it was you fucking retard
>>
>>62009959
i think he gets that but is referring to the fact that the standard excerpt you posted doesn't actually address that
>>
char.sizeof desu
>>
>>62009984
i didn't post a fucking standard excerpt. learn to follow a conversation. it's a very simple back and forth starting with >>62009764 >>62009771
>>
>>62010000
nice quads fuckface
>>
>>62010000
i just figured it would have been you based on your talking shit to
>But he's not reading it wrong at all
who is correct
>>
>>62010077
he's reading it wrong because he quotes an irrelevant part of the standard and takes it to mean that sizeof doesn't need parentheses
>>
>>62010099
haha oh, shit. i see it now. had it turned around. my bad i haven't slept in a couple days
>>
>>62010137
lol it's ok
>>
File: 1471930900569.png (437KB, 748x410px) Image search: [Google]
1471930900569.png
437KB, 748x410px
Post memes that one shouldn't fall for when getting into programming.
>>
>>62010238
Any advice given to you by /g/
>>
>>62010238
>OOP is bad
>muh haskell
>muh python
>>
>>62010238
functional programming anything

C++ cant be used for microcontrollers

automatic garbage collection
>>
>>62010238
"learn C first"
"learn Lisp"
"lean java"
"apply for a job in a language you hate"
"global variables"
"there are safe side-effects"
"c++ just takes time"
"read sicp even if you dont want to learn lisp"

to start
>>
>>62010238
>Go is slow
also these: >>62010257 >>62010264
>>
>>62010238
C++
>>
I'm coming back to using C after not touching it in a long time, valgrind is giving me some complaints but I can't figure out what it is I am actually doing wrong, can someone quickly diagnose it for me?

valgrind output: https://pastebin.com/iKApZ1mv

code: https://pastebin.com/i7qnsh2k
>>
>>62010352
please rewrite (x != NULL) to just (x) and (x == NULL) to (!x)
>>
>>62010393
I understand that they are the same thing but isn't it best practice to be explicit?
>>
>>62010352
might need to initialize root to NULL

>>62010422
yeah checking against NULL is fine
>>
>>62010422
in my opinion it's overly verbose, any programmer knows what (x) and (!x) evaluate to by sight
>>
>>62010433
yeah this

make this
typedef struct tree{
node *root;
} Tree;


become this
typedef struct tree{
node *root = NULL;
} Tree;
>>
>>62010352
Well, for starters, I see that when you malloc stuff, you don't initialize it properly.

Tree * t =  malloc(sizeof(Tree));

Here you initialize the thing but don't set t->root to NULL, before it's used on tree_insert. Set all shit to NULL when you malloc, and you should be good to go. For both nodes and tree.
>>
>>62010433
I had to initialise root and the node values to NULL. Does initialising a struct to NULL not set its values to NULL by default as well?
>>
File: 2017-08-21-054813_096221163.png (141KB, 1674x1157px) Image search: [Google]
2017-08-21-054813_096221163.png
141KB, 1674x1157px
static GLfloat * get_rgb()
{
srand(1u);
static GLfloat rgb[100*100*3];
unsigned int index_counter = 0;
for (int i=0; i<100; i=i+1)
{
for (int j=0; j<100; j=j+1)
{
rgb[index_counter] = (GLfloat) rand();
rgb[index_counter+1] = (GLfloat) rand();
rgb[index_counter+2] = (GLfloat) rand();
index_counter = index_counter + 3;
}
}
return rgb;
}


am I retarded about my use of static?
i.e should only the function be declared as static, such that the compiler only treats the array as static once it has been constructed and its location returned?
>>
>>62010506
>>62010493

Gotchya, thanks guys.
>>
>>62010512
>Does initialising a struct to NULL not set its values to NULL by default as well?

not sure what you mean by this. if you make a pointer null that isn't making a struct null. and no, there's no default initialization
>>
>>62010534
My mistake, for some reason I thought there was default initialization,
>>
>>62010515
the array needs to be static
>>
>>62006469
Would make a good shoegaze album cover desu.
>>
Using xinput in a win32 program to use a gamepad as a mouse. So far it kinda sucks.
>>
>>62010592
Just use SDL fgt.
>>
Do you guys follow any people related to this field? I only follow political pundits and can't see how I would follow anyone related to this field.
>>
>>62010515
why no += syntax
>>
>>62010277
Go is slower than Java
>>
>>62010661
it feels a bit awkward but I guess I should
>>
>>62010515
Static functions can get called multiple times. What static does for functions is to limit the scope to the C file where they exist.
Without making a global and initializing on main, you can pull off something like this:
GLfloat *testfun() {
static GLfloat rgb[100*100*3];
static int init = 0;
if (!init) {
srand(1u);
unsigned int index_counter = 0;
for (int i = 0; i < 100; i = i + 1) {
for (int j = 0; j < 100; j = j + 1) {
rgb[index_counter] = (GLfloat) rand();
rgb[index_counter+1] = (GLfloat) rand();
rgb[index_counter+2] = (GLfloat) rand();
index_counter = index_counter + 3;
}
}
init = 1;
}
return rgb;
}
>>
>>62010655
no, there are very few "advancements" in the field that you really need to keep up with, like new language standards and such
>>
>>62010739
so my understanding is that a static array is only initialized the first time.
A static function then is a separate concept, some sort of safeguard to avoid other files from calling/seeing it when included?
>>
http://box.endurehosting.com/contents/public/Main.cs

Ok, so this is pretty odd. I was testing out the 'run at startup' feature in my program and when I restarted, I blue screen'd every time with a "systems service exception" error every time until I removed it from the registry manually in safe mode. Can anyone identify why this may be the case? Perhaps I'm trying to call something before it's ready?
>>
>>62010903
a static array can be written to many times, it's just that it has static storage duration, so it will keep its state, whereas if the array is non-static it would be invalid to read from it through the returned pointer and it wouldn't keep its values between different calls to testfun
>>
>>62010903
Yes. The idea with static variables is that the initialization runs once. After that, the line gets ignored.
static GLfloat rgb[] = {1, 2, 3, 100, 500};

That would run once, whenever the compiler decides to allocate that stuff. Too bad you can't compact the initialization into a function.
>>
>>62010913

Ok on second thought I don't think it's the program. It was just a coincidence because I blue screened again went to remove it from startup again and its not there. Fuck I have something else going on.
>>
>>62011039
Check your harddisk
>>
New thread:
>>62011075
>>62011075
>>62011075
>>
>>62011055

I have 2 SSDs in raid. Neither of which are over 3 years old. I have a bunch of windows updates, I'll start with that and disabling my overclocks. Do SSDs suffer from that kind of error often or is it mostly HDDs?
>>
>>62010449
They're not the same thing. NULL merely has to be defined as a runtime invalid address. This is not always 0.
>>
>>62011111
NULL always compares equal to zero
>>
>>62011111
>>62011303
The underlying representation of NULL doesn't have to be zero, but it assigning a zero a pointer will produce NULL, and it will always compare as false.
Thread posts: 367
Thread images: 40


[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.