[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: 318
Thread images: 29

File: 2d_Nazi_031.jpg (329KB, 650x851px) Image search: [Google]
2d_Nazi_031.jpg
329KB, 650x851px
Old thread: >>57087452

What are you working on, /g/?
>>
Thanks for using an anime image
>>
>>57092926
weird, I ran it directly from the command prompt rather than from the exe, which opens cmd, and it runs normal now

wtf

is there a difference if i just open it from the exe file?

I've only used languages that use interpreters
>>
File: cancer.png (15KB, 1003x320px) Image search: [Google]
cancer.png
15KB, 1003x320px
Working on my terminal emulator, I got a couple of vttest tests working today (one pictured in the screenshot).

That was actually pretty hard to get right because it abuses a couple of retarded VT-100 controls like DECALN.

On the bright side I conjured an optimal script for terminal reeing.

echo -e "\e#8\e[rR"
>>
File: 1476391554596.png (910KB, 1024x768px) Image search: [Google]
1476391554596.png
910KB, 1024x768px
thanks for using a nationalist image
>>
>>57092946
Is Go a good language to start with?
>>
>>57093000
awful language to start with
>>
>>57092980
when you run .exe directly, console window gets closed when program ends
when you run it from command prompt you still have that command prompt and history on screen
>>
>>57093000
No, and it's a shit language in general.
>>
>>57093013
>>57093017
retards
>>
>>57093000
fuck no, it's not good for anything, it's a horrible language
>>
>>57093023
Google shill, only retards use it, they made the language explicitly for them.
>>
are there hackers on /dpt/? i'm playing a hack game and i'm running into a problem.

this is the file i'm looking at
http://pastebin.com/B7igYgNA

and this is the hint page http://overthewire.org/wargames/bandit/bandit13.html

if you want to connect and see what i'm seeing, you can
ssh bandit.labs.overthewire.org -l bandit12

password is 5Te8Y4drgCRfCx8ugdwuEX8KFC6k2EUu


please help me
>>
>>57093015
so what happened when I input ^Z/^D(ctr z/d) or a non int input on the exe? it terminated even though there was code left, so that means exe will always close on errors not handled?
>>
>>57093000
Yes, the semantics of the language are very minimal and straightforward and it's easy to come to terms with the basics of programming in it.
>>
File: 1476451358764.jpg (676KB, 1580x2238px) Image search: [Google]
1476451358764.jpg
676KB, 1580x2238px
>>57093000
>>
>>57093055
i tried doing bunzip2 of the xxd -r of the file and it said it wasn't a valid file type for bz2. maybe i did it wrong, idk. but it said it was ascii when i did it
>>
>>57093045
Using languages designed exclusively for smart people will not make you personally any less of a retard.
>>
>>57093071
sql needs to be lower
>>
>>57093078
Here, have your complimentary interface {}, (((you))) deserved it
>>
>>57093078
Is C++ for smart people? I just want to game dev cool physics without my brain exploding ;_;
>>
>>57093056
I was wrong, you should hit ctrl+z because that's how you send eof on windows. ctrl+d is on linux
when you sent eof, cin returned false, because that's not an int, so code inside that while wasn't executed and you got out of that while loop
>>
>>57093013
>>57093017
>>57093037
>>57093057
>>57093071
All I ever wanted is a compiled language what requires less typing and looks nice
>>
>>57093109
>Is C++ for smart people?
yes

especially for game dev, the only reason to use anything besides C++ is a lack of competence
>>
>>57093129
will I make it fampai ;___;
>>
>>57093124
>less typing
get a good mechanical keyboard and learn how to type properly
>>
>>57093124
Go was designed from the ground up to be condescending to the user.
>pointers exist, but no pointer arithmetic allowed
>unused vars are a compile-time error
>unused functions are a compile-time error

It's like C, no fun allowed edition.
>>
>>57093107
lol you caught me goyim, that post was all part of my evil jewish scheming. you crafty pollacks get more clever every day

>>57093109
It's on the high end of the bell curve of languages that weren't designed purely for academic purposes. It probably has the best selection of libraries and tutorials for game development though; having another level of indirection while using a wrapper around SDL in another language sucks on a number of levels. If you want to do video games you should try to come to terms with it.
>>
>>57093160
>unused functions are a compile-time error
this is not true
>>
>>57093160
What do you suggest then? C is actually okay but anything other than C?

See >>57093124 for my constraints
>>
>>57093160
>pointers exist, but no pointer arithmetic allowed

There's no pointer arithmetic because the language was designed at a level of thoroughness that exceeds C. You don't pointer arithmetic in a language with basic inbuilt support for strings and arrays. Leaving it in is nothing but an idle security vulnerability, hence why Ada, Rust and every secure C variant forbid it. Even C++ tries to promote the use of iterators instead.

>unused functions are a compile-time error

No, they aren't.
>>
Guys, I am confused. I have learnt that I can change the value of an array element with a function. But I read this on a book yesterday:
"The reason an array behaves differently from a simple variable or an array element—
whose value cannot be changed by a function". So, is there something I don't understand, or is the book wrong? I need to clarify this to calm my autism. Thanks in advance.
>>
>>57093257
It sounds like it's describing pass-by-reference semantics for arrays in C, but I have no idea what language or book this is or any other context, so there's no point spending time trying to explain it.
>>
File: Fib2sWc.png (78KB, 282x300px) Image search: [Google]
Fib2sWc.png
78KB, 282x300px
If you were to create a programming language, how it will look like?
>>
>>57093257
I don't really understand your question but I think that quote is just talking about how arrays can only be passed by reference. You can never take out a single element and play with it, you are basically telling the function the address of the array and that is how you are changing the values of elements.
>>
>>57093296
>>57093317

My apologies, I should have formulated my question a bit more clearly. This exert came from Kochan's "Programming in C" book. I guess I need to really try to understand the whole "passing by reference vs passing by value" thing in C. Thanks for your answers.
>>
>>57093302
Sexp-based with a type system at least as good as Haskell's.
>>
>want to list all files in directory using python
>there are 100 ways of doing this

why is this allowed?
>>
>>57093302
It would probably be pretty similar to C.
>>
>>57093302
low level scripting
>>
>>57093356
Despite Python's sloganeering I don't think there's a way to stop users from coming up with new ways to do things in a turing-complete language.
>>
>>57093356
>using python
why is this allowed?
>>
Has anyone else made it to Google's host matching process? How did it go/is it going for you?
>>
>>57093376

what language should I use for scripting them?
>>
How do I get the dimensional width and length of a 2d array in C

void displayHands(struct hands **test)
{
printf("INSIDE\n");

float cardsPerHand = sizeof(test)/sizeof(struct card*);
printf("%f", cardsPerHand);
}


I've tried all sorts of divisions via tutorials and nothing works, or I get 4 for some reason when that isn't true.
>>
>>57093401
>""""scripting""""
why is this allowed?
>>
>>57093413
You declare two constants before you declare the array.
>>
>>57093421
because people need to run scripts
>>
>>57093413
https://stackoverflow.com/questions/1281686/determine-size-of-dynamically-allocated-memory-in-c

TLDR: There is no way defined in the C standard and typically you keep track yourself or use some nonportable code. Unfortunately.
>>
>>57093413
You can't. C doesn't store the size of an array anywhere by default. sizeof(test) returns the size of the pointer. You need to pass in the length with the array.
>>
>>57093432
>>57093450
>>57093460

Right now the user defines the dimensions via input, so I'd have to use that.

I was looking for a more dynamic approach but if there are limitations I guess I have no choice.
>>
>>57093460
The type system knows the size of an array, but what he's passing is not one, it's a pointer.
>>
>>57093413
store info about width and height in your struct
#include <stdio.h>
#include <stdlib.h>

typedef struct {
size_t width, height;
char *data;
} letters;

void letters_init(letters *dest, size_t width, size_t height)
{
dest->data = malloc(width * height);
dest->width = width;
dest->height = height;
for(size_t i = 0; i < width*height; ++i)
dest->data[i] = 'A' + (i & 31);
}

void letters_print(letters *dest)
{
size_t width = dest->width;
size_t height = dest->height;
char *data = dest->data;
for(size_t i = 0; i < height; ++i)
{
for(size_t j = 0; j < width; ++j)
putchar(data[i * width + j]);
putchar('\n');
}
}

int main(void)
{
letters foo;
letters_init(&foo, 17, 5);
letters_print(&foo);
free(foo.data);
letters_init(&foo, 9, 3);
letters_print(&foo);
free(foo.data);
return 0;
}
>>
Would someone mind to help me?

I need to use a relatively unknown program, i am on windows, never used any other OS before, have limited skills in programming and the devs provide no support what so ever for windows, except for claiming " it is based on standard C++, should work with mingw, no one here ever cared to try out"

They provide only a .tar.gz file.

What the hell do i do?
>>
>>57093496
I was using "array" in the fungible C-style sense of a describing a pointer that points to one.

Does a C compiler actually do anything with the array size in a declaration apart from using it for static allocation upfront and then discarding it? I mostly use C++ so I wouldn't know.
>>
>>57093568
Build it with MinGW or Cygwin. Once you have it installed, the environment is pretty much just like Linux, so follow the usual instructions.

Or, just run a Linux VM.
>>
>>57093581

mind giving me some instructions on how doing it?
>>
>>57093631
Never used MinGW, but I used Cygwin long ago. Just install Cygwin, (I think you need to tell it to install basic software like apt, make, and gcc, but it probably has them checked already), then open up a shell, cd into the contents of your tar.gz, and follow the directions inside the README it probably has.

It's likely that you need to run ./configure. ./configure will tell you if you're missing anything it needs to compile the project, so tell Cygwin or apt to install it, then run ./configure again. If it tells you no problems, then run make and the project should compile.

This is, of course, without any information on what the software you're building actually is. https://en.wikipedia.org/wiki/Configure_script
>>
>>57093669
So I just checked, you have to go through Cygwin's package manager and not apt, since it has to compile from source and not use apt's Linux binaries.
>>
File: tlpi.png (183KB, 454x600px) Image search: [Google]
tlpi.png
183KB, 454x600px
>>57092946
Reading this cover to cover, typing and compiling every code example, doing every exercise. I'm on chapter 29, the intro to threading. I love this book.

Almost halfway through, I'm on Chapter 29 - Intro to Threading
>>
File: Capture.jpg (10KB, 68x122px) Image search: [Google]
Capture.jpg
10KB, 68x122px
Is making lists within lists a terrible idea? I'm looking at the code involving them and it's just a huge mess. I'm still a beginner programmer (obviously). The idea of my program in general is a flight booking system, which stores all the airports in a list, then each airport also stores all their flights in lists, and within those flights is a list of passengers.

Using C# for a UWP (because that's my assignment) btw.
>>
>>57093000
Yes, it's a very simple language with good documentation and a healthy standard library. It should be very welcoming to a new programmer, especially with the standard toolset, it removes the need to focus on project layout, code style, build systems, compilers, etc. the only thing you have to learn is the syntax and basic ubiquitous programming concepts, if your aim is to learn how to program I think Go is a good starting point.
>>
File: 1474668448311.webm (2MB, 1280x985px) Image search: [Google]
1474668448311.webm
2MB, 1280x985px
This is the 3rd "useful" thing that I made.
>>
>>57093723
Can I ask, are you employed or going to school? When I was doing nothing I spent a lot of time on books like that but I don't have the energy anymore.
>>
>>57093852
post code
>>
>>57093723
What kind of plant is that?
>>
>>57093886
A fern frond
>>
File: 1467873059414.webm (166KB, 350x376px) Image search: [Google]
1467873059414.webm
166KB, 350x376px
>>57093872

#!/bin/bash

for i in *.gif ; do
ffmpeg -i "$i" -c:v libvpx -crf 4 -b:v 500K "$(basename "${i/.gif}").webm" && rm $i
done
>>
>>57093841
use an array (or ArrayList) of Airport objects and Airport has an arrays of Flight objects etc
>>
>>57093915
Would that make it like tidier than lists? What the difference between a list and an arraylist?
>>
>>57093160
Programming's not supposed to be fun you autistic faggot.
>>
http://www.berkshirehathaway.com/
>literally on the top 10 richest company in the entire world
>not willing to spend $10k on a site
A MOTHERFUCKING WEBSITE
>>
>>57093914
Good work anon; ffmpeg is a really practical skill. I use it in a script to encode all my FLAC music as MP3 320 for portable devices. Super convenient, and if you try to do it other ways you have less control/have to use some retarded sketchy software/have to do each file one by one/or some combination.
>>
>>57094021
I'm glad I enjoy programming, then. It'd make for a shitty life if I felt the way you do about it.
>>
>>57094005
it would make it tidier because you'd have "array of Airport" instead of "list of list of list of..."

an ArrayList is a type of list. the data is laid out as an array "behind the scenes" but it has some extra functionality (like growing the array automatically) so that you can use it as if it were any list.
>>
>>57094021
>he is in it for the money
nigga
>>
>>57094028
>your face when they probably paid millions to some consulting firm to make the website during the dotcom boom
>>
>>57094021
it's not supposed to be shitty like go
>>
>>57094060
>Program car
>Segfaults, doesn't recover
>Accelerates into wall
Lol, at least I had fun :^)
>>
>>57094100
lmao
>>
File: 1476044914054.png (375KB, 785x757px) Image search: [Google]
1476044914054.png
375KB, 785x757px
>tfw just got done proving Church-Rosser for combinatory logic in Coq
>>
>>57094028

