[a / b / c / d / e / f / g / gif / h / hr / k / m / o / p / r / s / t / u / v / vg / vr / w / wg] [i / ic] [r9k] [s4s] [vip] [cm / hm / lgbt / y] [3 / aco / adv / an / asp / biz / cgl / ck / co / diy / fa / fit / gd / hc / his / int / jp / lit / mlp / mu / n / news / out / po / pol / qst / sci / soc / sp / tg / toy / trv / tv / vp / wsg / wsr / x] [Settings] [Home]
Board
Settings Home
/g/ - Technology



Thread archived.
You cannot reply anymore.



File: 1487820592296-1.gif (937 KB, 500x357)
937 KB
937 KB GIF
What are you working on, /g/?

Old thread: >>59496107
>>
WHOEVER POSTS ANYTHING NON PROGRAMMING-RELATED UNDER THIS POST WILL SEE HIS MOTHER DIE IN HER SLEEP TONIGHT
>>
File: 1487921166812.png (339 KB, 387x550)
339 KB
339 KB PNG
C is a disservice to intelligent programmers. It has almost 0 features that a modern and intelligent programmer uses to be productive. Since C is such a timesink, it's popularity is falling more than any other languages in the market.
C is dying and it should die ASAP. C programmers are actually retards in general. C is a small language to grasp, exactly the kind of shit that makes things retard friendly.
C has no advanced features like C++ does.

But as a newfag you are kinda in the right direction. C is for newbies. Think of it this way:
During ancient times, counting to 10 was a big deal and a person who could count to 10 was considered to be "wise".

Fast forward a few century counting to 10 is so trivial we teach this to toddlers. Now toddlers appreciate the vast "knowledge" of counting to 10 while matured brains are busy with modern technologies.

C is from stone age and the people who still preach it is like overgrown toddlers that can't learn advanced things.
C doesn't have delegates
C doesn't have resizable arrays
C doesn't have strings
C doesn't have string concatenation
C doesn't have namespaces
C doesn't have exception handling
C doesn't have closures in the standard
C doesn't have unit tests
C doesn't have Function overloading
C doesn't have memory safety of any kind
C doesn't prevent memory exploits and has no bounds and runtime checks
C doesn't have dynamic method loading/creatin
C doesn't even have generics and templates
C doesn't have meta programming
C doesn't have mixins
C doesn't have higher order functions
C doesn't have contract programming
C doesn't have inner classes
C doesn't have function literals
C doesn't have array slicing
C has a very limited support for implicit parallelism
C doesn't even have string switches

C is a cancer that plagues the modern software industry. If you want guaranteed memory exploits and security vulnerabilities in your program with timesink development period then use Assembly, not C.
>>
File: Guido van Rossum.png (1.41 MB, 800x1200)
1.41 MB
1.41 MB PNG
Thank you for using an anime image!


Why is FP the best programming paradigm?
>>
>>59499557
First for C and Lisp
>>
Is setjmp/longjmp literally save-stating in C?
>>
std::_Rb_tree_iterator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > std::_Rb_tree<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::_Select1st<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, jw::dpmi::locked_pool_allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >::_M_emplace_hint_unique<std::piecewise_construct_t const&, std::tuple<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&&>, std::tuple<> >(std::_Rb_tree_const_iterator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >, std::piecewise_construct_t const&, std::tuple<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&&>&&, std::tuple<>&&)

this is an actual thing.
>>
File: 1478900497527.jpg (70 KB, 535x535)
70 KB
70 KB JPG
Use this thread to post anything worthwile: >>59495452
C-tard once, C-tard forever, and the posts like >>59499605 is equal to casting pearls before swines.
>>
>>59499607
All paradigms are shit by themselves. Only multiparadigm languages are sane to use.
>>
>>59499629
That's a good thread but butthurt C toddlers showed up with their anime
>>
>>59499630
Multi-paradigm is a stupid as multi-culturalism

>just mix everything together! it's all compatible! it's all the same!
>>
>>59499626
Sepples was a mistake
>>
>>59499605
This is all just one salty annoying twat right? There isn't some anti-C brigading /g/
>>
>>59499605
>If I copy paste it enough time it'll make it true
Stay buttblasted, little pajeet, for you will never write anything worthwhile.
>>
>>59499644
Single-paradigm languages are as stupid as religious fanaticism. Take the best from different fields.
>>
>>59499630
I see you've never programmed in Scala :X
>>
>>59499642
It's C(ancer) thread. And it's filled with C(ancer) in last stage.
It will sink in animoo soon. Let them die.
>>
>>59499667
>>59499668
Don't reply, report and ignore.
>>
>>59499630
This desu
>>
>>59499667
Nobody hates C. There are some people who hate themselves, and that's why they don't want to use the best language. It would be tragic if they weren't busy trying to ruin it for the rest of us.
>>
>>59499671
Religious fanaticism isn't stupid

You can't "take the best" from different fields, they can't all stand completely independently of the rest of the field
>>
File: 1475566478902.png (17 KB, 400x300)
17 KB
17 KB PNG
>>59499607
Guido actually doesn't like FP.
>>
>>59499672
>:X
I see you belong on reddit.
>>
>>59499692
Guido actually is retarded, that's why he invented the stupid snake language
>>
>>59499691
>Religious fanaticism isn't stupid
Stopped reading there, fanatic.
>>
>>59499605
The only real problem with C is that people continue to see it as a proper high-level applications language, even when far better alternatives exist. C is fine for its intended purpose, as a systems language for situations where "features" and "safety" are unavailable or simply too costly. It takes an intelligent programmer to get the most out of C, specifically because the language itself provides so little, it's on the programmer to take those parts and put them into a coherent useful whole. Problem is, a lot of programmers today aren't the intelligent sort. It's not surprising, no matter what field you're talking about, quantity beats quality in economies of scale. Our current generation of programmers is taught mainly to plug API's together, which is all well and good if you're programming in Java or Python, but turning them lose on C invariably spells disaster. C trusts the programmer to be competent, and modern programmers aren't taught to be competent, they're taught to try stuff until it works. As a result, C code written by people who would be better off programming in some other language is frequently full of hacks, that work under the right conditions, but are far from being sound program design. Hacks have their place, especially in a minimalistic language like C - the existence of the C preprocessor itself is an excellent example of that - but people who expect programming to be easy and straightforward tend to make the mistake of assuming any difficulty or unexpected behavior means it's time to start using dirty tricks. And it's rarely the case; if they actually understood the language semantics for what they were, they would realize that there does exist a perfectly sane and safe way to do what they want.
>>
>>59499706
t. relativist nihilist who has yet to grow up

