[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
/dpt/ - Daily Programming Thread
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 255
Thread images: 33
File: K&R hime linked list copy.jpg (551 KB, 1280x1440) Image search: [Google]
K&R hime linked list copy.jpg
551 KB, 1280x1440
old thread: >>55154853

What are you working on, /g/?
>>
>>55163989
First for D
>>
>>55163989
Kill yourself
>>
Bare bruk Haskell, Elm og Idris, når skriver dere nye ting.
>>
cute girls
>>
>>55164037
>når skriver dere nye ting.
Når dere skriver nye ting (programmer hores mer naturlig ut).
>>
>>55164087
Takk!
>>
C++ question

How do I parse string "9,3,12"

then push each individual value into a list?
>>
I am learning about networks, so that I can be proficient while hosting a website. I am stuck at the following.
Ok. So I found that the subnet physically can just be a switch.
Furthermore, subnettting further divides the host part of an IP address into a subnet and host address, and a subnet.

But physically, what is the Subnet Mask? When i type in ipconfig, i get 255.255.255.0. What is this?? Why is this 255.255.255.0, and not 255.255.0.0?
>>
File: Screenshot.png (96 KB, 1024x600) Image search: [Google]
Screenshot.png
96 KB, 1024x600
I've tried to program for ages, however I can never get it. I saw pic related in the last thread and for the past few hours tried to apply some algorithms, but I can never get it. I suppose I see projects online like coin flippers, tic tack toe, etc and I try them but can never get them to work, or I feel like they're too boring and I'm not learning shit.

So can anyone give me some guidance to basic projects that will teach me application of fundamental programming concepts, as well as a book or something to study from.

If it helps, I've tried C C++ and Python.
>>
>>55164126
What you want is called splitting a string (based on the character ','.
Take a look at this http://stackoverflow.com/a/236803
>>
>>55164126
char *str = "9,3,12";
struct {
int num[1000];
int index;
} list;
char *tok = strtok(str, ",");
while (tok)
{
list.num[list.index++] = atoi(tok);
tok = strtok(NULL, ",");
}
>>
>>55164128
Indicates which portion of the IPv4 address is the network portion and which is the host portion

192.168.120.0
11000000.10101000.01111000.00000000

255.255.255.0
111111111.111111111.111111111.00000000

Any bits in the address that match with a 1 bit in the subnet mask are part of the network portion, everything else is the host portion.
>>
>>55164177
wait

char *str = "9,3,12";
struct {
int num[1000];
int index;
} list = { "", 0 };
char *tok = strtok(str, ",");
while (tok)
{
list.num[list.index++] = atoi(tok);
tok = strtok(NULL, ",");
}
>>
>>55164194
what the fuck
>>
>>55164146
Download this:
https://www.visualstudio.com/en-us/products/visual-studio-express-vs.aspx

Do these tutorials:
http://www.tutorialspoint.com/csharp/

Go through them one by one, and don't just copy/paste the code into your editor. Write them in by hand, play around with what you're typing in, modify the code in the tutorials so you understand how it all works together, what controls what etc.

As for basic projects, that's really up to you. Try to think about what you know how to do, then what you can build based on that. If you know how to take user input, do some basic math, and display numbers... then that's enough for a BMI calculator, so try to put one together. If you're missing a crucial step, say displaying the output, then you google and try to figure out how to do that. Rinse and repeat until you git gud.
>>
How does RAM navigate to its address?

If I tell my computer to read the contents at the address 0xFFFFFFFFFFFFFFFF, does the memory controller start searching for that address beginning with 0x0000000000000000 to 0xFFFFFFFFFFFFFFFE?
>>
File: 2ndbestimage.jpg (587 KB, 845x1200) Image search: [Google]
2ndbestimage.jpg
587 KB, 845x1200
Question: I already started learning Python, but due to my busy schedule as a student. I can vaguely remember half of what I learned.

So should I instead scrap python and begin on a new?

I'm thinking about learning C.

Thanks in advance.
>>
>>55164309
>but due to my busy schedule as a student i forgot information
Why do you even go to college?
>>
>>55164309
Scrapping python and learning C is never a bad choice. Unless you're dead set on making web servers and nothing else I suppose.
>>
File: 1454304293223.png (1 MB, 1280x720) Image search: [Google]
1454304293223.png
1 MB, 1280x720
>>55163989
Please, make more of these!
>>
>>55164309
>2ndbestimage.jpg
Whats the best image?
>>
>>55164194

Er, I get where you're going with this but it seems a bit weird.

>>55164149

I like how the person explains it/does this, but I can't particularly do this as functions. More so, I just need to do it on the fly in the main.

Can I not just use a for loop and if (string[i] == ',') while iterating through the string? I mean I can't 100% get it to work as i's iteration isn't managed as easily but...
>>
>>55164309
you don't even have time to learn like the simplest language there is and you want to learn C instead for no reason?
>>
>>55164335
There's another sequence in this same scene where Unko shows hime a page from that book, but I don't know what to put in there.
>>
>>55164146
C++ Primer Plus, soon or later theyll teach you basic alorithms and its implementation
>>
first for rust
>>
>>55164384
What ep and offset? Or could you post an image maybe? I could try helping.
>>
Let's say I have this function:
int i(const int &j)
{
//poo in loo here
}

Is it possible to create an easy reference to this function in C++?
>>
>>55164323
It's a hybrid, I'm not from the U.S so It's mandatory.
>>55164329
Hell, I want to develop software or even OS'.
Web can be a side thing, though.
>>55164342
For you.
>>55164377
In a year, I will attend an IT university and right now I have summer vacation.

So I thought, why not use the time productively?
>>
>>55164414
The other one's better imo
>>
>>55164402
ep4, 2:34

I don't know why you couldn't just look it up, the entire show is like 20 minutes.
>>
>>55164344
You're asking for homework help aren't you?
Let me sudo code you an algorithm.

You want to accumulate every digit between commas into one number.
For every digit you should shift the current number left one place, then add the digit.
Let's say you are parsing the number 1234.
You read the 1, number = 1
read the 2, number *= 10 + 2. Number is now 12.
read the 3, number *= 10 + 3. Number is now 123.
Then when you get to a comma, store the number in your array.

So it would be something like this:
arr[]
index = 0
number = 0
while string is not empty
read char from string
if char is not ,
number *= 10
number += convertToInt(char)
else
arr[index] = number
index++
number = 0
>>
>>55164424
Doesn't matter, because she is best girl.
>>
>>55164441
Because I do not wish to waste 30+ minutes of my life trying to search just one little moment, and since you knew exactly where it was, why not just ask you instead?
>>
>>55164344
>Er, I get where you're going with this but it seems a bit weird.

You didn't tell me for how long you would need the list of numbers.
I could have written up a linked list or a hashmap, but that's outside the scope of your question.
>>
File: Sad-Frog-Meme-Gun-041.jpg (19 KB, 400x388) Image search: [Google]
Sad-Frog-Meme-Gun-041.jpg
19 KB, 400x388
>JOB DESCRIPTION

>JUNIOR SMART CONTRACT DEVELOPER (SOLIDITY)
>REQUIREMENTS:
>EXPERIENCE WITH ETHERIUM, BITCOIN, SOLIDITY, SERPENT
>STRONG KNOWLEDGE OF EVM AND ERE ENVIRONMENTS
>FAMILIARITY WITH APPLIED CRYPTOGRAPHY AND OTHER BLOCKCHAIN TECHNOLOGIES DESIRABLE BUT NOT REQUIRED
>COMPENSATION: 150000$ WITH PERKS INCL FULL DENTAL INSURANCE

tfw haven't learned solidity can't get a job
tfw learned java instead
no java jobs only etherium/serpent/solidity

I'm a failure? I'm a failure. A fuckin failure.
>>
>>55164510
You could always learn those languages
>>
File: itsoktofeelthatway.jpg (103 KB, 318x700) Image search: [Google]
itsoktofeelthatway.jpg
103 KB, 318x700
>>55164510
Wow, calm down there, frogger.

Try turning off caps lock before you write your posts, okay?
>>
>>55164473
calm down anon

have you thought of some dialog?
>>
>>55164464

>Let me sudo code you an algorithm.
Pseudo code.
>>
Working on this programming language that I made, as usual:

https://github.com/jesserayadkins/lily
>>
>>55164510
150k a year for a junior to make meme buttcoin contracts that directly handle the company's cash flow?
What the actual fuck.
>>
>>55164559
>brackets
pass
>>
What's the difference between
#define PI 3.14
and
const pi = 3.14;
? I would think using const would provide more information to the compiler for optimization.
>>
>>55164575
That's a shame, but at least one person looked at it. :)
>>
>>55164579
#define is just a search and replace through your program that changes all instances of PI to 3.14.

int x = PI;
becomes
int x = 3.14;

Before the compiler even gets to look at your code.
>>
>>55164562
These are not meme contracts these are UNSTOPPABLE decentralized applications, anon
>>
File: 1462517434635.jpg (863 KB, 1280x1347) Image search: [Google]
1462517434635.jpg
863 KB, 1280x1347
>>55164547
>calm down anon
I am not upset

>have you thought of some dialog?
You could use these frames (pic). I was thinking of saying something simple like "and this is how you do a binary search" while showing a page from chapter 6.5 (where it has trees and a binary search implementation).

Sorry for the jpeg, but I forgot to configure my mpv to save in png.
>>
>>55164603
>https://github.com/jesserayadkins/lily
Looks cute.

>>55164625
Tell that to DAO. But "to the moon!" amirite?
>>
>>55164620
So it seems like there's pretty much no reason to use #defines instead of consts if you care about the compiler optimizing as much as possible.
>>
>>55164559

Well, this actually looks pretty fucking cool. How long have you been working on it?
>>
>>55164559
It seems cute and cool, I will look more deeply into it tomorrow.

>cmake
you disappoint me
>>
>>55164559
Doesn't look bad
I've wanted to build my own language, but making a compiler looks like a shit ton of work. Maybe I need to learn Flex and Bison to get myself started.
>>
>>55164683
Thanks! It'll be 5 years as of next month.
>>
File: etherium_glossary.png (265 KB, 703x982) Image search: [Google]
etherium_glossary.png
265 KB, 703x982
>>55164674
They fucked up their programming, Vitalik will save us from this failure short-term and provide long-term incentives to build tools to develop safe smart contracts https://blog.ethereum.org/2016/06/19/thinking-smart-contract-security/
>>
>>55164677
math.h uses
#define PI 3.14159265358979323846

I can't think of any optimizations the compiler would do on const int pi = 3.14 that it can't do on #define PI 3.14 desu.

http://stackoverflow.com/questions/27068362/static-const-vs-define-for-efficiency-in-c

This shows they both compile to the same thing.
>>
>>55164579
>I would think using const would provide more information to the compiler for optimization.
Nope. With #define, the compiler gets the immediate value 3.14 which is obviously constant. With const, you're trusting the compiler to take the hint and do the right thing.
There is nothing wrong with using const, but it doesn't allow for more optimizations than #define. The main reason to use const is for better error reporting, or if you want to take the address of a constant for some reason.
>>
>>55164702
Neat. You don't need to write your own compiler, since you can opt to hook into something existing like jvm/clr/llvm and work with that. Parsing and lexing aren't too bad if you do them yourself. The lexing might be tough at first with off by one's, but once you get a tokenization step that works, it pretty much never has to be touched again.

Hand-writing your own parser, recursive descent is a little harder, depending on the grammar you want to do. You might be able to find a 'build you a lisp' tutorial, since lisp is easy to parse and then once you get the feel for it branch from there.
>>
File: 03933712-photo-gnu-fsf.png (37 KB, 672x656) Image search: [Google]
03933712-photo-gnu-fsf.png
37 KB, 672x656
>>55163989
>mfw I just got away with plagiarizing another assignment
>mfw I got 100%
>>
>>55164772
I'm not actually using pi, it was just an example.
#define MY_CONSTANT 3
const int my_constant = 3;
>>
>>55164803
Reported
>>
>>55164409
typedef int (*iptr)(const int &j)

iptr var = i;
>>
What's better, python or ruby?

if you're going to be a smug prick and say they're both shit don't bother responding. I'm so fucking sick of you cunts
>>
>>55164803
Was it programming?

>mfw classmate copied my assignment
>mfw reported him
>>
>>55164803
Consider suicide.
>>
>>55164772
const static has the benefit of block scope while #define is global everywhere
>>
>>55164830
>python
>ruby
>>
>>55164836
Yes it was programming.
>>
>>55164830
Both are shit. Learn C.
>>
File: 1444848982407.png (1 MB, 1110x1600) Image search: [Google]
1444848982407.png
1 MB, 1110x1600
>>55164830
Both shit m8.
>>
>>55164836
story pls
>>
>>55164830
I hope you weren't expecting serious answers after that last part
>>
>>55164830
What are you trying to get into?
>>
>>55164848
>he can't get 100% without copying others
>>in programming
You must be a sad person.

>>55164859
It's secret
>>
Why aren't you part of the C+JS master race?
>>
>>55164871
i'm trying to make a compiler. why?
>>55164850
No
>>
>>55164772
>they both compile to the same thing
Perhaps not with -O3. The fpu in 86/64 chips is 80 bits wide, while doubles are 64bits. Storing mPi locally can sometimes force a 64bit coputation as on lesser optimization levels.
>>
>>55164877
You're just mad I got marks by cucking someone by using their code without their permission or license. 300k starting here I come.
>>
>>55164866
>>55164856
>>55164871
>>55164850
>>55164843

Just fucking kill yourselves already. I'm so fucking done with this shitty ass board and the shitty people who inhabit it. I want this place to fucking burn and would DDoS it into oblivion if knew how. You people don't fucking deserve to have a place to act like an ass unrestrained
>>
>>55164886
Lisp
>>
>>55164907
It's well known around this place since the ancient times that python and ruby are both shit, oriented for hipsters, sjws and pajeets and ignore thousands of years of research.
>>
>>55164727

Shiiiiit, that's a lot of work for a language.

>>55164897

Employers look for experience, not just degrees. So you're actually kind of fucked if you're not doing any work of your own in your spare time.
>>
>>55164922
>oriented for hipsters, sjws and pajeets and ignore thousands of years of research.

that's not even a fucking sentence. How the fuck can you be expected to judge a programming language if you can't even speak a human one?
>>
>>55164886
If you're trying to make a non-serious compiler, then either language will do. You may want to check for libraries that you think you'll need, as that will be the make/break for you.
>>
>>55164943
It is you fucking retard.
>>
>>55164945
No
>>
>>55164943
Not him, but it is a valid English sentence. Maybe the lack of the Oxford comma is confusing you?
>>
>>55164933
>So you're actually kind of fucked if you're not doing any work of your own in your spare time.

Why would I do work in my free time? Sounds pretty gay, bro. They should pay me.
>>
>>55164922
how the fuck do they ignore research?
>>
>>55164126
http://en.cppreference.com/w/cpp/locale/ctype_char
#include <iostream>
#include <locale>
#include <vector>

struct csv : public std::ctype<char> {
static const mask* make_table() {
static std::vector<mask> v(
classic_table(),
classic_table() + table_size);
v[','] |= space;
v[' '] &= ~space;
return v.data();
}
csv(std::size_t refs=0) : ctype(make_table(), false, refs) {};
};

int main() {
// whatever stream you read from
std::cin.imbue({std::cin.getloc(), new csv()});

int a,b,c;
std::cin >> a >> b >> c; // 1,2,3
}
>>
>>55164968
>>So you're actually kind of fucked if you're not doing any work of your own in your spare time.

This is actually pretty fucked up.
Programming ability is treated like a artistic skill, yet you have none of social currency of being a skilled artist.
>>
>>55164985
Next time please try to include any additional questions or requests in your original reply otherwise you may be accused of samefagging.
>>
>>55165015
>Programming ability is treated like a artistic skill, yet you have none of social currency of being a skilled artist.
but i'm a code artisan though
>>
Decided to finally look at Shen today.

Lots of really cool ideas, but ultimately it makes several big mistakes:
((/. -> fuzz))
doesn't behave as expected

I can't give provide any arbitrary predicate to
datatype


"Polymorphism" exists essentially in name only -- there's no convenient way to match based on type. I can't extend the semantic system to destructure any type I define

Lazy evaluation is a second-class citizen

No predicates like pair? or list? builtin

It does do some cool stuff:
>type system optional
>strong, expressive typing based on good mathematical principles
>hosted on a bunch of platforms
>builtin DSL for Yacc
>better support than its competitors (read: Haskell) for meta-programming and language extensions
>backtracking is sweet
>hosted on various platforms in an intelligent way

Ultimately, it gave me a few things I want to implement in Scheme, so it wasn't a total loss of a couple hours. Shen is great, it just feels incomplete.
>>
>>55165046
what the fuck are you talking about?
>>
>>55165053
The Shen programming language
>>
>>55164933
I am doing an internship. Stay homo gayboy.
>>
>>55165017
you're literally pulling criticisms out of your ass and trying to deflect
>>
>>55165082
Are you seriously expecting help from someone that you said >>55164943 and who after that tried to samefag?
>>
>>55164830

Both languages offer similar feature sets, but take different outlooks on how they should be programmed. Ruby follow's Perl's "there's more than one way to do it" approach, while Python behaves the exact opposite, and its users believe that there is only one way to do things, and that way is the correct way. Both are object oriented, but Python likes to do some rather silly things with some object __properties__, while Ruby is very much influenced by smalltalk, and I feel it's easier to hack about with (although it's also easy to do stupid things like undefining the + method on integers)

>>55164922

>Ignore thousands of years of research

How many programming languages, actually used today, are based on research into programming language theory, and how many are just based on what seemed like a good idea at the time?
>>
>>55164271
That is actually a fairly complicated question. Do you know anything about Virtual/Physical Addresses, Paging, MMUs, or the architecture of DRAM modules/memory bus system?
>>
Write a program detab that replaces tabs in the input with the proper number of of blanks to space to the next tab stop. Assume a fixed set  of tab stops, say every n columns.


Can anyone explain to me what this part means?
> Assume a fixed set of tab stops, say every n columns.

Is this to take into account tab stops getting to the "end" of the "page" and into a newline?
>>
>>55164183

>192.168.120.0
>11000000.10101000.01111000.00000000

>255.255.255.0
>111111111.111111111.111111111.00000000

>Any bits in the address that match with a 1 bit in the subnet mask are part of the network portion, everything else is the host portion.

So that means that the network portion is, 19 2 0 or something? I don't get it.
>>
What's the best language+library to make an android application?
>>
>>55165460
>android
Java
>>
>>55165169
N-no.
>>
>>55165551
and library?
>>
>>55165451
11000000.10101000.01111000.00000000 (192.168.120.0)
111111111.111111111.111111111.00000000 (255.255.255.0)
|------------------------------------------| |------------|
Network Portion Host Portion

The network portion can't be touched, so in my example of 192.168.120.0, the first three numbers (the first 24 bits) must always remain the same. The last number (or last 8 bits) is fair game for you or a dhcp server to modify and give out to computers on your network. That includes all addresses from 192.168.120.0 - 192.168.120.255. Actually 192.168.120.0 would be the network address and 192.168.120.255 would be the broadcast address (being the first and last addresses of your range) so they can't be used, but everything between is fair game.

It would be a good idea to learn binary if you don't know it already
>>
>>55165590
You use libraries based on your needs not for fun. Thus it depends on the kind of the program you are going to make.
>>
>>55165616
I need to make a anki clone.
>>
>>55164126
stringstream
>>
>>55165451
>IPv4 address: 192.168.1.85
>Subnet mask: 255.255.255.0
>Network ID: 192.168.1.0
>Host ID: 85
Each block of 255 in the subnet mask reserves a portion of the address as the network ID. Any block with a 0 in the subnet mask is a part of the Host ID.
Its useful to think of it like this:
>[ 192 ] . [ 168 ] . [ 1 ] . [ 15 ]
>[ 255 ] . [ 255 ] . [ 255 ] . [ 0 ]
>[ Network ] . [ Host ]

Another example:
>192.168.3.14
>Subnet mask: 255.255.255.0
>Network ID: 192.168.0.0
>Host ID: 14
>>
>>55165633
You do not really need to use any library then, other than the ones that come with the android framework at least.

If this is not for educational purposes you can also run the original Anki in Android.
>>
>>55165649
Formatting died its more like:
[ 192 ] . [ 168 ] . [ 1 ] . [ 15 ]
[ 255 ] . [ 255 ] . [ 255 ] . [ 0 ]
[ ---------Network-------- ] . [Host]
>>
File: succ.jpg (52 KB, 600x450) Image search: [Google]
succ.jpg
52 KB, 600x450
Why is C so inconsistent with char arrays?
[] and * are supposed to be interchangable, yet they act differently during initialization.

like for example
char *str = "1,2,3,4,5,6,6,6,6"; // read-only
char str[] = "1,2,3,4,5,6,6,6,6"; // read and write without segfault
char **strings = { "poop", "dicks", "ok", "sajdlkjsa" }; // invalid initializer
char *strings[] = { "poop, "dicks", "ok", sadjlksa" }; // ok
>>
>>55165843
they are interchangeable only in char arrays, because a char array has an end (=0). An array of strings, although technically a longer array of characters, has many zeros, but there is no value to signal the ultimate end of the array of arrays. Hence no implicit allocation.

I don't like the interchangeabilty of [] and * in chars, it creates the most stupid (and dangerous) errors.
>>
>>55164907
dude, here no one takes things seriously, all the bros from here just want to post their meme codes
>>
>>55165956
>because a char array has an end
>because a string has an end (=0)
fixed
>>
>>55165565
General gist as follows: disregarding the cache, when the CPU sends an address to 'memory', it is sending a virtual address. The virtual address space is usually much larger than the actual, physical address space (for many reasons, security/caching minimal program info in expensive mem. vs disk/shared libs/ect, this also has to do with paging). The MMU (memory managment unit) is the physical HW that does the translation from VA -> PA. The MMU does much more than that, including keeping track of timing and sending control signals to the various ranks of the DIMMs connected to your motherboard. This PA corresponds to a particular row/column(s) of a 'rank' on one of your installed DIMMs. It is much more complicated than this, but conceptually think of it like a hash function: VA -> PA -> Rank/Bank(smaller 'memory unit' than a row)/Row/Col. If you are interested at all in how the system really works, I would check out Memory Systems: Cache, DRAM, Disk.
>>
>>55165843
>[] and * are supposed to be interchangable, yet they act differently during initialization.
That's an incorrect assumption. They are NOT the same thing. It's just that arrays will decay into pointers when passed into functions.
>>
>>55165843
char **strings = { "poop", "dicks", "ok", "sajdlkjsa" }; // invalid initializer

That this doesn't work has nothing to do with chars. You're making a pointer to a pointer. One pointer. Not an array of them. That it works for a single char* is syntactical sugar.
>>
Idris > Haskell > OCaml > F# > everything else
>>
>>55166099
That is completely wrong.
>>
>>55166115
Okay, but do you dress like a girl?
>>
>>55166128
No, I dress like a guy, even though I have a vagina.
>>
>>55166120
And why would that be?
>>
>>55166120
He is correct.
>>
>>55166150
>>55166153
Actually looking back and re-reading his question, I think I misinterpreted it the first time.
>>
>>55165843
>[] and * are supposed to be interchangable,
only for function arguments.

char *str = "1,2,3,4,5,6,6,6,6"; // pointer to strings in readonly memory. should be const char*str;
char str[] = "1,2,3,4,5,6,6,6,6"; // string created on the stack. acts as a (char*const) pointer to said string
char **strings = { "poop", "dicks", "ok", "sajdlkjsa" }; // pointer to array of strings in read only memory. the array does not get created anywhere so this is invalid.
char *strings[] = { "poop, "dicks", "ok", sadjlksa" }; // array created on the stack of pointers to strings in readonly memory. should be const char*strings[];
>>
>>55166115
Ocaml has shit concurrency and still +. Shit
>>
>>55166170
>his question
his statement, I mean
>>
>>55166178
And F# is a toy language
>>
File: vktriangle001.png (5 KB, 804x625) Image search: [Google]
vktriangle001.png
5 KB, 804x625
It took me almost a week but I finally got a triangle in Vulkan

Yes, it passes validation

Yes, I do know OpenGL 3.x/4.x

Protip: vkBindBufferMemory is really useful if you don't want your program to crash
>>
File: 1436746717136.png (617 KB, 757x719) Image search: [Google]
1436746717136.png
617 KB, 757x719
Back when I was still in school, my C teacher gave me a lot of shit for using breaks and continues in my loops. I went on to use lesser languages for years and am now coming back to C because I need it for a small personal project.
You can't believe how angry I am right now.
>>
>>55166291
Show your teacher the Linux kernel, watch the cringe

It uses gotos

The best part is it's used to make the code cleaner
>>
>>55166310
Ah, the old C goto cleanup pattern.

Pisses me right off when people squeal and demand that lots of nested if-statements be used instead.
>>
File: 1465416304791.png (44 KB, 661x716) Image search: [Google]
1465416304791.png
44 KB, 661x716
important survey please do
http://www.strawpoll.me/10532101
>>
>>55166291

Breaks and continues aren't even gotos and they have no possibility to bring about spaghetti code. Use them as often as is reasonable.

Goto is fine in one or two scenarios, and I learned that the hard way using a language without goto to write a small kernel for a class. I kept thinking... you know, I keep doing a similar cleanup routine over and over in this function, and this would be much cleaner with a couple of labels. put into pseudocode, it was like this:

Obtain resource A
If (fuckup) { release resource A; return failure }
Obtain resource B
if (fuckup) { release resources B, A; return failure }
Obtain resource C
if (fuckup) { release resources C, B, A; return failure }
Do shit
Release resources C, B, A
return success


What I would have liked to do would look like this:

Obtain resource A
if (fuckup) goto ERR_A
Obtain resource B
if (fuckup) goto ERR_B
Obtain resource C
if (fuckup) goto ERR_C
Do shit
Release resources C, B, A
return success
ERR_C:
release resource C
ERR_B:
release resource B
ERR_A:
release resource A
return failure
>>
>>55166655
That's pretty much the one case where Linux uses gotos, so you're in good company.
>>

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {

if(jTable1.getSelectedRow() == -1 )
{
JOptionPane.showMessageDialog(this,"Veuillez selectionner une ligne","Erreur",1);
}
else
{
int nbH = Integer.parseInt(JOptionPane.showInputDialog(this, "Veuillez rentrer un nouveau nombre d'heures", "Modification heures", JOptionPane.OK_OPTION));
Planning plan = myModel.getMyList(jTable1.getSelectedRow());
boolean ok = daoPlan.updatePlanning(plan, nbH);
if(ok)
{
JOptionPane.showMessageDialog(this, "Modification du nobre d'heure confirmée", "Confirmation", JOptionPane.OK_OPTION);
myModel.fireTableDataChanged();
myModel.setMyList(daoPlan.selectPlanning());
this.jTable1.setModel(myModel);
}
else
{
JOptionPane.showMessageDialog(this, "Erreur", "Erreur", JOptionPane.OK_OPTION);
}


}



Anyone hase any idea why myModel won't update itself when this method (action event on a button) is launched ?
>>
>>55166655
>Breaks and continues aren't even gotos and they have no possibility to bring about spaghetti code. Use them as often as is reasonable.

You wouldn't believe how frequently people are told that break and continue are 'hacks' and should be avoided.
>>
>>55166969
1. Fix your indentation
2. Do you have a debugger?
3. Use it to check what updatePlanning is doing and if it returns correctly to bool ok
4. Don't use strings, create an object containing getters for these strings and call that instead. You'll need it when your program will need to support multiple languages. Your teacher is going to come buckets and you'll be the smart guy of the class.
5. nobre => nombre, heure => heures
>>
1) Do any of you folks use Lint (or lint like software) for your personal/work projects?

2) If yes, then do you use it because you are required to do so or because you prefer to use it?