It looks just fine to me.
>>
>>57094100
You're pulling a straw man. I don't think it's fun to adhere to security standards and work on some corporate project. Certainly more rewarding than working a register that will be replaced with a kiosk in 5-10 years, but I'd do it to make a living.

I write personal projects and learn about CS because I want to, and making cool things/using them are fun to me. I'm not arrogant enough to think all of programming is "not supposed to be fun" just because of my personal opinion.
>>
>http://www.gwan.com/blog/20160405.html
>https://www.youtube.com/watch?v=9No-FiEInLA
>don't major in useless easy majors like marketing they said
>you will get far in life if you go into stem they said
;_____;
>>
>>57093914
Other webm plz?
>>
>>57094154
cause u a grandpa lol
>>
File: 1450117923640.webm (212KB, 250x435px) Image search: [Google]
1450117923640.webm
212KB, 250x435px
>>57094215
>>
>>57094241

I like simple web pages. People need to get their 5MB JS crap off the internet.
>>
>>57094262
we need to prepare for fiber
>>
>>57094288

I don't know what you mean.
>>
>>57094438
https://fiber.google.com/about/
>>
>>57094448

If you think Google are actually going to expand, then you've got another thing coming.
>>
I'm proud of my homework, but when trying posting my modest 27 lines of code here I get
>Error: Our system thinks your post is spam. Please reformat and try again.