you're fanatically opposed to commitment
that's why you love multi paradigm
>>
>>59499671
The only true multiparadigm languages are those with powerful metaprogramming at read time, i.e Lisp and Forth.
If you can't implement custom control flow, compiler directives and syntax you'll always be constrained in some way and essentially forced into one paradigm because it becomes too inconvinient to stray outside it.
>>
>>59499691
>fractal wrongness: the post
>>
>>59499612
No. It only "saves" stack related things. Global/dynamic state does not "wind back". You have to be careful not to leave your program in an inconsistent state, and not leak resources.
setjmp is pretty shit, in my opinion.
>>
>>59499726
I can use the best tool for the job without switching the language in the same project.
>>
What's the actual use case for setjmp?
>>
>>59499754
Why not use an actually expressive paradigm in the first place then?
>>
>2017
>not compiling to javascript
>>
>>59499764
Because all paradigms are unusable shit in some cases.
>>
>>59499775
Using TypeScript and VSC is actually not that bad
>>
>>59499763
Getting out of some deeply nested function to do cleanup/error handling/other bookkeping without needing a massive chain of if statements testing flags everywhere.

A concrete example could be the top level interpreter loop of some shell or repl environment, remember a jump target there and any interpreted command can easily reset the top level to a known state from anywhere.
>>
Comment
>>
I want to datamine 4chan. What would be a fun first project?
>>
>>59499819
This.
>>
>>59499963
Post your boipucci
>>
>>59499963
Detect bad programmers in the dpt thread and reply "ur shit" to them
>>
>>59500001
ur shit
>>
>>59499963
sure. be sure to use the json api!
http://a.4cdn.org/g/thread/59499557.json
>>
>>59499994
But it's a hairy mancunt.
>>
File: n-no_homo49.png (348 KB, 593x670)
348 KB
348 KB PNG
>>59500017
You think that'd stop me?
>>
>>59500009
fuck
>>
File: 1489979795997.jpg (24 KB, 303x566)
24 KB
24 KB JPG
>>59499963
signature strike drone algorithm that targets t. appeal to middle ground meme language programmers
>>
>>59499850
Uhh no. That's what goto is for.
>>
>>59500198
setjmp/longjmp is a non-local goto, though.
Normal goto can't jump out of a function in C.
>>
File: UNI0P4A-TOP-600.jpg (63 KB, 600x600)
63 KB
63 KB JPG
>>
Is there an equivalent of setjmp/longjmp in js? Just curious.
>>
>>59499602
I welcome it.
>>
>>59500326
Nope.
>>
>>59500326
in js, everything is global, and gotos are allowed to jump you out of functions, so it's basically the same thing
>>
>>59499605
>Programming using pointers scares me, the post, the musical, the experience
>>
>>59500382
JS doesn't even have goto, it just has labeled break/continue, which I'm pretty sure don't work across functions. There might be some trick you can do with eval(), but I doubt it would be efficient.

>>59500501
this
>>
File: sel.jpg (167 KB, 1010x768)
167 KB
167 KB JPG
>>59499557
Thanks you for posting a Lain
>>
redpill me on x86 segmentation

why did everyone ditch it for paging?
>>
I need to check whether the first 2 digits of a credit card are 51 through 55, I did it in C and it's this montser, but now I have to do it in Python. Are there any python shortcuts for this? Basically a multiple clause OR statment...