I haven't used the c programming language since I was an undergrad. But I remember that the compiler would give you warning messages in addition to error messages. I don't remember actually calling/using lint at the time. So the warnings may have had nothing to do with lint.

I'm not a programmer. And I never plan on programming for work. But after reading a little bit about Lint on StackExchange, I'm tempted to give it a try for my person projects/school work. I feel like there would be work involved getting it setup to my liking.

It *seems* like it is a good tool to keep the code you write within the standards set by people who supposedly know better. I'm curious as to how useful you folks think it is.

Thanks.
>>
File: 1465054116766.png (2 MB, 1016x1222) Image search: [Google]
1465054116766.png
2 MB, 1016x1222
Anon suggested that if I was going to use WPF, I will need to dive into MVVM. I have read a couple of tutorials, and learned about the basic things (commands, view, templates, model, etc.) Anyone has more advanced resources to start off?
>>
>>55164409

As long as you only have one function named i, just use auto.
>>
>>55167115
>>55167115
I just got why it doesn't work. I have an error in my sql request.

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException

The thing is that this request is actually done in my database. When I check directly in it, the update is done.
What kind of error could make this shit happen ?

And when if I remove the model update lines to put them outside the if condition, it should still update my model. But it still doesn't...
>>
>>55167173
Aren't gcc warnings enough? I remember using pedantic, and a fuckton of other flags to make sure my code was in order.
Never used lint or valgrind since my C projects were very basic.
>>
>>55167216
>Aren't gcc warnings enough?
I wasn't clear at all in my post.