wat do?
>>
>>57094551

pastebin it.
>>
if (document.querySelector('.is_thread')) {
document.querySelector('.boardTitle').addEventListener('click', e => {
const c = document.querySelector('.thread').classList;
c[c.contains('gallery') ? 'remove' : 'add']('gallery');
});
GM_addStyle(`
.thread.gallery .postContainer {
display: inline-block;
vertical-align: top;
}
.thread.gallery .postContainer > :not(.post),
.thread.gallery .post > :not(.file),
.thread.gallery .file > :not(.fileThumb) {
display: none !important;
}
.thread.gallery .fileThumb, .thread.gallery .post {
margin: 0 !important;
padding: 0 !important;
border: 0 !important;
}
.expanded-thumb {
max-width: 95vw !important;
max-height: 100vh !important;
}
`);
}
>>
>>57094484
>a company with almost limitless money will deny the opportunity to datamine most americans at a never before seen scale
ok tripfaggot, whatever you say
>>
>>57094559
oh, right
http://pastebin.com/jEb5RQEk
>>
>>57094288
>we need to add bloat because we can
I hate this mentality, people act like their programs, pages, etc. are the only thing people are going to use. This kind of shit is why my browser is using gigabytes of ram, because everyone wants to bloat up their pages.
>>
>>57094571
how will I lolis ;_;
>>
writing a http mp4 streamer in C using pthreads and sockets
>>
Thinking about picking up programming. I have the desire to develop smartphone applications as a hobby.

Should I go with Java or C++?
>>
>>57094591
>Test case: cat von
>>
>>57094671
use apache cordova or phonegap to use JS and HTML5 xd
>>
>>57094671
C++
>>
>>57094671
start with java, then you can learn C++ if you want, but java is enough for most apps
>>
>>57094591
>>57094685
You also have an infinite loop as well as this undefined input.
>>
>>57094671
Java. honestly you should learn Javascript and HTML instead since with java you'll only be able to do android apps. Plus if you're new to coding they are VERY forgiving.
>>
>>57094028
See why they're so rich? That's because they don't throw away money to pay useless idiots who fuck shit up with their framework-of-the-month.
>>
>>57094571
their strategy with google fiber is basically just to put pressure on other ISPs to improve internet speeds so google can reach more people with their other services
>>
>>57094028
>http://www.berkshirehathaway.com/
>webpage loads instantly
>not filled with stock photos of smiling models in business suits making fake transactions
>no pointless fluff
>all the information you need to know is right there
>can be viewed on any platform with no hiccups

This is the reason they're so rich. They don't bullshit around.
>>
>>57094028
>If you have any comments about our WEB page, you can write us at the address shown above. However, due to the limited number of personnel in our corporate office, we are unable to provide a direct response.
>here is my phone number, text me anytime ;3 oh but I wont reply back sorry!
what did she mean by this?
>>
>>57095579
that's standard to take feedback but not give a personal response
>>
Good morning, /dpt/.
>>
>>57095738
It's almost 8pm.
>>
>>57095738
It's midnight, you dumb neet european.
>>
>>57095770
Funny, isn't it?
>>
>>57095770
I see you're in my time zone
>>
>>57095738
I am about to sleep dude wtf

post cutie
>>
File: 1469490803206.gif (1007KB, 500x563px) Image search: [Google]
1469490803206.gif
1007KB, 500x563px
>>57095818
>>
>>57095818
>>
>>57095850
>That tumblr colour filter
That's not cute at all.
It looks like fucking shit.
>>
File: 1475432842909.jpg (76KB, 515x698px) Image search: [Google]
1475432842909.jpg
76KB, 515x698px
>>57095868
>>
If I have a date before 1970 that I want to store, is it dumb to store it as a unix timestamp?
>>
>>57096020
negative integers represent time before 1970
a 32-bit signed integer will go back to 1901, and a 64-bit signed integer will go back into prehistory
>>
>>57096010
Better
>>
>>57095579
comments, not questions
>>
>>57096020
32-bit unix time can go to 1901 or some shit.
ISO 8601 is probably a better idea though.
>>
>>57096051
But does it go back to the big bang?
>>
>>57096467
theory?
>>
>>57095193
Why are people incapable of writing safe code?
>>
>>57096498
C"++"
>>
File: Untitled.png (22KB, 1803x541px) Image search: [Google]
Untitled.png
22KB, 1803x541px
Why am I getting this error (pic related)?
i = i fixes it, but this makes no sense. Google gives no results.
>>
>>57096563
leave it empty
for (; ...
>>
>>57096570
cheers mate!
>>
What's the difference between a void pointer and a char pointer?
>>
File: lua.gif (5KB, 256x255px) Image search: [Google]
lua.gif
5KB, 256x255px
>>57092946
Learning Lua and drinking beer /g/. What are you doing?
>>
>>57096585
a void pointer doesn't have a particular type it points to (and therefore can't be dereferenced)
a char pointer does (chars)
>>
>>57096592
then what are void pointers good for? I mean, only reason to have a pointer is to be able to get at the data it points to.
>>
>>57096609
what if you want to be able to store any type?
C doesn't have anything like templates
but you can write generic code using void*
>>
>>57096623
and a char* won't do?
>>
>>57096512
Could write it in Ada, it would be almost identical but with one difference. It wouldn't crash or give garbage output.
>>
Thoughts on Julia? Looks pretty much like Matlab.

I am into Fortran and VBA mostly.
>>
>>57096676
julia isn't well implemented and incredibly buggy