Noob here, pls be gentle

    if (card[0] == 5 && (card[1] == 1 || card[1] == 2 || card[1] == 3 || card[1] == 4 || card[1] == 5 ) && valid){
>>
>>59500612
>it's this montser
if (card[0] == 5 && card[1] >= 1 && card[1] <= 5 && valid)
>>
>>59500612
Segmentation only made sense because of the small size of a 16-bit address space, and the doofuses at Intel were too autistic to combine two registers into a 32-bit pointer, but instead had to some up with some ridiculous bitshift scheme.

>>59500619
You're joking, right? If the numbers are stored as an array of digits (rather than an integer or string).

if(card[0] == 5 && (card[1] >= 1 && card[1] <= 5));


That would be a way more efficient C implementation. Now, if your example is wrong and you're doing a character comparison (in which case you should have single quotes around the digits being compared to), there are library functions that could help you. But your C implementation is like one of the worst ways to do it.
>>
>>59500619
ur shit
>>
>>59500663
Replied to wrong post: >>59500619
>>
>>59500689
ha lol yeah I did fuck up. Like I said, I'm a noob, but yeah your solution is what I was looking for. They are stored in a digits array. Thanks!
>>
I'm building a server from scratch in nodejs + postgresql with everything from authentication through to static websites without a single dependency or framework.
>>
>>59500689
>>59500700
someone pls post one of those shitty programmer pics right now, I deserve it
>>
>>59499605
C was once a decent systems and application programming language. Now it is not a decent application programming language, and honestly it's systems and HPC aspects are kind of meh at best. Using C as a high-level assembly generator is dubious at best.

Honestly, it's only real use today is as an interface language; most languages have a C API.
>>
int i, n, j, alpha_value, new_key, alpha_index[strlen(k)];


fuck scope
>>
>>59499605
>C is a small language to grasp, exactly the kind of shit that makes things retard friendly.
Having to implement everything yourself and retard friendly are mutually exclusive
>>
What does programming sound like?
>>
>>59499605
ur shit
>>
>>59500853
aplay /bin/*
>>
>>59500853
cat program.ext > aplay
>>
I'm having an issue. My sum variable is printing out a value of 10 before I've assigned it anything but a 0. Why is the initial value after I run the do while loop once 10 instead of 0?


int floor = 10, suitesPerFloor = 20, sum = 0, totalSuites = 120;
int suitesFilled[5];

do {
if (floor != 13) {
cout << "How many suites are occupied on floor " << floor << "? " << endl;
cin >> suitesFilled[floor];
cout << "Suites: " << suitesFilled[floor] << endl;
cout << "Sum: " << sum << endl;
sum += suitesFilled[floor]; //don't know why this is giving me the wrong sum!
cout << "Sum after adding: " << sum << endl;
}
floor++;
} while (floor >= 10 && floor <= 16);

cout << "Suites: " << totalSuites << "\n";
cout << "Occupied: " << sum << "\n";
cout << "Percentage: " << (sum / totalSuites) * 100;

>>
>>59500730
Webdevs really say the most boring shit.
>>
>>59500853
http://www.cs.tau.ac.il/~tromer/acoustic/

this is actually really interesting if anyone else wants to read about computer sounds.
>>
>>59500887
>>59500879
>mfw I aplayed my hard earned program and all it did was a measly *bip* for half a second
>>
>>59500918
Ikr. Imagine writing code that actually earned you money?

It's really boring.
>>
File: java-vs-haskell.png (102 KB, 2435x913)
102 KB
102 KB PNG
what does it mean?
>>
>>59500730
how long have you been programming? i don't see where that's exactly groundbreaking but i'm not a webdev, i've just done web development before and i didn't use frameworks. just php, html, and mysql
>>
>>59500911
Can anyone help me please?
>>
>>59500935
I don't fucking care if you're earning money off of Generic Program #1261236389.
What you're saying is mundane and boring. There is no creativity. There is no "progress" either personally or programming as a whole.
I would rather a thread of loli-rape simulators and pointless toy languages than a thread full of webdev, enterprise OOP software, and the like.
>>
>>59501006

Just a moment, I'm reading your code right now
>>
Fuck objective c
>>
>>59501050
fuck you leather man
>>
File: 1489786668352.jpg (119 KB, 540x960)
119 KB
119 KB JPG
>>59499557
I need a new way of learning C#

The course I'm taking is "learn C# with unity" except they aren't touching any C# besides the syntax that I already know and they're spending hours pussy footing around unity as if I fucking gave a shit

where do I go to learn C# that won't make me want to suck off a shotgun barrel
>>
Hippies are all like, "I don't like definitions maaaan... You can't define me doood!"
And I'm just like, "nothing makes any sense without definitions..."Amirite guys?!
>>
>>59501006
>>59501020

cont:

Well I'm not exactly sure what the 'suitesFilled' is supposed to do, but I can tell you are doing it wrong.

You instantiate suitesFilled to be a 5 int long array at line 2 and then you try to access the 10th element of this 5 element array at lines 7, 8, and 10. You aren't supposed to do this.
>>
>>59501079
Who's this qt trap?
>>
>>59500985
really makes you think
>>
>>59501079
https://learnxinyminutes.com/docs/csharp/
>>
>>59501079
CLR via C#
>>
File: csharp.jpg (51 KB, 401x500)
51 KB
51 KB JPG
>>59501079
this book is pretty good imo

link here
http://gen.lib.rus.ec/book/index.php?md5=F01EBD1F09886E890058743AA652D7D8
>>
>>59500985
One is for intelligent people
>>
>>59501004
It's not groundbreaking. Just what I'm currently working on in my spare time when not at work.
>>
>>59501079
All you need is the yellow book:
http://www.robmiles.com/c-yellow-book/

free PDF on page + code samples
>>
>>59501089
That fixed it. Thanks. Just changed from 5 to 16
>>
>>59501019
I mean you're wrong. And you're probably a poor fag that lives in you're mother's basement.

But whatever you need to tell yourself to keep you happy. Building servers from scratch for a specific purpose as optimally as possible is enjoyable, flexes my creativity and I get paid for it.
>>
>>59501129
ah. carry on
>>
>>59501143

To avoid this in the future stop using so many 'magic numbers' in your code.

The lengths of your arrays, the parameters of your while loops, the numbers in your if statements, and etc, shouldn't just be a literal like:

>} while (floor >= 10 && floor <= 16);
>if (floor != 13) {
or
>int suitesFilled[5];

These are magic numbers, You see how you would have to keep track of all of those numbers and if you changed anything in the program you would have to go back through and make sure everything that depends on each change is changed as well?

Instead try to dynamically generate these numbers from the values you instantiate other variables with or from macros that way if you make one change everything else changes automatically.
>>
>>59501152
I don't care about what you enjoy doing in your own time, but why do you need to post about such mundane shit here?
If you're going to "blogpost" in /dpt/, at least say something insightful or interesting to anybody other that yourself.

I think that's why most people here don't post about the shit they're doing very often; it's usually not very interesting to others.
>>
>>59501245
alright
>>
Anyone know where to go to find data breach dumps? I cant find this info on google
>>
>>59501347
>>>/g/sqt
>>
I'm re-learning Python. Haven't fucked with it in a few months and I've forgotten a lot of it.
>>
anyone here know anything about http calls in android?

im building an app for a shitty fitness startup and they want to use fitbits API, which is fine but fitbits API has a 30 day token reauth period but i cant figure out a way to determine if the user needs to reauth within android

basically how it works is
>user starts app
>user clicks fitbit as their device
>user signs into their fitbit account via my custom chrome tabs
>user links account
>my app receives the auth token from them and stores it
>token needs to be refreshed every 30 days

the problem is i cant figure out how to tell if the token is expired or not. when i try to pull data with an expired token you just get their old data rather than new data. i cant just time it since some people are going to be using my app and other apps that also have fitbit account sync and the auth periods will overlap
>>

// HotelSuitesOccupancy.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>

using namespace std;

int main()
{
int floor = 10, suitesPerFloor = 20, sum = 0, totalSuites = 120;
int suitesFilled[16];

do {
if (floor != 13) {
do {
cout << "How many suites are occupied on floor " << floor << "?\n";
cin >> suitesFilled[floor];
} while (suitesFilled[floor] > suitesPerFloor);
sum += suitesFilled[floor];
}
floor++;
} while (floor >= 10 && floor <= 16);

cout << "Suites: " << totalSuites << "\n";
cout << "Occupied: " << sum << "\n";
double percentage = sum/totalSuites*100;
cout << "Percentage: " << percentage << endl;

system("pause");
return 0;
}



Why is my percentage value printing out as 0 every single time regardless different inputs. Why is it giving me that?
>>
File: Untitled.png (23 KB, 848x369)
23 KB
23 KB PNG
>>59501453
how about you spend 2 seconds looking up the docs you monkey
>>
>>59501524
Integer division homie, cast the numerator and denominator as floats.
>>
>>59501524
Jesus christ, your program basically does EVERYTHING wrong.
>#include "stdafx.h"
Pointlessly non-portable.
>using namespace std;
Stupid.
>sum/totalSuites*100;
Integer truncation.
>system("pause");
Completely unnecessary and non-portable.
>Using C++ at all
The path to insanity and failure.
>>
>>59501524
Use OCaml next time.
>>
>>59501679
alright man. that worked. thanks. I'm done with this assignment finally.
>>
in my java program i have this bidimensional array[i][2] where the user inputs:
[ID] [height]

and i need to compare all the heights and show the user the largest/shortest height and its ID...

should i use one FOR to get the input and compare the values using the IF statements

or

should i create another FOR just to compare the values?

thanks in advance guys
>>
>>59501707
you bully
>>
Still trying to understand foldr, working on this problem.
>Using foldr, write the function that for any types a, b, and c, takes a function, f, of type ((a,b) -> c) and a list of pairs, lp, of type [(a,b)] and returns a list of elements of type c that is the result of applying f to each pair in lp.

So far I came up with

frMap2 :: ((a,b) -> c) -> [(a,b)] -> c
frMap2 f lp = foldr (\xs ys -> f xs : ys) [] lp
>>
How would you go about implementing a stack using 2 empty queues?

Also how would you implement the operations like push(x) & pop() but you don't have access to the queue's standard operations (like enqueue or dequeue)?

Any explanation will help.
>>
>>59501727
>should i use one FOR to get the input and compare the values using the IF statements
Yes.
Here is some pseudocode because I can't be fucked writing syntactically correct java:
int[][] array = whatever;

// Initialise to some impossible large and invalid values,
// so the checks will always succeed on the first try.
int shortest = maxint;
int shortestid = -1;

while (there is input) {
int id = readid();
int height = readheight();

if (height < shortest) {
shortestid = id;
}

array[id] = height;
}
>>
>>59500925
Try it with a program that continuously outputs data.
>>
>>59501853
>if (height < shortest) {
I forgot to set 'shortest' in this block.
>>
File: 1485814888885.jpg (25 KB, 960x540)
25 KB
25 KB JPG
I want to read a book on algorithms outside my area but I'm paralyzed in doing an assignment for a group system software design class,I cant do this /g/.
>>
>>59501853
excuse for being too dumb, anon, there are such thing as functions in java (like in C) or its all about classes?
>>
>>59501950

cute pupper alert
>>
def pair_factors(num):
for factor in range(1, int(num**0.5) + 1):
if num%factor == 0:
yield factor, num // factor

def gen_triples():
r = 2
while True:
num = r**2//2
for s, t in pair_factors(num):
yield r + s, r + t, r + s + t
r += 2

Why doesn't this generator work? It resets itself to r = 2, instead of staying the in the while loop
>>
File: sy-1.png (225 KB, 580x583)
225 KB
225 KB PNG
>>59501950
you can do it, anon! gambatte!!
>>
>>59501152
>as optimally as possible
>Node.js
Funny joke.
>>
How do i grok GUI programming /dpt/? I can understand frameworks like QT, but isn't there a principle behind all frameworks that i missed in my studies?

For example, how would you make something like Discord, that goes outside of common frameworks visual style? That applies to everything, really. How are game launchers made? They don't seem to use any specific frameworks, it's simple enough that you don't seem to need it. But i have zero clue on how i would even tackle a game launcher.
>>
>>59501786
This is assuming a "normal" queue (FIFO, not a deque etc.), and we have access to how long the queue is.
I'll just call the queues 'A' and 'B', so I don't have to keep typing it out.
Store all of the data in A. When you 'push' to A, just 'enqueue' in A like normal.
When you want to 'pop', you need to just cycle through the queue ('dequeue' it, and then just 'enqueue' it again) the length of the queue - 1 times. When you dequeue the final element, that is the element to return.
You don't even need B in this case.

If you don't have access to the length of A, then you'll need to use B.
Just 'dequeue' from A and 'enqueue' into B, keeping count of how many things you took from A until it's empty.
Then you can just swap A and B to get back to normal.

>>59501957
No. Every function (method) in Java must be attached to some object. The closest thing you have to a function is a static method.
Fucking kingdom of nouns bullshit.
>>
>>59502063
Discord uses javascript with electron as far as I know, so they most likely made their gui using html
>>
>>59502063
Most game launchers just use simple WinAPI widgets, as for Discord they just use Electron which wraps Chrome's web renderer/JS engine so they're built with web technologies.

At the bottom it's all either custom OGL renderers or system native controls that override paint events for fancy stuff.
>>
>>59502011
Post results. I tried your code and it worked for me.
>>
>>59501100
>>59501116
>>59501118
>>59501134
Saved them all, I'll take a look at each and find one or two to stick with. Thanks anons
>>
File: wahnilla.jpg (55 KB, 720x720)
55 KB
55 KB JPG
>>59499557

Learning how to use cvxopt.

>>> P = cvxopt.spdiag([1, 1, 1, 1])
>>> q = cvxopt.matrix(21/4, (4, 1))
>>> A = cvxopt.matrix([1,0,0,1,1,0,0,1,1,0,0,1], size=(3, 4), tc='d')
>>> b = cvxopt.matrix([10, 9, 11], size=(3, 1), tc='d')
>>> sol = cvxopt.solvers.coneqp(P, q, A=A, b=b)
>>> print(sol['x'])
[ 5.75e+00]
[ 4.25e+00]
[ 4.75e+00]
[ 6.25e+00]
>>
File: 1453303517244.png (48 KB, 336x280)
48 KB
48 KB PNG
I want to make a proposal to ISO/IEC JTC1/SC22/WG14.
How does one go about doing this?
>>
>>59502354
you don't, your proposal is probably gonna be trash anyway
>>
>>59502381
Probably, but I think people will like it.
I want them to change the type of string literals from char[] to const char[].
I don't think anybody does that whole "modifiable string literal" shit anymore.
>>
Anyone know how to swap 2 nodes h & g in a singly & doubly linked list when you only have references to them but not there position in the list when working with pseudo code?

Thanks in advance.
>>
>>59502416
You have no choice but to start from the front, and just check if node->next is h or g, remember their positions, and then swap them.
>>
>>59502393
It's defined by the standard to be read only. const is just to help the programmer, it isn't necessary here.

Also I'm sure the ISO C standard autism circle has discussed this before several times.
>>
>>59502155
You're right. But
for i in range(1, 11):
print(next(gen_triples()))

prints tuples (3, 4, 5), which I don't understand why
>>
>>59502469
>const is just to help the programmer, it isn't necessary here
Is that not enough reason?
But now we have _Generic, so it's 'non-const'ness can actually have an effect on decisions in code.
There is a proposal for a const-correct string.h (which also handles wide strings) <tgstring.h>. Having to cast string literals to use this header properly would be really fucking stupid.
>>
>>59502393

Aren't string literals char const[] in c11?
>>
>>59502537
No. I think it is in C++, though.
>>
>>59502523
>tgstring.h
Where do you see this? It doesn't even show up on a google.

It doesn't matter, at all. If you're passing a string literal to an argument that's expecting char *, eat shit.

Enforce it in your code and don't ever create a library that uses _Generic, seems like you might be more suited for C++. It has templates and const char[] string literals.
>>
What are some good/popular networking libraries for games? Any ideas?

I haven't used one before so I don't have any experience to make an informed decision.
>>
>>59502520
It's because every loop creates a new generator. Assign the generator to a variable.
>>> g = gen_triples()
>>> for i in range(1, 11):
... print(next(g))
...
(3, 4, 5)
(5, 12, 13)
(6, 8, 10)
(7, 24, 25)
(8, 15, 17)
(9, 12, 15)
(9, 40, 41)
(10, 24, 26)
(12, 16, 20)
(11, 60, 61)
>>
>>59502657
>Where do you see this?
http://www.open-std.org/jtc1/sc22/wg14/www/wg14_document_log.htm
http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2068.pdf
I check this page pretty often, to see if anything new pops up.
Sometimes there are some interesting proposals. It doesn't mean that they'll all get in, though.
>If you're passing a string literal to an argument that's expecting char *, eat shit.
Yes, I know how to use a string literal properly. It just seems like such a pointless beginner's trap though, and would be a pretty easy fix for a simple kind of bug,
>don't ever create a library that uses _Generic
No. <tgmath.h> is useful. I'm sure they added _Generic so they can reduce the "surface area" of the standard library, and allow programmers to have that power as well.
If they didn't, <stdatomic.h> seriously would have introduced over 100 functions.
>>
are data structures even used in real programming?
>>
>>59502792
Yes.
>>
>>59502792
Yes. Programming consists of just algorithms and data structures.
>>
>>59502768
>over 100 functions
Welcome to C, it's been this way without generics and shitty void * crap since forever. Adding it 30 years later doesn't change shit, no existing code base uses it and there are better languages to write new stuff in.
>>
>>59502792
No, data is overrated.
>>
lain is cute
>>
>>59502913
y-you too
>>
>>59502866
Why are you so adverse to change? C is allowed to evolve over time, as any language would.
None of these things fundamentally change the spirit of C.
I just don't think anyone really gives a fuck about the difference between cabsf and fabsl, or atomic_init_int and atomic_init_float.
>>
Why the fuck do you spergs even bother talking about C? It's obsolete and not worth any attention.
>>
>>59503029
Use Lisp.
>>
>>59503029
>It's obsolete
For something to be obsolescent, something has to obsolete it.
Nothing makes C obsolete. It's still the undisputed king of its domain.
>>
>>59503039
love lisp and c
wheres your god now faggot
>>
>>59503029
Why the fuck do you, sperg, get so mad when people talk about C?
>>
>>59503043
>It's still the undisputed king of its domain.
Which is?
>>
>>59503066
Systems programming, libraries, and high performance software.
>>
do i have to free all dynamic allocated pointers i use in the end of a C algorithm or it makes no difference?
>>
>>59503098
Depends if you want to leak memory or not.

I guess it makes no difference, nobody will use your software anyway.
>>
I have an exam in 80x86 assembly programming in 7 weeks' time but I can't even write "Hello, world" from scratch. The most complicated thing we'd be expected to write is a palindrome checker (although that won't actually be examined). Wat do?
>>
>>59503135

Start studying, I suppose.
>>
>>59503081
>systems programming
So what makes C king when Rust exists?

>libraries
How so?

>high performance software
Vague and subjective, people write high performance software in even fucking Java at the biggest possible scales (like Kafka used by Netflix and Cloudflare) on the internet and it works just fine for them.
>>
>>59503121
what exactly do you mean by leak memory? because i can notice no difference with or without free
>>
>>59503135
>7 weeks
Give up masturbating for a day, get back at it for the other 48.
>>
Who else /deliberately use C over C++/?
>>
>>59503165

Who actually uses Rust for anything?
>>
When will /dpt/ upgrade to engineers and start using Misra C?
>>
>>59503135
>databases exam due in 2 semesters
>still haven't started studying
>>
>>59503218
I use half and half, a lot of my C work could be done in C++ but for imperative programming I feel it's not worth it. Besides idiomatic C++ is cache coherency rape.
>>
>>59503165
>Rust
Rust is new, unproven, and still plagued with problems of its own.
>How so?
C FFIs do damn easily with other languages, and is extremely portable. If you want to write a library that you actually want to be taken seriously, you basically HAVE to export a C API/ABI, and would probably just write it in C to begin with.
>Vague and subjective
What? In the general case, C is faster than basically every other programming language.
How on earth is that subjective?
>>
File: languages3.png (17 KB, 522x384)
17 KB
17 KB PNG
Looks like I need to post it again for all y'all.

Java's performance is better than Python's, but it's not on the same level as C outside of one or two meaningless microbenchmarks.
>>
>>59503218
i use non-oop C++
>>
>>59503166
If you allocate for example 1 KiB of memory to run your algorithm and don't free it, your program just lost track of 1 KiB of memory. Run the algorithm 10 times, now your program is wasting 10KiB of memory.

If your program does a single thing and exits it's not a big deal. It's a problem when you have a long running program that's using a GiB of memory when it should take next to nothing.
>>
>>59503223
People use it to write bots that open PRs to add CoCs to other GitHub projects.
>>
>>59503286
I do that manually.
>>
>>59503269
i use non-functional haskell
>>
>>59503303
All Haskell is nonfunctional.
>>
>>59503251
>100 word essay due in two days
>haven't started yet
>>
C++ is a horrible language. It's made more horrible by the fact that a lot
of substandard programmers use it, to the point where it's much much
easier to generate total and utter crap with it. Quite frankly, even if
the choice of C were to do *nothing* but keep the C++ programmers out,
that in itself would be a huge reason to use C.

I've come
to the conclusion that any programmer that would prefer the project to be
in C++ over C is likely a programmer that I really *would* prefer to piss
off, so that he doesn't come and screw up any project I'm involved with.

C++ leads to really really bad design choices. You invariably start using
the "nice" library features of the language like STL and Boost and other
total and utter crap, that may "help" you program, but causes:

- infinite amounts of pain when they don't work (and anybody who tells me
that STL and especially Boost are stable and portable is just so full
of BS that it's not even funny)

- inefficient abstracted programming models where two years down the road
you notice that some abstraction wasn't very efficient, but now all
your code depends on all the nice object models around it, and you
cannot fix it without rewriting your app.

In other words, the only way to do good, efficient, and system-level and
portable C++ ends up to limit yourself to all the things that are
basically available in C. And limiting your project to C means that people
don't screw that up, and also means that you get a lot of programmers that
do actually understand low-level issues and don't screw things up with any
idiotic "object model" crap.
>>
>>59503303
why would you use haskell at all
>>
>>59503325
Gotta love how many strawmen Linus can fit in a mail.
>>
>>59503286
I published a cargo crate which was just a wrapper over a C library when I was experimenting with Rust, and was published under the MIT license.
Some fucking faggot bot open an issue on my github to relicense it under dual MIT/Apache-2.0 for whatever stupid reason.
That really pissed me off.
>>
>>59503257
>Pick one.
DING DING DING DING DING
THERE'S THAT PICTURE AGAIN
THERE'S THAT PICTURE
THERE'S THAT PICTURE PEOPLE USE WHEN THEY HAVE NO ARGUMENT
HE WON YOU LOST LEAVE AND COME BACK WITH AN ARGUMENT
>>
>>59503248
When the average age in these threads goes above 16.
>>
>>59503335
>Python luser BTFO
>>
>>59503248
we should migrate to basic
>>
>>59503331
>no counterarguments
>s-strawman!!
>>
>>59502460
How would you do this for a doubly linked list?
>>
>>59503257
>Idris
>fast development
Top fucking kek any non-trivial project takes months to build in this shit language. "Hurr durr mathematical abstraction" my ass, use Coq and export it to an actual language if you want correctness so badly. Fucking faggots.
>>
python is comfy
the hate for it just makes me like it more
>>
>>59503364
>literally only a list of borderline ad hominem with no actual examples
>requires counterarguments
>>>/global/rules/2
>>
>>59503223
Mozilla uses Rust for servo (https://github.com/servo/servo) which will replace the current engine in the future.
There's an entire OS that's pretty decent for its age that's writtein in Rust including its binutils and what not (https://github.com/redox-os/redox).
Cisco uses Rust for data processing (https://umbrella.cisco.com/blog/2013/10/04/zeromq-helping-us-block-malicious-domains/).

I don't like Rust very much personally but it's really promising overall.

>>59503255
>Rust is new, unproven, and still plagued with problems of its own.
It's not *that* new, it's 7 years old and while it doesn't compare with really old languages, you can't really say that it's brand new. The good thing is that they're continuously working on improving the language because changes are welcome if its for the better in general so "plagued with problems of its own" is temporary at best (if you're actually thinking about actual issues rather than memeing about stuff you don't like).

>If you want to write a library that you actually want to be taken seriously, you basically HAVE to export a C API/ABI, and would probably just write it in C to begin with.
I guess no one takes Google seriously for writing Tensorflow in C++ then?

>How on earth is that subjective?
The claim was that C is king at high performance software, and while C's speed is unmatched (but some languages come close enough depending on on the impl) you can write high performance software in other languages and will do just fine - no need to give up on language features for the speed.
>>
>>59503335
u mad as fuck
>>
>>59503364
You don't argue against fallacies, idiot.
>>
>>59503396
>It's not *that* new
It hit 1.0 less than 2 years ago.
>I guess no one takes Google seriously for writing Tensorflow in C++ then?
https://github.com/tensorflow/tensorflow/blob/master/tensorflow/c/c_api.h
>no need to give up on language features for the speed
While it is probably be fast algorithmically, I imagine it would be a lot faster if written in C "properly" (be mindful of the cache).
>>
>>59503446
>While it is probably be fast algorithmically
I changed that sentence, and forgot to remove a word:
While it is probably fast algorithmically*
>>
what happens if i do this:
int *p; 
p = malloc(sizeof(int));
*p = 3;
p = malloc(sizeof(int));

will *p become an array or will it allocate new memory and forget the old value?
>>
>>59503495
Latter
>>
>>59503495
You are allocating a new int on the heap while forgetting about the older one. That's called a memory leak.
>>
>>59501079
I bought the same course even though I already knew C# for shits and giggles, everything produced by those guys is absolute cancer tier. I struggle to believe they've ever used anything they teach in a professional environment.
>>
>>59503446
>It hit 1.0 less than 2 years ago.
That doesn't make a 7 year old language new.

>https://github.com/tensorflow/tensorflow/blob/master/tensorflow/c/c_api.h
https://github.com/tensorflow/tensorflow/blob/master/tensorflow/c/c_api.cc

>While it is probably be fast algorithmically, I imagine it would be a lot faster if written in C "properly" (be mindful of the cache).
That is true but again there's no reason to give up on language features when another language can perform the same task reasonably fast while also providing the programmers with many more utilities that help the development process a lot.
>>
>>59503515
>>59503509
is it possible to allocate more memory on *p using malloc and not realloc?
>>
>>59503537
No since malloc allocates a new block while realloc might (and I said MIGHT) extend the current one, but that's not a guarantee either, it might as well just reallocate the whole thing.
>>
>>59503531
>That doesn't make a 7 year old language new.
Nobody gives a shit about a pre-1.0 language. People who want to write reliable software aren't going to use a language which could change under their feet.
>c_api.cc
That means nothing. They still have a C API.
>>
>>59503537
There's no guarenteed way to do that.
>>
>>59503564
ok, thank you anon
>>
Just starting out Java & programming in general

Why does False || True = True? How exactly does that work?

Like if you went binary you are saying 1 or 0 = 1.

First thing I came to I dont understand
>>
>>59503645
https://en.wikipedia.org/wiki/Logical_disjunction
in short or is only false if both operands are false
>>
>>59503667
I will read that, is that why this is true?
(n < m) || (n == m) = (n < = m)

Is essentially one of those two is true, thus making it true (because both operands are not false)

Is && the opposite then?
>>
>>59503697
>Is essentially one of those two is true, thus making it true
yes
>Is && the opposite then?
not exactly the opposite. && only evaluates to true if both operands are true
the exact opposite would be !A && !B or !(A && B) which only evaluates to true if both operands are false
>>
>>59503697
Say it verbally
N < M or N == M is logically equivalent to N is less than or equal to M.
>>
>>59503737
disregard the last sentence. its getting late and i should go to bed
>>
>>59503565
>People who want to write reliable software aren't going to use a language which could change under their feet.
Then why would Dropbox have chosen Go and Rust quite a while ago for most of their core services? Would that imply that a service such as Dropbox does not need reliability because otherwise they'd have chosen C (or any other dated language for that matter)? I know this could be kind of a fallacy because I'm just spouting a big corp name but certainly these languages are reliable enough to put them at scale despite their (relatively) young age. There's also another interesting metric that I am going to link in a follow up post because it's too long.

>That means nothing. They still have a C API.
They do, the library is still written in C++ and the C linkage is just an extra although I agree that this is mostly due to the fact that C can be interfaced with from about any other language. That does not mean that people do not go for native library implementations but I guess this is one of the actual valid reasons for C as initially implied by someone in an earlier post (probably you).
>>
>>59503764
https://telemetry.mozilla.org/new-pipeline/dist.html#!cumulative=0&end_date=2016-04-06&keys=__none__!__none__!__none__&max_channel_version=release%252F45&measure=MEDIA_RUST_MP4PARSE_SUCCESS&min_channel_version=null&processType=*&product=Firefox&sanitize=1&sort_keys=submissions&start_date=2016-03-03&table=0&trim=1&use_submission_date=0
>>
>>59503667
>>59503697
>>59503737
>>59503738
>>59503759
So I have fallen down the rabbit hole here. This shit is fucking weird but very interesting

Currently starting here
https://en.wikipedia.org/wiki/Truth_table
>>
>>59503790
thats a good starting point
>>
>>59503803
Cool. I have taking an edX course on Java and we started with Boolan Calculations. I can do the basic ones (AND/OR/NOT) in my head but I haven't really heard of the others

Is there a use for all those operators? Someone once told me that

x !< 10 is better than x > 10 but I really had no way of knowing if that is true
>>
File: 346.jpg (21 KB, 400x400)
21 KB
21 KB JPG
>>59501950
>read a textbook for college about system design and development
>get bored
>then read a ex-googler's articles of how most practices/methods are wrong or suck.
WHO DO I TRUST?!?!?
>>
>>59503857
>Someone once told me that
>x !< 10 is better than x > 10
that should not make a difference and even if it did it would probably be optimized by the compiler
>>59503857
>Is there a use for all those operators?
|| and && are used very frequently to test for multiple values and | and & is often used to check/test for bitflags
>>
>>59503902
I don't know what | and & are yet but I will look out for it
>>
File: Capture.png (29 KB, 914x400)
29 KB
29 KB PNG
How do I move entA out of entB or vice versa?
>>
>>59503953
Bitwise operators. They do logical operations with each bit for two numbers such as 0001 and 1110.
>>
>>59503764
>>59503531
>>59503396
You sound really desperate to have your choice of social circle validated by a totally different social circle. If it was actually about programming, you'd just be writing code, but as we know, Rust evangelists aren't capable of doing that.
You can't have it all. You should make up your mind about what kind of company you want to keep.
>>
>>59504124
>Rust evangelists
I don't even like Rust that much myself senpai.
>>
>>59504012
Usually you do the collision check before you actually would move the entity into the other one. Else you can just try to shove it out. (Take the vector from enta to entb and shove entb that way)
>>
>>59499557
Being more than slightly annoyed at the distinct lack of easy to use implementations of post-quantum asymmetric cryptographic standards.

Being even more annoyed at the distinct lack of pre-quantum equivalents.

Guess I've got to be content with the NSA reading all the shit I do in the meantime as soon as they've got a decent quantum computer.
>>
Daily reminder that a survey a couple days ago proved approximately no one here actually knows rust. Everyone shilling it is a troll or a wannabe idiot.
>>
>>59499557
FizzBuzz
>>
Am I retarded for doing this if I don't want to use regex?

isNumber(char c)
{ int i;
char numbers[10] = {'0','1','2','3',
'4','5','6','7',
'8','9'}
for(i=0;i<10;i++)
if(numbers[i] == c)
return 1;
return 0;
}

I suppose I could just check if c is within the ASCII codes for numerical values but I'm checking for other types of characters (that aren't sequential) in other functions so I just wanted to be consistent.
>>
File: laughing_loli.gif (134 KB, 340x340)
134 KB
134 KB GIF
>his language has two types of strings
>>
File: .png (599 KB, 1000x1000)
599 KB
599 KB PNG
I JUST WASTED THREE FUCKING HOURS TRYING TO DEBUG MY HOMEWORK WHEN I HAVE A MIDTERM TOMORROW BECAUSE I PUT A SEMICOLON AT THE END OF AN IF STATEMENT

REEEEEEEEEEE
>>
>>59504306
That is a naive way to do it, but it works.

This would be better:
bool isNumber(char c)
{ return (c >= '0' ) && (c <= '9');
}
>>
>>59504338
Mine has 3
>>
>>59499605
kek
>>
>>59504344
Got an exam tomorrow too, what are you in for?
>>
>>59504344
semicolon.cpp:4:21: error: suggest braces around empty body in an ‘if’ statement [-Werror=empty-body]
if (semicolon == 1);


:^)
>>
>>59504344
>not knowing how to read error messages
>>
File: 1481933632025.png (18 KB, 203x209)
18 KB
18 KB PNG
>>59504344
>his language uses semicolons as delimiter
>>
requesting that picture of a glacier and git commands
>>
>>59504344
That's not a problem in better languages, tbqh
>>
File: Capture.jpg (20 KB, 469x122)
20 KB
20 KB JPG
I'm trying to find how to apply Y in this here loop. Should be a simple fix, but I can't figure this shit out considering the 2d array in question needs to be a string so I can't use Integer.parseInt, which is what most of the shit I'm finding on Stackoverflow says to use.
>>
File: sweatingpepe.png (551 KB, 964x912)
551 KB
551 KB PNG
>>59504381
Abstract data type containers, linked lists, stacks, stack implementations, and recursion.
>>
>>59504431
Does that not work?
>>
>>59504456
intro to data structures or something?
>>
File: cute anime pic 0137.jpg (51 KB, 640x634)
51 KB
51 KB JPG
>>59504431
>NCAA
ISU never made it in, and just got knocked out of the NIT. Thanks for reminding me
>>
>>59504480
Yep.
>>
>>59504344

reevaluate u're life
>>
File: Capture2.jpg (380 KB, 1184x695)
380 KB
380 KB JPG
>>59504468
It sets every value in the 2D array to the first value in the file. Each value is separated by a comma, hence the usedelimiter. I need to find a way to set teams[x][y] = the string on [x][y] location in the file. Pic related is what the data in the file looks like.
>>
>>59504489
Stacks: Push and pop. Implement using an array or something (maybe "dynamic array" or whatever buzzword)

recursion: calling the same function with a smaller scope basically

linked list: nodes with pointer to next node.

Abstract data type containers: you mean a structure? Just something that represents something else basically.

Good times.
>>
>>59499557

I want a program that helps me illustrate the relationships between the concepts I'm learning at uni. I want the illustration to be similar to a web diagram.

I looked for such a program and couldn't find it, so I'm trying to make my own program instead.

The issue is - I only know how to program in python.
>>
>>59504512
use Integer.parseInt and then cast it as a string if it needs to be a string.
>>
how do i become good at source control

like i used github personally for a long time but now im "on the job" and my people use repos for all their shit and i feel like im constantly playing catchup with the master branch and i can barely do any work because i spend all my time carefully treading around the existing code because i know someone else is editing it so my code will need to be edited over and over as they push

like im not even spaghetti coding right now and i feel like i have to basically wait until everyones sleeping just to have a shot at editing a version of the code that wont have hundreds of conflicts
>>
>>59504306
There is an better way to do it (in C99). It requires a little bit more memory, and a bit more code, but is extremely efficient.
bool is_hex(char c)
{
static const bool lut[UCHAR_MAX] = {
['0'] = 1,
['1'] = 1,
['2'] = 1,
['3'] = 1,
['4'] = 1,
['5'] = 1,
['6'] = 1,
['7'] = 1,
['8'] = 1,
['9'] = 1,
['a'] = 1,
['b'] = 1,
['c'] = 1,
['d'] = 1,
['e'] = 1,
['f'] = 1,
['A'] = 1,
['B'] = 1,
['C'] = 1,
['D'] = 1,
['E'] = 1,
['F'] = 1,
};

return lut[(unsigned char)c];
}

GCC has an extension for initialiser ranges, but lets keep it standard.
>>
>>59504551
I'm a bit puzzled at the moment on how ParseInt is supposed to be structured and I'm in a bit of a hurry since I procrastinated like a dumbfuck. Mind showing an example on what you mean?
>>
>>59504527

use graphviz
>>
What's the best way to implement a "Roman Numeral" system?

I currently have some god damn ugly abomination that converts from a string of numerals to a number, trying to come up with number-> Roman Numeral just seems like a god damn pain... Should I just resort to using Boost?
>>
>>59504527
Are you really sure you can't find a good mind-mapping software that suits your needs? There's dozens of them.
>>
>>59504648
data RomanDigit a =
O -- 0
| I a -- 1
| V a -- 5
| X a -- 10
| L a -- 50
| C a -- 100
| D a -- 500
| M a -- 1000
>>
File: 1483915385806.png (602 KB, 963x720)
602 KB
602 KB PNG
Am I an inhabited type?
>>
>>59504687
Fair enough, but I meant more like "IV" == 4, "IX" == 9, "CM" == 900, and so on...
>>
>>59504596
How do your coworkers get around it?
>>
>>59504706
absurd
>>
>>59504742
N-not in front of everyone.
>>
>>59504730
roman O = 0
roman (I x) = 1 + roman x
roman (V x) = 5 + roman x
...

then you can just write Read/Show instances to make it work with strings
>>
>>59504648
ur shit
void print_roman(unsigned n)
{
struct {
unsigned val;
const char *str;
} num[] = {
{ 1000, "M" },
{ 900, "CM" },
{ 500, "D" },
{ 400, "CD" },
{ 100, "C" },
{ 90, "XC" },
{ 50, "L" },
{ 40, "XL" },
{ 10, "X" },
{ 9, "IX" },
{ 5, "V" },
{ 4, "IV" },
{ 1, "I" },
};

int i = 0;
while (n > 0) {
if (n >= num[i].val) {
n -= num[i].val;
printf("%s", num[i].str);
} else {
++i;
}
}

putchar('\n');
}
>>
>>59504344
CL-USER> (read-delimited-list #\;)
>his language doesn't allow him to use anything as a delimiter;
(>HIS LANGUAGE DOESN 'T ALLOW HIM TO USE ANYTHING AS A DELIMITER)
>>
>>59504784
>doesn't
>DOESN 'T
>
>>
>>59504619
bumping my own retarded request because I have to hurry up on this project or my ass is grass
>>
>>59504766
void function()
{
struct {

} variable [] = {
};
}


...Huh... I've never seen that before... Are you essentially creating a map<int, string>? Because I'm not entirely sure how num [] works in your case.
>>
>>59504806
It's an array of structs.
Why do sepplesfags always try to overcomplicate simple concepts?
>>
>>59504648
In Lisp this is just
(format t "~@r" number)
>>
File: 1489872166650.jpg (74 KB, 1280x720)
74 KB
74 KB JPG
>>59504827
>not realising the exponential is isomorphic to a repeated product
>>
>>59504512
teams[lineNumber] = line.split(",");
^ is pseudocode but accomplishes something like what you want.
>>
>>59504901
"line cannot be resolved"
>>
>>59504931
It's pseudocode that I made up. line represents a string of the current line you are parsing.
>>
>>59499557
C baby here. Why am I getting a segmentation error?
<code>
#include <stdio.h>

int main (){
int value = 0;
printf("Hi, welcome to fizzbuzz!\nType your number.\t");
scanf("%d", value);
printf("Entered value is %d", &value);
}</code>
>>
>>59505004
scanf's second argument is a pointer to where you want to store the data. It should be.
>scanf("%d", &value);
>>
>>59505004
>scanf("%d", value);
>printf("Entered value is %d", &value);
You've got these two things backwards. scanf requires the pointer (&) and printf requires the int itself.
>>
>>59505004
just learn python instead
>>
>>59505021
>>59505025
Thanks.
>>
>>59505004
For future reference, use square brackets for your code tags. ([ and ])
>>
>>59505045
Thanks for this as well.
 Testing. 
>>
>>59505002
How would I convert each row of the file to a string in the loop?
using String line = new String(MMfile.toString()); would make the string into a 2D array (causing a mismatch), so I need to find a way to only convert the current row (x value in the loop I made) to a String.
>>
>>59505076
You should really look this up on google.
If MMfile.toString() produces the whole file you could try MMfile.toString().split("\n"). I really recommend you google how to do it correctly though.
>>
>>59505106
Alright, thanks for your help man. Wish me luck.
>>
printf("%s",_functionThatReturnsAstring());


Is this possible in C? I'm guessing the function should return a char pointer in this case.
>>
>>59505262
Yes, you can always pass the return value of one function as the argument to another, so theres no reason this is bad as long as the result is a string, like you expect it to be with %s.
Just be careful to clean up the string if it was malloc()'d in the function that returned it
>>
>>59505262
Yes
>>
>>59505262
Sure, but there are problems, depending on how the string being returned is allocated.
If the string is dynamically allocated (i.e. via malloc), you will leak memory after you print it, as there will be no way to free the pointer.
>>
>>59500985

What website is that?
>>
>>59505040
>messes up in calling api
>get asked to learn a language without static typechecking
Yeah because he will do so so much better when python does random shit as things go wrong and he might not even notice.
>>
>>59505371
Looks like hackerrank.
>>
>>59505371
https://www.hackerrank.com
Please learn how to use google next time
>>
>>59505384
C is horrible at catching bugs at compile time. For instance, why didn't it catch the scanf error?
>>
>>59505402
Most compilers will give you warning for doing that
>>
>>59505388
>>59505402
Because it's not an error
At least not a compile time error
>>
>>59505429
Hackerrank isn't an error?!
>>
>>59505402
Because its a format string function (doesn't actually do typechecking sadly, outside of certain compiler extensions). Vararg functions in general tend to be problematic. But both of these are rare.
Python doesn't do it at all until runtime and its far less intuitive in its checking so that's way worse.
Not to mention that there's a great deal of difference between proper pythonic code and what a rookie will write. Not the case in C really.
>>
>>59505429
Its an error. It always produces undefined behavior. You should treat it as an error, not as a "bug at runtime".
This extends beyond type systems. For instance, some dynamically typed languages reject programs with undefined globals, others delegate to runtime. Either way it is behavior that is always an error.
>>
>>59505262
The one thing to watch out for is if these aren't functional functions. Meaning they handle some global state or modify the same arguments.
Because C doesn't define what order parameters to functions are evaluated so even if it happened to be right in one case it might fail in another case.
Which has good reasons.
>>
>>59505433
Woops, didn't mean to reply to that post
>>
File: cuddle.jpg (209 KB, 694x1141)
209 KB
209 KB JPG
>rainy outside
>sitting inside on my computer reading "Programming in Lua"
Who here /comfy/?
>>
>>59505489
Fuck you, learn Lisp.
>>
I'm working on a digital defence system called ...


Sky-Net.
>>
>>59505478
>Which has good reasons.
No, not in 2017
>>
New thread when?
>>
>>59505518
>hardware constraints disappeared because it's the current year
>>
>>59505518
No it's more vital now than ever.
If you care about performance and realise that ordering the arguments in one way may be less performant than ordering them another way, and the compiler doesn't allow itself to do that, then you would have to manually change the function prototype and profile it.

And imagine having all those different overloads or function variants that just take arguments in different order.
It'd be an incredible headache. Now something you can have is a keyword that forces strong ordering of the arguments. That'd be fine. Or you'd have people who care about performance markup their function calls when argument order doesn't matter. Which I don't think will be popular with the community.
>but the performance gains are insignificant
They absolutely huge anon. Because of how OOO processors are nowdays it wouldn't surprise me that as few arguments as 3 or 4 could multiply the execution time by 2 or so. If the functions don't happen to have dependencies (if that were the case you should have just sorted your arguments by calling them outside the parameter list).

Now it happens to be the case that C++17 is putting exactly the wrong kind of restriction on function calls. They will allow them to remain about as unpredictable as they are now. It's just that compilers can't weave the operations inside the functions. They're still unordered they just removed one of the most important thing about having this.

Demonstrating once again that the committee is just braindead.
>>
>>59504613
That's probably actually slower as it has to access memory that may be out of cache.
>>
>>59505644
Depends on the use case. If you're using it often the branch you take with checking the ascii range is worse. I'd expect string processing functions to use it a lot though. It's a shame bool is as big as it is though.
>>
>>59505619
Do you define
static inline void amb(unsigned xx, ...) { } #define amb(...) amb(0, __VA_ARGS__)

and use it like:

amb(x[0] = y[0], x[1] = y[1], x[2] = y[2], x[3] = y[3]);

as well?
>>
new bread >>59505732
>>
>>59505708
No.
When you care about performance you normally don't use them (its rare for their use to not impact you in some way).

But for most uses of variable argument functions you don't care that much right? Then it's fine. You still have to understand that there's no ordering though.
>>
need ideas for beginner c++ projects
>>
>>59506232
3d game engine




Delete Post: [File Only] Style:
[Disable Mobile View / Use Desktop Site]

[Enable Mobile View / Use Mobile Site]

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.