But I'm not currently using the c programming language. The overwhelming majority of my work is done in python3.

I mentioned c because it seemed like it performed the function of lint without actually calling it.

Sorry for the confusion.
>>
>>55167090

>break and contineu are 'hacks'
They are literally required for switch statements to not turn into complete shit...

Or do these retards not use switch statements?
>>
>>55167274
thats what if else blocks are for :^)
>>
>>55163989
best book(s) for learning OpenGL?
>>
>>55167290

But that's inefficient. It's much easier for a compiler to turn a switch statement into a jump table.
>>
>>55167274
If you want to piss them off, find an excuse to slip Duff's Device into your code:

    for(i = (len&7); i < len;) {
switch(i&7) {
case 0: dst[i] = src[i]; i++;
case 7: dst[i] = src[i]; i++;
case 6: dst[i] = src[i]; i++;
case 5: dst[i] = src[i]; i++;
case 4: dst[i] = src[i]; i++;
case 3: dst[i] = src[i]; i++;
case 2: dst[i] = src[i]; i++;
case 1: dst[i] = src[i]; i++;
}
}
>>
File: anita sharkeshian.jpg (463 KB, 1262x1760) Image search: [Google]
anita sharkeshian.jpg
463 KB, 1262x1760
haskell beginner here, I want to get all the files under a directory into a single list, here's what I got so far
(doesn't compile yet)
getfiles dir = do
items <- fmap (\\ [".",".."]) (getDirectoryContents dir)
files <- fmap (dir</>) (filterM doesFileExist items)
dirs <- fmap (dir</>) (filterM doesDirectoryExist items)
return $ files ++ foldl1 (++) (map getfiles dirs)

where a </> b = a ++ '/':b

the line with "return $ ..." is rougly what I want (yes I know monads are in the game, therefore it should be mapM or whatever)
how do I into this?
please halp veteran haskellers
>>
>>55167448
What's the error?
>>
File: 1464159508698.png (129 KB, 314x278) Image search: [Google]
1464159508698.png
129 KB, 314x278
I know that I'm probably just going to get memed on, but what's the best python library for making a game similar Fire Emblem? I was going to use Tkinter but holy fuck it seems impossible. I'm solid on every other aspect of game design though, and I'm willing to learn how to do GUIs but TK seems too low-level for what I'm trying to create.

And don't say RPG or Gamemaker, I've already considered them at great length but neither seem optimal for what I need to do.
>>
>>55167309
the loop goes inside the switch.
>>
>>55167532
pygame?
>>
>>55167532
Fire Emblem is kinda like a visual novel right? Maybe renpy in that case.
>>
>>55167294
You could try this: http://www.opengl-tutorial.org/

Although I tend to use linmath.h instead of glm, simply because linmath.h works on glorious C whereas glm requires scrub-tier C++: https://github.com/datenwolf/linmath.h

How to draw a triangle (untested, **assumes you have a shader set up already** w/ vertex input 0 bound to vertex data, and vertex input 1 bound to colour data):

// declaration
const GLfloat tri_mesh[3][6] = {
-0.5f, 0.5f, -1.0f, 1.0f, 0.0f, 0.0f,
0.5f, 0.5f, -1.0f, 0.0f, 1.0f, 0.0f,
0.0f,-0.5f, -1.0f, 0.0f, 0.0f, 1.0f,
};
GLuint tri_vbo;
GLuint tri_vao;

// setup
glGenVertexArrays(1, &tri_vao);
glBindVertexArray(tri_vao);
glGenBuffers(1, &tri_vbo);
glBindBuffer(GL_VERTEX_ARRAY, tri_vbo);
glBufferData(GL_VERTEX_ARRAY, sizeof(tri_mesh), tri_mesh, GL_STATIC_DRAW);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(tri_mesh[0]), &((GLfloat *)0)[0]);
glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, sizeof(tri_mesh[0]), &((GLfloat *)0)[3]);
glEnableVertexAttribArray(0);
glEnableVertexAttribArray(1);
glBindVertexArray(0);