go and rust (sorta) set a new standard for tooling provided by default.
i doubt languages without something as good as the go tool or stuff like cargo will survive.
>>
File: 1464487277972.jpg (162KB, 960x720px) Image search: [Google]
1464487277972.jpg
162KB, 960x720px
>still have no idea how the fuck pointers work
>still have no idea what the fuck parser means
>>
>>57096633
don't typecast pointers of one type to pointers of another type, unless it's void. Something like this is considered UB:

    int x = 43;
int *z;
char *p;

z = &x;
p = (char*)z;


The compiler might not warn you, but it's error-prone nevertheless.

Google for the strict-aliasing rule.
>>
>>57096734
it's ok anon
You're probably still more knowledgeable than half the people with degrees.
>>
>>57096744
>p = (char*)z;
Your example is actually the exception of the strict-aliasing rule.
char (including signed/unsigned char) are allowed to alias any kind of pointer, so that functions like memcpy can work.
>>
>>57096734
A pointer is a variable which refers to another variable.
A parser is something that takes unstructured input and assigns structure to it.
>>
>>57096744
Can you show that example again, but with legal use of void*?

>Google for the strict-aliasing rule.
That's what i've been doing for the last few days.
>>
>>57096755
Yeah I thought of it afterwards, it's a bad example. Char is the only exception due to the fact that it's 1 byte length guaranteed.

Just replace 'char' with 'long' or something in that example.
>>
>>57096734
Pointers are numbers which point to memory addresses. Pointers also have a type associated with them. When you dereference a pointer it lets you either set or get the value stored at the specified memory location (also taking into account its type).

Parser means it basically scans text and converts it into a list or data stream.
>>
>>57096744
That's not undefined behavior. And it has nothing to do with aliasing.

The only reason void* exists is because it coerces implicitly to every pointer type.
>>
>>57096744
>Something like this is considered UB
You're right, it's considered UB by donkeys like you, but it ain't.
>>
>>57096769
It's very easy with void *:


int x = 43;
int *z = &x;

void *p = z;



If you want to point to a generic area in memory but can't dereference (how can you dereference if the area is generic and you don't know its size?) use void pointers.

If you use char* it will be like if you made a char array (a byte array, that is) out of your data. So if it's a pointer to a 4 byte int, it would be like you created a 4 size array out of char, by typecasting to char*.
>>
>>57096804
But what am i now allowed to to with p, that i couldn't do if p was a char*?
>>
>>57096823
Convert it back to its original pointer type.
>>
>>57096734
making people explain pointers to you is a good way to trigger the c standard semantic nazis, anon
disclaimer: the following won't be as precise as many that know the C standard in and out would like it to be.
put simply, a pointer is just an adress to some memory.
you can get a pointer to some memory by using &foo.
you can retrieve the memory by using *foo. whether the memory is copied when dereferencing the pointer (using *foo) depends on the use case. foo->bar (which is short for (*foo).bar) for instance will not create a copy, while Foo f = *foo might, depending on compiler optimization.
a type int* is a pointer to an int.
using pointers makes sense because passing a huge chunk of memory somewhere might have to create a big copy of it, which is expensive. in such cases, passing a reference usually makes more sense.
that being said, dereferencing is more expensive than directly accessing a member, so it entirely depends on the use case.
it might also sense if something wants to alter the memory. if you pass a copy, that function will alter the copy. if you pass a pointer, it can alter the memory referred to by the pointer.
C also allows you to do pointer arithmetic, allowing you to add something to pointers.
this is useful for arrays: an array may just be a pointer to the first value and the size of the array. the second value is pointer + size of single value, etc.

parsers transform a string input into an output.
transforming "123" to 123 is parsing.
transforming XML into a tree datastructure is parsing.
>>
>>57096828
And how do i know it's original type?

I still don't understand why i would want to convert it to a void* in the first place, then.
>>
>>57096839
>put simply, a pointer is just an adress to some memory.
Look at this faggot who only uses flat address spaces.
>an array may just be a pointer to the first value and the size of the array.
Unironically wrong (not even meming.)
>>
>>57096823
A usual usage of void pointers is on thread functions that have a standard prototype but aren't reliant on any specific type parameters other than void *.
You can pass it on to functions like that, as a parameter, and change it back to its original type inside the function.


void func(void *ptr)
{
int *data = (int *)ptr;

/* do stuff with data */
}

int main(void)
{
int z = 43;

func((void*)&z);
return 0;
}
>>
>>57096852
how would you formulate it correctly?
>>
File: Stella no Mahou.jpg (154KB, 1280x720px) Image search: [Google]
Stella no Mahou.jpg
154KB, 1280x720px
>>>/a/148613204
>>
Why i need function languages?
>>
>>57096848

If you're using someone else's library and they're using void pointers to store their data, you can't know the original type of the data. This is an example of primitive encapsulation in C.

Winapi uses this all over with opaque HANDLE types. HANDLE is a type that's used about most things in WinAPI applications, but it's just a void * type. You can't do anything on this type by yourself because you simply don't know what it is.

What you CAN do is pass it around on functions that know what the type is (they convert it inside) and these functions do the computations on your data, without you having to ever worry about what this data holds.
>>
>>57096848
>And how do i know it's original type?
It depends. For example, if you're using the qsort/bsearch function:
#include <stdio.h>
#include <stdlib.h>

int compare(const void *arg1, const void *arg2)
{
const int *a = arg1, *b = arg2;

if (*a == *b)
return 0;
else if (*a < *b)
return -1;
else
return 1;
}

int main()
{
int array[6] = {7, 2, 6, 1, 2, 5};

qsort(array, 6, sizeof array[0], compare);

for (int i = 0; i < 6; ++i)
printf("%d\n", array[i]);
}


Other times, you might have an enum which specified the type it is or something.
>>
>>57096865
One can refer to an array via a pointer to its first element.
>>
>>57096859
Wouldn't it be better to overload func to
func(void *ptr)
?

Oh wait, C doesn't have function overloading, has it? Things may slowly be beginning to clear.
>>
>>57096885
You don't. They're just a meme.
>>
>>57096885
What?
>>
>>57096898
Yeah you're getting the point. Function overloading is implemented in a less dynamic way too, because in essence the compiler chooses the best function to call at compile-time.

Void * in C is dynamic and doesn't depend on that stuff. But it DOES depend on what you typecast that pointer to, inside the function that takes void * as a parameter. If you typecast that pointer to something else, other than its original type, then the data you get might not make sense.
>>
>>57096898
>C doesn't have function overloading
_Generic provides a way to do function overloading in C.
>>
>>57096937
I hope you're being ironic.
>>
>>57096937
Yeah I doubt anyone would ever use that in production code.
>>
>>57096898
Ment to write
func(int *ptr)
.
But yeah, you get the idea.
>>
>>57092946
Programming microcontrollers in assembly
>>
>>57096948
It's true though.
#include <stdio.h>
#include <stdlib.h>

void my_int_fn(int a)
{
printf("int: %d\n", a);
}

void my_double_fn(double a)
{
printf("double: %f\n", a);
}

