/dpt/ - Daily Programming Thread

old thread: What are you working on, Sup Forums?

Other urls found in this thread:

en.cppreference.com/w/c/string/byte/strncpy
twitter.com/AnonBabble

killing myself.

How do I pass values by reference in javascript?

I can help with that.

Man only knows true peace after he has shuffle'd off this mortal coil.

can the retarded java is pass by reference faggot please stay in the old thread thanks

Consumer & disposable helium tanks are no longer 100% helium and won't work with this method, just FYI

Can somebody help me understand this haskell code?
primes = 2 : primes'
where isPrime (p:ps) n = p*p > n || n `rem` p /= 0 && isPrime ps n
primes' = 3 : filter (isPrime primes') [5, 7 ..]

I don't understand how one can use primes' inside primes' definition, since it is an infinite list.

Repost bc maybe someone has a clue why this prints 0 AND 1
#include
#include

int main()
{
double sineSignal;
double my_pi = 3.141592653589793;

sineSignal = std::sin(my_pi/2);
std::cout

by not using javascript

IEEE-754 b64.

shouldn't the integers be doubles

(1/2) returns an int due to them both being ints. Do (1/2.0), or (1/2.f) if you were working with floats.

Useless post. Filtered.

I'm guessing 1/2 is integer division, so the result is 0. Try 1.0f/2.0f, for example.

>i'm a retarded and i don't follow the standard IEEE convention

hello reddít

>o != o[0].
>pass by reference syntax
using System;

class Program
{
static void foo(ref object o)
{
o = null;
}

static void Main()
{
object o = new object();
foo(ref o);
if (o == null) {
Console.WriteLine("passed by reference");
} else {
Console.WriteLine("passed by value");
}
}
}

inb4
>that's not pass by reference in C# because ref o != o
>why don't you compare "ref o" against "null" in Main
Please don't be this stupid.

>strawman out of nowhere
Put your tripcode back on.

Fuck off with this shit already.

Look at the C# "equivalent"

>DELETE THIS
Out of arguments, my mentally impaired friend?

Would you happen to have an un-fucked (compressed to hell) version of that picture; or be able to point me to the article?

>double my_pi = 3.141592653589793;
double my_pi = acos (-1.0);

>>strawman out of nowhere
>Put your tripcode back on.

I don't take it off to post niggers on Sup Forums, /s/, and /hc/, so I definitely wouldn't take it off here.

Get ahold of yourself.

How do I write an array of arrays in C?

>I don't want multidimensional array

Reverse image search will get you to it.

No, the shitposting should just stop with the last thread.

An array of arrays is a multidimensional array, a multidimensional array is not an array of arrays.

they are the same thing

>shitposting should just stop
Got told hard, eh?
>multidimensional array is not an array of arrays
Prepare your anus again!

>No, the shitposting should just stop with the last thread.

Pass an array to a function, then. That's a reasonable simple thing to do, right?

mercilessly rate my sort
import re

splitter = re.compile( r"\d+|\D+" )

def split_compare( a, b ):

longer, shorter, mult = ( a, b, 1 ) if len( a ) >= len( b ) else ( b, a, -1 )

for i in range( len( longer ) ):
if i >= len( shorter ):
return 1 * mult

try:
l_part = int( longer[ i ] )
s_part = int( shorter[ i ] )
except ValueError:
l_part = longer[ i ]
s_part = shorter[ i ]

if l_part > s_part:
return 1 * mult
elif l_part < s_part:
return -1 * mult

return 0

def smart_sort( *strings ):

presplit = [ ( s, splitter.findall( s ) ) for s in strings ]

return [ p[ 0 ] for p in sorted(
presplit,
cmp = lambda a, b : split_compare( a[ 1 ], b[ 1 ] )
) ]

typedef struct trip {
Date date;
char destiny[MAX];
int seats_available, max_seats;
} Trip;

I got this struct, why can't I simply do destiny = "Paris"; ?

Thanks, didn't knew that.

Interestingly, both equations return 1 when I change the compile settings in QtCreator to debug.

>multidimensional array is not an array of arrays
why would you contradict the C standard? is your mouth itching for a big dick?

>return 1 * mult
>return -1 * mult

Because destiny is an array and not a pointer.

inb4
>b-but arrays are pointers

Not exactly.

>[][][][][][][] == [][]
Go home.

I swear, C is the only language that can offer so much entertainment with this crowd of retards! Keep it up!

So, how can I make it work? Sorry for wrong quote I forgot to delete the quick reply

not exactly inb4? how do you know?

>>> from datetime import datetime
>>> t = datetime.utcnow()
>>> print t
>>> datetime.strptime(t, "%d-%m-%Y %H:%M:%S")
ValueError: unconverted data remains: .86400


Help

You must do a for loop (or a mem copy) to copy the value of your static string to your array.

nah, I'll stay and rape your fat stupid face :^)

Yes I am lazy

>dodging the questions
user...

arrays in C decade to pointers every time they get passed to a function.

how do you know it's "not exactly inb4"?

Or used as a pointer.

That's what the >inb4 meant, dumbass

>decade to pointers
the fuck is that?

help

>arrays
>every time they get passed to a function
you can't pass arrays to a function

pass-by-reference cucks BTFO!

>Useless post. Filtered.

That's true, I'm retarded and didn't read gud. To be fair, though, IEEE is the problem in 99% of "Why doesn't this float/double calculation do what I expect?" posts.

>you can't pass arrays to a function

What a shitty language.

Jesus christ all I want to do when creating a trip is
Trip paris;
paris.destiny = "Paris"';

And I apparently can't do that

Is this C or C++? If it's C++, use std::string. If it's C, choose another language or resign yourself to strcpy_s()

strncpy (paris.destiny, "Paris", MAX);
Maybe "Paris" must be allocated to a static variable.

>I'm surprised by this
standard webshit, as usual

I recall that Ritchie said the entire thing was a fucking mistake.

try javascript, it was literally made for you

I can't.
This C assignment I'm supposed to make a "travel agency" with linked lists, queues, reading from files etc...
It's supposed to be able to choose a trip, cancel it, if full then go to a queue, list all trips to a destiny list all trips by a client, etc etc...

>C programmer
>can't take criticism

Enjoy your shrinking programming niche

>what is c++

I was told by Sup Forums that my project was shit so now I am working on a CLI anime folder organizer written in C; pls do not judge

>criticism
>from webshits
you're out of your element, "html programmer"

But all this does is organize my anime folder?

you didn't understand: YOU can't pass arrays to a function; competent programmers can

Use strncpy en.cppreference.com/w/c/string/byte/strncpy the page is C++ but the function is available to C99 and later.

>covert hime thread

I like this.

You don't.
There's literally no possible way to pass a reference to a variable.

its shit

Why the MAX?

you shouldn't give advice if you don't know what the fuck you're talking about

Its not ready yet, soon all you neckbeards will be organizing your anime folders automatically with my command line application

>you're out of your element, "html programmer"

And you STILL can't pass an array to a function.

What if you don't have any anime?

lel k what's your solution?
I mean if all destinations are known at link time sure you can just reference them.

What about my hentai? Does it look for tags?

of course I can, see for more information

>you didn't understand: YOU can't pass arrays to a function; competent programmers can

From Dennis Ritchie himself

" The rule, which survives in today's C, is that values of array type are converted, when they appear in expressions, into pointers to the first of the objects making up the array."

DENNIS FUCKING RITCHIE.

Organinzing? Can you explain how it works? I'm actually kinda excited.

memcpy

What language is it in? C? Why not Python?

To protect from writing outside of the array.

yes, and you're not competent enough to figure out how to work around that

Do "vec4(f_color, fade);"

void PrintArray(int arrah[], int arrayElements) {
for(int i=0; i

>DENNIS FUCKING RITCHIE.
he's a fag, err was*

Do you have this on Github yet?

How do you justify that above strncpy()?

that's a pointer, donkey

>yes, and you're not competent enough to figure out how to work around that

BTFO BY THE LANGUAGE DESIGNER HIMSELF.

work around to pass an array to a function, my fucking sides.

As I said you can't pass an array to a function in C, and Dennis Ritchie agrees with me.

it doesn't do stupid shit

What are you guys going to do when blo-lang (aka Jai) revolutionizes programming?

Stroustrup, Gosling, Rossum, Hejlsberg, and Alexandrescu are planning a group suicide for its release day.

bampu~

>agrees with me
he agrees that stupid shits should stick to css

>programming
>2016

Programming is being made obsolete under your feet and you crusty C autists are too stupid to realize it.

Nobody will be programming in 20 years from now, software development is over.

I am sorry guys this was a joke, I said that Sup Forums would not make fun of my project if it were a "command line application written in C" and the people I was talking to said Sup Forums was not this way. So while I am sorry I got you guys excited for nothing, I know have evidence that Sup Forums would not make fun of my project if it were an anime organizer and for that I thank you.

You passed a pointer and a length. That's differente tha an array, and it's retarded.
You should be able to do something like this.

void PrintArray(int arrah[]) {
for(int i=0; i< length(arrah) ; i++) {
printf ("This would the element %d of a true array, if C were a sane language", arrah[i]);
}
}

(¯―¯٥)