// draw
glBindVertexArray(tri_vao);
glDrawArrays(GL_TRIANGLES, 0, sizeof(tri_mesh)/sizeof(tri_mesh[0]));
glBindVertexArray(0);


Shader setup requires you to pretty much do these calls:
GLuint prog = glCreateProgram();
GLuint shad_vert = glCreateShader(GL_VERTEX_SHADER);
GLuint shad_frag = glCreateShader(GL_FRAGMENT_SHADER);
glShaderSource(shad_vert, 1, &shad_vert_source_code_string, NULL);
glShaderSource(shad_frag, 1, &shad_frag_source_code_string, NULL);
glCompileShader(shad_vert);
glGetShaderInfoLog(shad_vert, ...);
glAttachShader(prog, shad_vert);
glCompileShader(shad_frag);
glGetShaderInfoLog(shad_frag, ...);
glAttachShader(prog, shad_frag);
glBindAttribLocation(prog, 0, "in_vertex");
glBindAttribLocation(prog, 1, "in_color");
glBindFragDataLocation(prog, 0, "out_color");
glLinkProgram(prog);
glGetProgramInfoLog(prog, ...);

glUseProgram(prog);
>>
>>55167563
I don;t know what it's cpabilities are yet or if it's good for turn-based stuff yet, but I was considering it. Really should check it out already.