#define my_fn(a) _Generic((a), \
int: my_int_fn, \
double: my_double_fn)(a)

int main()
{
my_fn(10);
my_fn(20.0);
}


>>57096958
That's not the point.
>>
>>57096975
That's macro overloading.
>>
>>57096980
What?
>>
>>57096986
You're overloading my_fn.
>>
>>57096975
This looks horrible holy shit. I love C but please don't ever use this horrible stuff again. Are you too scared to just type the full function name by yourself that you have to use the preprocessor?
>>
>>57096991
No. It's just a macro.
All of the actual work is done by _Generic.

From an API standpoint, "my_fn" is the function, and "my_int_fn" and "my_double_fn" are implementations of that function.

>>57096996
>have to use the preprocessor
What? Are you scared of macros or some shit?
Also, _Generic is not a preprocessor construct, but would only be useful to have in a macro.
>>
>>57097017
Just move to C++ if you want function overloading. ISO committee GTFO with your stupid additions to an already complete language.
>>
>>57097017
>"my_fn" is the function
(my_fn)(10);

hmm
>>
>>57097017
What happens if you want to pass that function as a parameter to another function? This feature is at worst retarded, at best mentally challenged.

It completely ruins the purpose of using C as a naked programming language that doesn't have any need for badly engineered constructs like that one.
>>
>>57097034
But C++ doesn't have designated initializers REEEEEEEEEEE
>>
>>57097034
>Just move to C++ if you want function overloading
I don't really want function overloading as I don't find it to be particularly useful. I was just pointing out that it's there.
>ISO committee GTFO with your stupid additions to an already complete language
I'm pretty sure they just added _Generic to make the "compiler magic" in C99 <tgmath.h> standard, and not have like 200 functions added in <stdatomic.h>.

>>57097041
If that bothers you that much, you could actually implement my_fn.
#include <stdio.h>
#include <stdlib.h>

void my_fn(int a)
{
printf("int: %d\n", a);
}

void my_double_fn(double a)
{
printf("double: %f\n", a);
}

#define my_fn(a) _Generic((a), \
default: my_fn, \
double: my_double_fn)(a)

int main()
{
my_fn(10);
(my_fn)(20.0);
}
>>
>>57097017
So if I write 1++ will it do it once or 3 times?
>>
>>57097081
(my_fn)(10.0)

hmmm
>>
>>57097076
Oh no! The horror!
>>
>>57096937
>>57096975
>>57097017
>>57097081

Found this thread's autist. There's always one.
>>
>>57097088
>1++
1 is not a modifiable l-value, so that won't even compile.
>>
>>57097111
You know what I mean you fuck nugget, answer the god damn question!
>>
File: 1453303583505.jpg (41KB, 429x377px) Image search: [Google]
1453303583505.jpg
41KB, 429x377px
>>57097106
>Pointing out a language feature is autism
>>
>>57097095
Random piece of code from the kernel:
static const struct file_operations timerfd_fops = {
.release = timerfd_release,
.poll = timerfd_poll,
.read = timerfd_read,
.llseek = noop_llseek,
.show_fdinfo = timerfd_show,
.unlocked_ioctl = timerfd_ioctl,
};


Can't do this in C++.

>inb4 using non-constexpr constructors in static variables
>>
>>57092946
Learning C lisp because all non lisp languages are inferior
>>
File: metrobits-wallpaper-prague-2.jpg (270KB, 1600x1200px) Image search: [Google]
metrobits-wallpaper-prague-2.jpg
270KB, 1600x1200px
>>57097125
>A non-portable addition to the newest standard of a language is considered a feature

>noone will ever use it
>>
for an if statement with std::cin, it will not start until a user inputs something?
how does that work
It first asks the user for input then it runs the code?
>>
File: eg1.png (10KB, 514x211px) Image search: [Google]
eg1.png
10KB, 514x211px
>>57097129
replace . with _ and you could

write a variadic constructor that takes property-setters, make _release its own "property" type with an = operator that turns it into a property-set type, then use those to build the result

i don't mean setter in an OOP style
>>
>>57097123
_Generic doesn't evaluate it's argument, it just decides what type it is. In fact, it's completely a compile-time construct.
So if you passed "my_fn" i++, it will only evaluate once.

>>57097150
>A non-portable addition
It's standardised. That's literally the definition of portable.
>>
Newbie here, working with C

/g/, when I try to return EOF I need to press enter before it terminates the program.

What's a good way to debug this, and find out why it waits for a newline before it terminates?
>>
>>57097163
There's a difference between being standard and portable. Where is the support for C11 threads? GCC only has the header. Portability means compiler support. In C there's no need for compiler devs to implement these redundant "features", as you call them, so they skip them
>>
>>57097106
>Implying their is only one
>>
>>57097152
>replace . with _ and you could
What?
>write a variadic constructor
>inb4 constructors
>>
>>57097180
true

>>57097168
Post code
>>
>>57097151
cin blocks until it receives a signal from the os that input is available.
>>
>>57097178
>There's a difference between being standard and portable
_Generic is NOT an optional feature. Every C11 compiler must support it.
>Where is the support for C11 threads?
C11 threads are an optional feature.

You should seriously learn how a standard works before you say stupid shit.
>>
>>57097181
_ is a valid identifier, so you could make
_release
a variable, and
_release =
creates a "release configuration" type, which the constructor analyses to create the result

i think you could do it constexpr
>>
>>57097205
Show your code.
>>
File: wtf.jpg (19KB, 351x359px) Image search: [Google]
wtf.jpg
19KB, 351x359px
>>57097152
I have no idea what's going on i this post.
Would you mind providing complete working example code, so i can try to analyze it an hopefully maybe learn something new?
>>
Hey guys I have a question. What exactly is the cond variable in pthreads? How does it work? Can someone explain it to me in a simple way?
>>
>>57097239
>What exactly is the cond variable in pthreads?
A linked list of threads.
>How does it work?
A thread enqueues itself and waits for another thread to wake it.
>>
>>57093055
gunzip
bunzip2
tar xvf
tar xvf
bunzip2
tar xvf
gunzip
xxd data8 | head
00000000: 5468 6520 7061 7373 776f 7264 2069 7320 The password is
00000010: 385a 6a79 4352 6942 5746 596b 6e65 6168 8ZjyCRiBWFYkneah
00000020: 4877 7843 7633 7762 3261 314f 5270 594c HwxCv3wb2a1ORpYL
00000030: 0a


Git gud.
>>
>>57097152
I remember arguing with some sepplesfag anon quite a long time ago about this.
He tried to implement a hacky designated initialiser to try and "prove" that C++ can do it, even though his solution was hideous and inelegant.

Anyway, make your code do this:
enum {
THING_ERR,
THING_A,
THING_B,
THING_C,
THING_D,
THING_E,
};