>>55167586
It's a TRPG. My game doesn;t have much in the way of VN stuff anyway.


Essentially, all I really need is a better, easier way of doing graphics than TKinter. That's literally it, I can handle everything else.
>>
File: 91i328.jpg (142 KB, 740x740) Image search: [Google]
91i328.jpg
142 KB, 740x740
>>55167588
>>
>>55167510
the "return $ .." part
I just know it wouldn't compile, but I checked and it definitely doesn't compile
>>
>>55167629
If you've completely and utterly given up here's the GL 1.1 version:

// declaration
const GLfloat tri_mesh[3][6] = {
-0.5f, 0.5f, -1.0f, 1.0f, 0.0f, 0.0f,
0.5f, 0.5f, -1.0f, 0.0f, 1.0f, 0.0f,
0.0f,-0.5f, -1.0f, 0.0f, 0.0f, 1.0f,
};

// draw
glVertexPointer(3, GL_FLOAT, sizeof(tri_mesh[0]), tri_mesh[0][0]);
glColorPointer(3, GL_FLOAT, sizeof(tri_mesh[0]), tri_mesh[0][3]);
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_COLOR_ARRAY);
glDrawArray(GL_TRIANGLES, 0, sizeof(tri_mesh)/sizeof(tri_mesh[0]));
glDisableClientState(GL_COLOR_ARRAY);
glDisableClientState(GL_VERTEX_ARRAY);


Or the GL 1.0 version, but please don't get into the habit of doing this as it screws up your upgrade paths:
// draw
glBegin(GL_TRIANGLES);
glColor3f( 1.0f, 0.0f, 0.0f); glVertex3f(-0.5f, 0.5f, -1.0f);
glColor3f( 0.0f, 1.0f, 0.0f); glVertex3f( 0.5f, 0.5f, -1.0f);
glColor3f( 0.0f, 0.0f, 1.0f); glVertex3f( 0.0f,-0.5f, -1.0f);
glEnd();
>>
>>55167624
Use pygame

It's probably the easiest thing to use for it that isn't actually an engine

----

Elaborating on my post: >>55167732

The sizeof stuff might make it look a bit messier but it makes it much easier to add points

Also I fucked up the mesh declaration it should be this:
const GLfloat tri_mesh[3][6] = {
{-0.5f, 0.5f, -1.0f, 1.0f, 0.0f, 0.0f, },
{ 0.5f, 0.5f, -1.0f, 0.0f, 1.0f, 0.0f, },
{ 0.0f,-0.5f, -1.0f, 0.0f, 0.0f, 1.0f, },
};
>>
>>55167696
What's the error?
>>
File: Capture.png (53 KB, 827x368) Image search: [Google]
Capture.png
53 KB, 827x368
could anyone tell me what this means? is the open diamond the same as the open diamond with solid arrowhead? if so does that just mean that abstraction makes a reference to implementor?
>>
>>55167798
yes
>>
>>55167798
I think the arrow is there just to remind you that the diamond is on the opposite side of what you expect, kinda like everything else to do with the shittiness that is UML
>>
File: monad diagram.png (26 KB, 334x358) Image search: [Google]
monad diagram.png
26 KB, 334x358
>>
>>55167950
arrows are functions
m a is like m<a>
m m a is like m<m<a>>
>>
>>55167758
right here
>>
>>55168091
I didn't ask where the error was, I asked what it was
>>
>>55166223
toy? It is used a lot and is on the .NET platform

ocaml still doesn't have a unsigned integer type
>>
In Java, how can I make my code still run after a NullPointerException ?

This error occur but what I want to do is still done so Ill just ignore it and make the rest of my code run. How do I that ?
>>
>>55168102
the error is the that the types don't match up, and the code doesn't do what is desired
>>
>>55168122
thank you for your detailed description
>>
>>55168119
Handle the exception?
>>
>>55168119
try/catch NullPointerException on a case-by-case basis

Alternatively, learn to code properly and actually check if something is null

If it's a problem in another lib though, try/catch should cover it... but that IS pretty dangerous
>>
>>55168128
why do you need the exact error?
all you need to know is it doesn't compile.
the description of what is desired should be enough for someone to help
>>
>>55165843
>[] and * are supposed to be interchangable
They are not.