const char *enum_str[] = {
[THING_A] = "Thing A",
[THING_B] = "Thing B",
[THING_C] = "Thing C",
[THING_D] = "Thing D",
[THING_E] = "Thing E",
[THING_ERR] = "Error",
};
>>
>>57097150
Is this in Prague?
>>
>>57097338
yes
>>
>>57097152
That's the most disgusting abuse of UDLs I've seen so far. Congratulations.
>>
>>57093548
Might as well use C++ instead.
>>
File: eg3.png (18KB, 674x352px) Image search: [Google]
eg3.png
18KB, 674x352px
>>57097238
>>57097303
>>57097350

You can achieve a lot, you can certainly get most of the functionality of C initialisers, except by doing it yourself
>>
>>57097361
This is one of the most disgusting things I've seen, but that's just everyday C++.
Also, you haven't done my enum example yet.
>>
>>57097380
Your enum example would work with the
at
stuff
i.e.
1_at[enumA]

and i don't see how you can complain about implementing shit
better library than language
>>
>>57097390
>better library than language
There's such a thing as going to far, and I say that as a sepplesfag.
>>
>>57097400
so you don't think designated initializers should exist
>>
>>57097390
>1_at
I want a string though.
>better
I cannot even comprehend anyone with shittier taste than sepplesfags.
>>
>>57097404
You shouldn't put words in people's mouth, it's almost always incorrect.
Unless you care more about feeling right than being right.
>>
File: 1373600715585.jpg (59KB, 480x480px) Image search: [Google]
1373600715585.jpg
59KB, 480x480px
>>57097356
>Might as well use C++ instead.
>>
>>57097405
you could do something like
array {
place(enumA, value),
place(enumB, value)
};

>>57097409
so you just want it to be there but without being done
it should just be the compiler that does it
how lazy and short sighted

you can extend it this way. you can't extend C initialisers.
>>
>>57097422
>so you just want it to be there but without being done
>it should just be the compiler that does it
>how lazy and short sighted
>you can extend it this way. you can't extend C initialisers.
Again, you're attacking a straw man.
It sounds like you just want to discard me as some idiot without a care for what I think.
>>
>>57097422
plus you could manipulate configurations as first class values
in C you can't pass around
{
[a] = x,
[b] = y
}
as a value

>>57097441
i am literally covering all the options
either you don't want designated initializers
or you do want them in a library
or you do want them in the language
>>
>>57097449
You still haven't shown your work. For this

struct file_operations {
struct module *owner;
loff_t (*llseek) (struct file *, loff_t, int);
ssize_t (*read) (struct file *, char __user *, size_t, loff_t *);
ssize_t (*write) (struct file *, const char __user *, size_t, loff_t *);
ssize_t (*read_iter) (struct kiocb *, struct iov_iter *);
ssize_t (*write_iter) (struct kiocb *, struct iov_iter *);
int (*iterate) (struct file *, struct dir_context *);
unsigned int (*poll) (struct file *, struct poll_table_struct *);
long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long);
long (*compat_ioctl) (struct file *, unsigned int, unsigned long);
int (*mmap) (struct file *, struct vm_area_struct *);
int (*open) (struct inode *, struct file *);
int (*flush) (struct file *, fl_owner_t id);
int (*release) (struct inode *, struct file *);
int (*fsync) (struct file *, loff_t, loff_t, int datasync);
int (*aio_fsync) (struct kiocb *, int datasync);
int (*fasync) (int, struct file *, int);
int (*lock) (struct file *, int, struct file_lock *);
ssize_t (*sendpage) (struct file *, struct page *, int, size_t, loff_t *, int);
unsigned long (*get_unmapped_area)(struct file *, unsigned long, unsigned long, unsigned long, unsigned long);
int (*check_flags)(int);
int (*flock) (struct file *, int, struct file_lock *);
ssize_t (*splice_write)(struct pipe_inode_info *, struct file *, loff_t *, size_t, unsigned int);
long (*fallocate)(struct file *file, int mode, loff_t offset,
loff_t len);
void (*show_fdinfo)(struct seq_file *m, struct file *f);
#ifndef CONFIG_MMU
unsigned (*mmap_capabilities)(struct file *);
#endif
};


do this

static const struct file_operations timerfd_fops = {
.release = timerfd_release,
.poll = timerfd_poll,
.read = timerfd_read,
.llseek = noop_llseek,
.show_fdinfo = timerfd_show,
.unlocked_ioctl = timerfd_ioctl,
};
>>
>>57097449
>i am literally covering all the options
Yes, that's the problem. You made up your opinion before we even started talking.
Before I say anything, you've already put me in a box.

If this is how you think, how will you know when you are wrong?
>>
>>57097467
i'm not doing all that bullshit
i was just giving you a proof of concept

i'll write some code for you as an example
>>
>>57097476
>you've either put me in a box or not put me in a box
wow you're putting me in a box
you've already made your mind up
>>
>>57097485
>wow you're putting me in a box
>you've already made your mind up
I listened to you before making my mind. You called me "lazy and short sighted" before knowing what I think.
>>
Hey guys, I am trying to get all possible spotify playlists using their API.

What API endpoint do you think would cover everything?

There would need to be a dictionary search, but I'm not sure what to use.
>>
>>57097493
i literally called the opinion you had lazy and short sighted

it was in a reply for fucks sakes

where are you even trying to take people with this

do you need directions to the moral high gruond?
>>
A good c roadmap? Looking for books, lectures etc to read
>>
File: ani.webm (1MB, 854x480px) Image search: [Google]
ani.webm
1MB, 854x480px
/dpt/-chan, daisuki~

>>57097514
c primer plus
/r/c_programming

>>57095738
Ohayou~

>>57094671
Javascript with React Native

>>57094021
T. Rasmus lerdorf

>>57093914
>Bash
Into the trash it goes.

>>57093852
Excellent.

>>57093548
>not using procedural abstraction to have a transparent pointer

>>57093401
Scripting what ?

>>57093302
Lisp

>>57093055
As a white hat, i only hack for the common good, not for individuals. Sorry.

>>57093000
http://jimplush.com/talk/2015/12/19/moving-a-team-from-scala-to-golang/
http://qr.ae/drvVS
http://qr.ae/drvm8
http://yager.io/programming/go.html
http://nomad.so/2015/03/why-gos-design-is-a-disservice-to-intelligent-programmers/
http://java.dzone.com/news/i-don%E2%80%99t-much-get-go
http://dtrace.org/blogs/wesolows/2014/12/29/golang-is-trash/
http://www.lessonsoffailure.com/software/google-go-not-getting-us-anywhere/
http://www.lessonsoffailure.com/software/googles-go-not-getting-us-anywhere-part-2/
http://www.lessonsoffailure.com/software/google-go-good-for-nothing/
https://gist.github.com/kachayev/21e7fe149bc5ae0bd878

>>57092990
>Doesn't share the source code.

>>57092946
Thank you for using an anime image.
>>
>>57097467
compiles on VS2015
pretty shitty code, could be done better with enums or macros, but you get the point

#define veryconst static const constexpr

struct release_conf {
int(*release)(int, int);
};

struct push_conf {
char(*push)();
};

struct example {
int (*release)(int,int);
char(*push)();

constexpr example() : release(nullptr), push(nullptr) {}

template <typename ... T>
constexpr example(const release_conf x, T... rest) : example(rest...) {
release = x.release;
}

template <typename ... T>
constexpr example(const push_conf x, T... rest) : example(rest...) {
push = x.push;
}
};

veryconst struct {
constexpr push_conf operator=(char(*push)()) const {
return push_conf{ push };
}
} _push;
veryconst struct {
constexpr release_conf operator=(int(*release)(int, int)) const {
return release_conf{ release };
}
} _release;
// only exist to give _release = ... syntax
// alternative would be to just do
// example ( release_conf { ... }, push_conf { ... } }

char examplepush() {
return 'x';
}
int examplerelease(int x, int y) {
return (x + y) / 2;
}

int main(int, char**) {
static const example e = {
_release = examplerelease,
_push = examplepush
};

return 0;
}
>>
>>57097589
Why haven't you killed yourself yet?
>>
File: 1475316703072.png (2MB, 1920x1080px) Image search: [Google]
1475316703072.png
2MB, 1920x1080px
>>57097589
pls reply to me this time senpai
>>
>>57097601
If you can't see the problem with this code, I don't know what to say.
>>
>>57094685
>>57095193
>>57096498

Thanks for noting that. Yet I wasn't asked in this assignment to implement anything that checks whether input actually is natural numbers, or any numbers at all.

I have some clue how to avoid that integers<0 or decimal fractions are entered,
but how do I avoid other symbols?
input as string, then go through that string checking whether it's all numbers and then convert?

>also an infinite loop
Please explain. Where is it
>>
>>57097620
You could generalise this for tuples and use either string literals (assuming identical string optimisation), user defined literals or enums

I am telling you for the last fucking time that this is a proof of concept, and obviously C++ is a shitty language that can't do a bunch of things

at least this is fucking extensible, you could have all kinds of configuration types and set up different things in many different ways

probably the most interesting syntax bullshit in C++ was someone made lambdas before lambdas
>>
>>57097620
oh and you can pass around tuples of _conf values.
so you might have two different things that both have push and release values, and you could create the same config and pass it to both
>>
>>57097601
If I understand you correctly you want me to define 25 new types and 25 new constructors to initialize the struct above?
>>
>>57097649
No, you only define 1 extra type. And that's assuming you aren't using the enum alternative I suggested, or using macros to build it for you.

The type is there for overloading, and if you look at it it's very straightforward for this kind of "setter". (again, not an OOP setter)
You could create arbitrary "setters", doing things like in >>57097361 or even more complicated things.
>>
>>57097667
>No, you only define 1 extra type.
You have two fields in your example and you have defined one type per field. Is my math off?
>>
>>57097649
>>57097667
>>57097674

Oh, you mean for your example. Sorry, I misinterpreted

If you used the naive implementation I gave, then yes you'd need one type per field.
The alternatives - using enums, would let you define a set of enums for field names, and a mapping of enum -> type. You could work this with tuples quite naturally by having the enums decay to size_t (so they work with std::get), you'd end up with get<release>(...). With macros all of this boilerplate could be generated automatically.
>>
>>57097686
>If you used the naive implementation I gave
Post the implementation that's not naive.
>>
>>57097674
>>57097686

so you'd have something like

using example = customStruct<fieldEnum, fieldTypeFun>;
//or
using example = customStruct<fieldEnum, field1T, field2T, field3T>;


example value {
conf<release>(val1),
conf<push>(val2),
...
};

get<release>(value);


The constructor would translate the conf<e>(val1) into a set<e>(val1)

>>57097689
I keep telling you this is a proof of concept and I don't want to fuck around doing all of this.

With tuples you can already use (non-class) enums because they can be converted to size_ts. You'd have to write your own tuple set, in a similar style to get.
>>
>>57097724
>I keep telling you this is a proof of concept and I don't want to fuck around doing all of this.
Got it. Your solution is not ready for production.
>>
>>57097751
Jesus christ you're fucking intolerable.
Grow up.
>>
>>57097778
There is only one thing left to do to complete your full blowout:

Clang supports designated initializers in C++11.
The authors of this extension have created a formal proposal for adding it to C++17 because professional C++ users know that your solution is utter garbage.
>>
>>57097514
I recommend C Primer Plus, what >>57097589
said.

>>57097619
Hey Anon... Rem is best girl. I just wanted to let you know that.
>>
>>57097823
>>here is how you implement your syntax sugar in C++
>lol wtf just get someone else to do it

Wow, you really blew me the fuck out
Well done anon

You've really shown that if you want syntactic sugar and concise code, you should go for C!
>>
>>57097840
Were you this buttblasted when they added closures to C++ even though you can already do the same with function pointers and a struct?
>>
>>57097850
Closures change the semantics significantly, but what's your point? I thought you were trying to argue in favour of C. But you can't make your mind up. You just need something to latch on to that shows C is better. If C++ gets designated initialisers, what will you do?
>>
>>57097860
You seem to think that there are only two people in this thread.
>>
>>57097832
>Rem
Who?
>>
>>57097874
This
>>
>>57097874
So you're telling me you were just jumping in on the conversation to tell me how programming is stupid and you should just complain to your language standard?
>>
>>57097887
Absolutely not. I jumped in to tell you that you are stupid and that leading C++ experts agree with me.
>>
File: bjarne.png (91KB, 136x275px) Image search: [Google]
bjarne.png
91KB, 136x275px
>>57097901
>leading C++ experts
>>
>>57097621
>>57094591

>I have some clue how to avoid that integers<0 or decimal fractions are entered
come to think of it, I actually don't.

>integers<0
would be this
do { cin >> a; } while (a < 1);


and my thought for the whole thing was something like
float a;
do { cin >> a; } while ( ( a != (float) (int) a ) ) || ( a < 0 ) );


- but this doesn't prevent numbers with decimal point and only zeros behind that point (8.0, 67676.0000000) being entered. Do such numbers count as integers? As I see it they kinda are, but they're not entered in integer notation. How should I look at this?
>>
Is there a way to build a program with MinGW-w64 without exception handling? I tried -fno-exceptions but that didn't work. Should I just use an older compiler without exception handling like MinGW?
>>
Hello, dear anons!
Could you give me some advice what application should i create in UWP, which contains the advantages or features of UWP? I need for my home assignment for college course, where I'm learning to develop for UWP devices.
>>
File: faggot.jpg (14KB, 238x320px) Image search: [Google]
faggot.jpg
14KB, 238x320px
I've started playing with my arduino, and so far I've got a listener set up in an IRC channel to display all messages like "!gitgood message".