One denotes an array, the other a pointer.

>>55166174
Not even for function arguments.
>>
>>55168188
Just post the fucking error you dumbass
>>
>>55168195
Arrays are pointers.
>>
>>55168202
That's incorrect

int main()
{
int array[4]; // <-- allocates four ints
int* pointer; // <-- allocates only an int pointer

int array2[4];
array2 = array; // <-- invalid C

pointer = array; // <-- valid C
pointer = array + 2; // <--- valid C
}
>>
>>55168225
Then why does this work?

void a(int *p)
{
}

int main(int c, const char **v)
{
int test[4];
a(test);
return 0;
}
>>
>>55168199
like I said in the original post, "the "return $ ..." is roughly want I want
aka, that line isn't part of the code, its what I roughly want, described in haskell code
I know it doesn't compile, but I included it there to let the readers know is what I want
>>
>>55168247
Because you're passing the address of the array (aka pointer), not the array itself.
>>
>>55168225
> array2 = array; // <-- invalid C
No, it's perfectly valid.
array is a pointer of type int * and so is array2.
You're assigning array2 to array.
>>
>>55168257
>array is a pointer of type int * and so is array2.
No, they're not and no it's not valid C.

Try it in your compiler if you don't believe me.
>>
>>55168248
take a picture of what GHC gives you when you try to compile it and post it, obviously censoring anything private

nobody is going to mess around running your code for you just to get the error message
>>
>>55168297
like I said, there's no point, but here it is, because you're so stubborn
10 bucks it won't help at all
>>
>>55168255
But wouldn't that be &test then?
>>
is it a good idea to include libraries without their own namespace into a custom namespace with a header file that looks like this?

#ifndef USER_NCURSES_H
#define USER_NCURSES_H


namespace nc
{
#include <ncurses.h>
}

#endif
>>
>>55168338
Not for array-types (or function types), no.

a(test);
is equivalent to
a(&test[0]);
>>
>>55168374
No, because C has no concept of namespaces.
>>
>>55168391
I am talking about C++ you dummy
>>
File: 1417722010147.png (25 KB, 465x354) Image search: [Google]
1417722010147.png
25 KB, 465x354
I'm looking for a script that keeps track of when a website updates or when a forum gets a new post.

Does anyone know of a script like this or if i was to write one what method i would use.

The method i was thinking of was to download the page html, look through the code and if x != y i would return true. But this feels like overdoing it to me.
>>
>>55168329
It seems like you're treating FilePath s like [Char]s and vice versa

For instance, to use \\ on a filepath requires either side be a filepath, but you're using strings and filepaths
>>
>>55168401
ncurses.h is a C library, which is why you're going to have a bad time when you try to link afterwards.
>>
>>55168416
Or rather, either side be a [FilePath]
>>
>>55168403
It's called RSS and your post is an old /g/ meme btw.
>>
>>55168416
just tell me you're a troll pls
>>
>>55168445
>trying to use FilePath, String and [Char] interchangeably
You're obviously new to the concept of strong typing
>>
>>55168445
>FilePath = string
Prelude is retarded
>>
>>55168375
Does it have any specific name? This kind of behavior that is.
>>
>>55168464
>type A = B means A is interchangeable with B
>type String = [Char]
>type FilePath = String
pls, just say you were meming so I can move on
>>
File: 1327384327321.jpg (13 KB, 300x300) Image search: [Google]
1327384327321.jpg
13 KB, 300x300
>>55164830
>What's better, python or ruby?
>>
>>55168480
I'm not >>55168464
I'm surprised Prelude defines a filepath as a string, that's fucking retarded and Haskell is the last community I'd expect that from
>>
>>55168225
char[] arr
is pretty much
char * const ptr
>>
>>55168474
Maybe, but not that I'm aware of.

If it has a name, it is defined here:
http://www.open-std.org/JTC1/sc22/wg14/www/docs/n1256.pdf
>>
>>55164816
Then use an enum.
>>
I'm about to start a Java to course. Is likely my 1st "serious" contact with coding. Did I fuck up?
>>
>>55168403
while (1)
{
static char *last_time = NULL;
char *current_site = get_from_curl(); /* or something */
if (!strcmp(current_site, last_time))
printf("HEY IDIOT");
else
{
free(last_time);
last_time = current_site;
}
}
>>
>>55168502
but filepaths are strings, think about it
>>
>>55168535
File paths are not strings. There are characters that are allowed in strings that are not allowed in file paths.
>>
>>55168535
1) they shouldn't be
2) if you did go for that representation, wouldn't [String] be better?

>>55168480
Also instead of foldl1 (++)
You could use concat
And instead of
concat (mapM ...)
you might be able to use some kind of bind with return
(I don't use mapM so I wouldn't know)
>>
>>55168374
>>55168417

Okay, I had to look up the behavior for this. This should work, because extern "C" tells the linker to turn off all name mangling. Trying it out with a simple test function shows that C++ will basically ignore the function outright. So putting a C header inside of a namespace like that IS safe.

What it isn't, is standard. Why? Because if you have two functions like so:

namespace A {
extern "C" void foo(int);
}

namespace B {
extern "C" void foo(double);
}


The namespaces will not help you. As far as the linker is concerned, it is looking for a function whose name in the object symbol table is foo, and not something like _ZN1A3fooEi

Aside from forcing type definitions into the namespace, any perceived ability to avoid name collisions among functions is absolute placebo.
>>
Is there a way to not bring a DB search into memory with python/sqlite3? Or, to maybe only pull a few at a time and write them somewhere?
The entire point was not to, but now every search takes longer than searching the regular file...
I need to search a HUGE db... it eventually writes it to pagefile and slows everything painfully
>>
>>55168531
Why all the effort with setting up cURL and shit when you can use Python...

import requests
from time import sleep

last = None
while True:
req = requests.get('url')
if req.status_code = 200:
data = req.text
if data != last:
print('Site changed.')

last = data

sleep(1)
>>
>>55168547
yes, filepaths are a subset of strings, its ok for them to be strings
>>55168548
why would [String] be better?
that makes no sense
unless you mean Filepath(s), of course, Filepaths are [String]

so can anybody help
>>
>>55168650
>yes, filepaths are a subset of strings, its ok for them to be strings
That's like saying it's okay for ints to be treated like doubles because both are numbers.
>>
>>55168650
a\b\c
[a,b,c]
>>
>>55168650
WHY WOULD YOU EVEN USE A FILEPATH TYPE WHEN YOU TRY TO USE IT AS A STRING ANYWAY