If you want to come insult me directly on my desk, join #lainchan on freenode and type !gitgood suck my balls".
>>
>>57098027
you spelt faggot wrong
>>
>>57098029
They actually spelled it right, I just realized my text wrapping is fucked up.
>>
nigger
>>
>>57098056
How is this post programming related?
>>
>>57098065
>r
i was trying to reply to the guy with the audrino
i posted op is a nigger in the channel
>>
>>57093184
C, if properly formated with a good text editor that has colors can look great but C is designed with maximum control in mind which means you will have to do much of the actual work yourself, which takes some typing, but thats not a bad thing.
>>
>>57093413
run sizeof(array)/sizeof(array[0]) on each array.
>>
I think the more I advance into my programming course at uni the more of a degenerate I'm becoming
>>
>>57097589
僕たちもあなたのこと大好きなのだ!////
>>
>>57098160
>hiragana
lol baby
>>
>>57098185
>僕 好
>hiragana
k tard
>>
>>57098189
>2 fucking characters
holy shit you really convinced me
>>
>>57098185
there's nothing else in that sentence that needs kanji, retard
>>
>tfw don't even have one friend in any of my classes
>>
>>57098266
but you have us, anon.
>>
>>57098266
That's probably for the best. Your classmates will most likely not be on your wavelength.
>>
 
#define t< template<

t<typename T>


Why does this not work?
>>
>>57098303
>Why does this not work?
Because it's C++.
>>
>>57098303
Because here "t" is the name of the macro and "< template<" is the value of the macro.

So the source ends up as :
< template< <typename T>


>>57098306
Wrong!
>>
>>57098357
why is that the case?
read though GCC and didn't see anything about this.
>>
>>57098357
Fair enough, but why does this work:

 #define tt template<
tt typename T>
[code/]

But not this:
 #define t template<
t typename T>
[code/]
>>
>>57098422
The second one will work.

Try:
#define t template<
t typename T> void f();
>>
How to generate sounds in C? I want to make a small piano VST for learning
>>
>>57098443
alsa
>>
File: scientific.png (1MB, 1702x2471px) Image search: [Google]
scientific.png
1MB, 1702x2471px
why does /g/ get so pissy when you try to talk about scientifically proven tools and gear for programming?
>>
can someone help me understand this assignment?
http://www.cs.ecu.edu/~karl/3675/fall16/Assn/Assn5/assn5.html
i'm on step 6 and i feel like now i need to actually understand the program to continue on. before i just followed the instructions but now i'm lost
>>
>>57098428
Doesn't work for me.

#define tt template<

tt typename T>
void fun(T &t)
{
std::cout<<t<<std::endl;
}
int main()
{
int a=5;
fun(a);
return 0;
}


^this compiles and works.

#define t template<

t typename T>
void fun(T &t)
{
std::cout<<t<<std::endl;
}
int main()
{
int a=5;
fun(a);
return 0;
}


^this won't compile.

||=== Build: Debug in thisisatest (compiler: GNU GCC Compiler) ===|
main.cpp|5|error: expected ',' or '...' before 'template'|
main.cpp|7|note: in expansion of macro 't'|
main.cpp||In function 'void fun(T&)':|
main.cpp|5|error: a template declaration cannot appear at block scope|
main.cpp|9|note: in expansion of macro 't'|
||=== Build failed: 2 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|
>>
>>57098443
Audio is just a stream of samples, so in theory, you just need to write some numbers to an array and you have raw audio data.
However, in all likelihood, you probably want to write it to an array of frequencies and then use an inverse FFT to get the audio.
>>
>>57097989
Figured it out, DJGPP can do this. It seems to be the only active C++ compiler capable of doing this except maybe TDM-GCC but that has other issues on older systems.
>>
>>57098567
Yes, you use "t" inside "void fun(T &t)", so the macro will replace that with garbage.
>>
>>57098598
Thank you. I apologize for being a retard.
>>
https://www.youtube.com/watch?v=YnWhqhNdYyk


will C ever recover?
>>
>>57098751
C++fag here
i doubt this video is worth watching
>>
>>57098777
It was actually okay.
It just says to teach modern Sepples before the more dangerous C subset, when teaching beginners.
>>
>>57093302
White-space sensitive lisp. New-lines and indentation could be used as an alternative to parenthesis. Otherwise, it would generally follow the design philosophy of Clojure.

(do (print (+ 1 2 3)) (print "hello"))


do
print (+ 1 2 3)
print "hello"
>>
>>57098945
this is almost valid haskell
>>
Should I stop programming in C and use D only?
>>
Yes, I know about the API but that won't work for what I'm actually trying to do.
import requests, time
pic_num=1476617537105
tries=0
while True:
tries+=1
pic_num+=1
if int(str(pic_num)[:10]) > int(time.time()):
print("CURRENT TIME")
continue
the_url="http://images.4chan.org/g/src/{0}s.jpg".format(pic_num)
image=requests.get(the_url)
if "404 Not Found" in image.text:
print("Tries:",tries, end="\r")# (int(time.time())-int(str(pic_num)[:10])),"sec until corrent time")
else:
input("FOUND!\n"+the_url,
"\nKeep going?")



Please help, I don't know how to multi-thread/queue this.
I've done threading before but only with a certain amount of work to do..
for item in range(10):
q.put(item)

q.join()

I can't just have a while loop+counter there..
Thoughts?
Am I retarded?
>>
>>57098961
It would probably end up that 50% of its programs end up being valid Haskell.
>>
>>57099000
yes
>>
Redpill me on Go, is it worth getting into? It seems like a good C replacement
>>
>>57099072
No
>>
opinions on computer graphics? Do you ever make things in WebGL / OpenGL / Vulkan?

https://www.shadertoy.com/browse
>>
>>57099072

>>57097589
>>
/!\ A L E R T /!\

New thread

>>57099132
>>57099132
>>57099132


/!\ A L E R T /!\
>>
In java, making a File instance never created a file in the disk, however, if I make a RandomAccessFile instance and the file I'm using for the instance doesn't exist, then a new file always gets created. How can I test if a RAF exists without creating a new file on disk?
>>
>>57097129
That's what constructors are for.
>>
>>57098751
The whole point of teaching anybody anything is to make better C++ programmers.
>>
I'm new to programming. It makes me feel like an idiot. Right now I'm back at the university for a degree in compsci and the stuff we're doing isn't too difficult but I have just immense amounts of anxiety built up around it. When I had little tastes of programming before it was C# and kind of pretty but my class is for C++ and it's just so ugly to me... I'm working a part time job in IT for the state so I'm not totally fucked but I'm depressed because I really thought I would like learning to program more. Is it worth sticking with it? Obviously the pay is high for programming, but is it just miserable working one of those jobs or do you reach a point where you know what you're doing and it's easier to tackle issues and solve problems?
>>
>>57100745

>>57099135
>>
>>57098751
>its the language for smart people
> because they have to learn C first
so C is the language for smart people
Thread posts: 318
Thread images: 29


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