JUST USE A STRING YOU AUTIST

REEEEEEEEEEEEEEEEEEEEEE
>>
>>55168639
curl is stupid easy to setup.
>>
>>55168674
>WHY WOULD YOU EVEN USE A STRING TYPE WHEN YOU TRY TO USE IT AS A CHAR * ANYWAY
>
>JUST USE A CHAR * YOU AUTIST
>
>REEEEEEEEEEEEEEEEEEEEEE
>>
How do I prevent this from opening the console in firefox and a few other applications?

https://ghostbin.com/paste/aujvf
>>
>>55168629

Why are you using SQLite if you did not want to have an in-memory database?
>>
>>55168663
nope, you're saying that doubles should be in their own and not be considered numbers

doubles and ints don't overlap, they're not supersets or subets of another, they belong to the same set, so it doesn't make sense to do that
im arguing that its ok for doubles to be real numbers, because they're a subset of real numbers

>>55168674
because its defined that way u dumb fuck
also easier to read because it tells what the string is supposed to represent
>>
>>55168693
Your program doesn't even compile, and you're ranting about it on /g/ about how your program SHOULD compile

You're a fucking autist.
>>
>>55168723
See >>55168725

Your bitching on /g/ isn't going to make your program compile.
>>
>>55168725
im not him, but you don't even undestand what help I'm trying to get
you assume I already have a solution and that the errors are syntax errors
I don't have a solution, thats what I'm asking for
>>55168740
>bitching
you syaing that dogs are cats and me pointing out its not is not "bitching'
>>
>>55168639
this is great, ty
>>
What sorting algorithms are there that are really fast and only get you to a nearly sorted state? I have maybe 100000 elements to sort but it doesn't matter if it's perfectly sorted or not.

Are all the best sorting algorithms targeting a perfectly sorted state?
>>
>>55168713
I'm new to DBs, I want to be able to /quickly/ search the database, I write to the DB like this so it doesn't kill my computer as I do not have much ram:
            c.execute("insert into IP2ID (IP, USERNAME, EMAIL, NAME, PASS) values (?, ?, ?, ?, ?)",
(IP, USERNAME, EMAIL, NAME, PASS))
if count == 100:
conn.commit()
count = 0
print("100 more Saved, senpai! :3 --", line, "ND lines:", c2)


conn.commit()#save sql file
conn.close()#close sql file

Is there something similar I can do while reading the DB and searching for something?
I'm completely new to databases. Am I asking the right thing? When I try, it pulls it all out and fills my tiny amount of RAM...
>db is 50+GB
>>
>>55168777
Yes, most sorting algorithms do a total sort
>>
>>55168707
Yes, I know shell is in a few different places for no reason. plz no bully
a work in progress
>>
File: 1000%Bothered.gif (982 KB, 320x287) Image search: [Google]
1000%Bothered.gif
982 KB, 320x287
>>55168777
Why wouldn't you need it to be sorted all the way?
And All sorting algorithms sort all the way.
>>
>>55168528
>coding
Yeah. You'll learn to code but the real question is: will this course teach me programming? Probably not. But you never know.
>>
>>55168528
>Java
May God have mercy on your soul
>>
>>55168725
can you point out where I was bitching and saying my program should compile?
>>
>>55168754
>you assume I already have a solution and that the errors are syntax errors I don't have a solution, thats what I'm asking for
The fucking error is right there in the compiler output....

>you syaing that dogs are cats and me pointing out its not is not "bitching'
It doesn't compile FFS

How much more evidence do you fucking need?
>>
This general is the epitome of shit code from any website. I can imagine how most of you look in real life (fat lonely NEET fucks who bullshit about programming languages they know nothing about). Some cunt was arguing in a thread that malloc can't fail and that using a ternary operator for assignment is "confusing" to his little retarded brain. I fucking hate this board.
>>
>>55168779

While 50 GB is not even close to the physical limit of data SQLite can handle, I am not sure if your use case with 50 GB is necessarily a good application of SQLite.

https://www.sqlite.org/whentouse.html
>>
>>55168831
>"I was told I was wrong on the daily programming thread so fuck you all"
>>
File: anime.png (201 KB, 335x365) Image search: [Google]
anime.png
201 KB, 335x365
>>55168831
>thinking of 4chan as just a website
You've got to go back
>>
>>55168825
like I said for the third time, the line that gives me trouble is there to poinpoint what I'm trying to get
its not meant to be compiled, (I wrote it knowingly that it won't compile)
the reason I came here is to see if someone more knowleadgeable than me, would help me by writing a line that did what I described and actually compiled
is it hard to understand?
>>
>>55168844
The problem was that I wasn't wrong, malloc can fail on certain machines, and there is nothing wrong with using a ternary operator for assignment (it's quite short and understandable really).

Here's the example this cunt complained about:
argv[0] = argv[0][0] == '\0' ? PROG : argv[0];

>>55168849
How big is your cartoon porn directory?
>>
>>55168859
>I wrote something that didn't compile and I want 4chan to program Haskell for me
You're a tool
>>
>>55168831
you can always go back to plebbit
>>
>>55168872
>argv[0] = argv[0][0] == '\0' ? PROG : argv[0];
Why would you do this?

Do you use a file system that allow filenames with 0 length?
>>
>>55168878
its hard senpai, can you you help or not?
>>
>>55168889
Some people might, and I'm just trying to keep my code portable.
>>
>>55168831
>Some cunt was arguing in a thread that malloc can't fail and that using a ternary operator for assignment is "confusing" to his little retarded brain.
>I hate this
I don't blame you. I've made erroneous pretend-to-be-ignorant posts here and people don't even answer. I've made posts about floating point precision errors and didn't get any answers after 3 bumps, assignments in if statements, misunderstood OOP completely (doing things like switchcase+casting for polymorphism while complaining about OOP).

And people here just can't answer. I don't believe you're intentionally mean, all the posts were carefully crafted to seem like I'm an inexperienced but enthusiastic rookie. And you answer whatever shit is possible.

All you bitch about is syntax. Some moron even thought that it'd be illegal to write
extern "c"

in C. Simply because he had never seen a compiler written with a language specification for lowercase C. Bitched about it being invalid C for over an hour.
>>
>>55168897
You're not writing portable code, you're writing code in case someone uses a non-standard complying compiler, which is retarded.
>>
>>55168872
>malloc can fail on certain machines
Malloc can fail on all machines. Malloc can always fail. You can have calls to OS specific allocation functions that fail.
Thread replies: 255
Thread images: 33

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

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.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.