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

/dpt/ - Daily Programming Thread

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 331
Thread images: 38

File: daily programming thread2.webm (2MB, 600x338px) Image search: [Google]
daily programming thread2.webm
2MB, 600x338px
old thread: >>56432690

What are you working on, /g/?
>>
First for D
>>
>>56440203
>What are you working on, /g/?
Reading K&R. Just started 1.6 Arrays
>>
>>56440203
First for D
>>
why is this printing out 5?

s = 'azcbobobegghakl'
num = 0
for i in s:
if i in 'bob':
num+=1

print ('Number of times bob occurs is:' + str(num))


Theres nothing in there that would even suggest 5 that i can see?
>>
>>56440203
filter (`elem` ['A'..'Z']) "i lauGh At You BecAuse u r aLL the Same"  
>>
>>56440203
CodeEval challenge: String List
>>
>>56440214
Should I drop the beginner book to C now and start on K&R the only things left talk about creating functions which I have a good knowlege about.
>>
>>56440240
>if i in 'bob'
>if i is 'b' or i is 'o'
>>
>>56440262
K&R is outdated
C Primer Plus
C Programming: A Modern Approach
>>
>>56440240
bob is an array of two b's and one o.
>>
>>56440281
>C Programming: A Modern Approach
that's an oxymoron though.
>>
>>56440262
yes. books are for nerds
just code, man
>>
File: proj.trace_call_4657-1_2.png (3KB, 800x600px) Image search: [Google]
proj.trace_call_4657-1_2.png
3KB, 800x600px
Can someone here assist me with OpenGL? My program generates absolutely no errors but there's no output.
I'll save you from reading the source code as I'm just looking for advice

I've checked the vertex data and the data on the buffer at the time of glDrawArray, and that's OK; the vertex data is perfectly what I intended it to be.

I used GLM to create a projection matrix and applied the transformation in my vertex shader.

I've checked that the VAO and VBOs are generated, they are. They're also bound before glBufferData or glDrawArray.

I've checked the size of glDrawArray and it's perfect.

I've checked that textures work. They do. A debugging program tells me that GL_TEXTURE0 has the image loaded into it, anyway. No other texture units in use

I don't think my camera is inside the geometry- I've checked the depth buffer.

I honestly don't know what else to check. any suggestions?

Attached is an image of the depth buffer, with no alpha. With alpha it's all white.
>>
File: 1461880979099.png (315KB, 559x519px) Image search: [Google]
1461880979099.png
315KB, 559x519px
>>56440203
>when you discover abstraction
How long did it take for programming to click with you?>>56440211
>>
File: 1451346722581.png (39KB, 888x174px) Image search: [Google]
1451346722581.png
39KB, 888x174px
Go home GCC, you're drunk.
>>
|n| (2..n).take_while(|d| d * d < n).all(|d| n%d > 0)
>>
>>56440203
>What are you working on, /g/?
Django
>>
>>56440710
>C++

Not even once
>>
>>56440710
V E X I N G
E
X
I
N
G
>>
>>56440580
There's a lot of reasons this could be failing. Were you able to successfully draw a triangle with no texture? No depth test? No vertex transformation? No shader at all?
>>
File: t.jpg (43KB, 526x421px) Image search: [Google]
t.jpg
43KB, 526x421px
When I run Python through notepad++ it won't do stuff like download images or show errors.

What gives, lads?

I don't want to use a shitty IDE.
>>
>>56440751
I don't understand what's ambiguous about it.
It is quite clearly a function declaration, I'm not seeing any syntax or semantic errors anywhere.
I don't understand why g++ is complaining.
>>
>>56440795
>notepad++
>>
>>56440710
Do you have a variable called "time" anywhere?
>>
File: gorilla.jpg (9KB, 197x256px) Image search: [Google]
gorilla.jpg
9KB, 197x256px
>>56440203

how can people watch this mlp tier shit
>>
>>56440839
same reason people like you get robbed and shot up.

cuz you're a punk ass bitch.
>>
>>56440710
you forgot closing } in previous function

it thinks you're trying to create a static bool variable with the parameters
>>
>>56440833
No, I have a class called time though.
Clang came to the rescue and showed my error. it seems the time function from time.h was causing the problem, why the fuck would it though? time from time.h is a function, while my time class is a class, how is that ambiguous?
>>
File: gorilla2.jpg (31KB, 197x256px) Image search: [Google]
gorilla2.jpg
31KB, 197x256px
>>56440867

I doubt you even go outside
>>
>>56440886
And this is why namespaces exist.
>>
File: 1469780251479.png (30KB, 401x366px) Image search: [Google]
1469780251479.png
30KB, 401x366px
>>56440876
Nope.

>>56440904
>C++ is so dumb it can't differentiate between a function name and a type name.
>>
>>56440886
>>56440904
Oh, and it thinks it's ambiguous because it's seeing "time" as a value, parsing (time & t) as an application of the binary & operator, and parsing the whole thing as an initialization.
>>
>>56440795

Use cmd.
>>
>>56440925
It's still the reason you use a namespace. #include <ctime> instead of <time.h>.
>>
>>56440203
My reddit interjector bot fucked up and replied to everything containing arch including the word "search"....
>>
>>56440795
Use Sublime Text 3, and run your scripts through your command prompt/shell
>>
>>56440898
and i bet you haven't seen the outside of your mothers ass since you're just constantly turtling like the little shit you are.
>>
>>56440925
Then don't use C++ if it's not suited for you?
>>
>>56440994
Did you get banned yet?
>>
I was instructed to come and ask here : I want to make a program for Windows, with which I'll be able to command my PC with gestures (Kinect). It's for educational purposes and my own satisfaction. I would be really grateful, if anybody could provide any quality tips, materials, code help and this kind of stuff (beginner level programist). Even smallest things will be good.
>>
What's the No Man's Sky of programming?
>>
>>56441005

better watch some barney to calm down
>>
>>56441072
rand();
>>
>>56440952
That didn't solve the problem.
I don't think c<lib> is guaranteed to not put them in the global namespace anyway.
>>
>>56441062

learn python, figure it out from there
>>
>>56441088
Ah, that's true, but it's still good practice. Using the new function signature syntax could remove the ambiguity:
static auto parse_time(time &t, std::string &m) -> bool
>>
>>56441072
Something that was a huge disappointment built on a web of lies and broken promises?

Go
>>
>>56441128
Putting my whole program into a namespace seems to have solved the problem.
>>
Learning Rust by making an RSS downloader.
I'm currently stuck with this:
use std::fs::File;
use std::io::Read;

extern crate serde_json;

static PATH: &'static str = "~/Projects/rss/config.json";

#[derive(Deserialise)]
pub struct Config {
urls: Vec<String>
}

impl Config {
pub fn read() -> Result<Config, String> {
let mut file = try!(File::open(PATH).map_err(|e| e.to_string()));
let mut content = Vec::new();
try!(file.read_to_end(&mut content).map_err(|e| e.to_string()));
let config : Config = try!(serde_json::from_slice(&content)
.map_err(|e| e.to_string()));
Ok(config)
}
}

error[E0277]: the trait bound `config::Config: serde::de::Deserialize` is not satisfied
--> src/config.rs:18:36
|
18 | let config : Config = try!(serde_json::from_slice(&content)
| ^^^^^^^^^^^^^^^^^^^^^^ trait `config::Config: serde::de::Deserialize` not satisfied
|
= note: required by `config::serde_json::from_slice`

error: aborting due to previous error

error: Could not compile `rss`.
>>
>>56441042
hell ye
>>
>>56441306
>Deserialise
>>
>>56441340
Well, fuck...
Apparently that's the issue.
>>
>>56441368
Unfortunately you have to get used to the standard being American English in programming.
>>
>>56441306
You need a specific #feature to automatically derive Deserialize from serde iirc (you could use rustc-serialize instead and #[derive(RustcDecodable)]).
>>
>>56441415
I'm using Rust nightly and I've added this to main.rs:
#![feature(plugin, custom_derive)]
#![plugin(serde_macros)]

So far, I'm pretty happy with Rust. I wonder if I can do something about those map_err() though.
>>
>>56441490
Maybe use your own Errortype? What you want is pretty much described in the book:
https://doc.rust-lang.org/book/error-handling.html#the-real-try-macro
https://doc.rust-lang.org/book/error-handling.html#composing-custom-error-types
>>
>>56441490
>>56441583

Alternatively use
Box<Error>
instead of String, removes the need for .map_err()
>>
>>56441637
Thanks anons. This is what I currently have:
use std::fs::File;
use std::io::Read;
use std::error::Error;

extern crate serde_json;

static PATH: &'static str = "/home/bas/Projects/rss/config.json";

#[derive(Deserialize, Debug)]
pub struct Config {
urls: Vec<String>
}

impl Config {
pub fn read() -> Result<Config, Box<Error>> {
let mut file = try!(File::open(PATH));
let mut content = Vec::new();
try!(file.read_to_end(&mut content));
let config = try!(serde_json::from_slice(&content));
Ok(config)
}
}

It looks pretty clean to me. >>56441583 requires me to write boilerplate, so I prefer the
Box<Error>
method. However, is it best practice to use Box like that?
>>
> a human can't beat a compiler because ITS 2016
>>
>>56441710
It is at least preferable to String because:

1: The Error trait provides a description() method returning a &str, removes the need to convert to String in the first place.

2: Unlike String, provide a cause() method, returning the lower-level Error if it exists, thus providing more information.

From https://doc.rust-lang.org/std/error/

I'd really recommend reading the chapter on Error handling in the book, as it explains idiomatic error handling really well.

Tl:dr: If you don't want to write your own Errortype, use Box<Error> instead
>>
Is learning to use GitHub hard?
>>
I'm feeling lost /g/, I'm currently working in .Net but while I enjoy both F# and C# I'm getting tired of the rituals of having project files and solutions. I've been looking around but while other languages have better ideas and executions there is nothing that feels great. Always something that nags in my head. In rust it's the method chains needed to make anything useful but ends up reading like crap. In go it's the type system. OCaml I haven't tried because the tooling on Windows is crap. Haskell has its love for operators and also the wall you need to climb before you can start being proficient. I just want a general language that I can use and make tools for me in. But instead I waste time jumping around. Ugh.
>>
>>56441835
>If you're writing a quick 'n' dirty program and feel ashamed about panicking anyway, then use either a String or a Box<Error> for your error type.
That will work just fine for my application.
I did finish reading the Rust documentation a few weeks ago. This is my first time writing Rust instead of looking at examples.
>>
>>56441945
Learn git instead,
>>
>>56441978
learn Haskell, it's not as bad as it looks

make sure you're using an editor that will show you errors as you type though
>>
>>56440364
But what :/
>>
>>56441945
Git is such an incredible tool. It's a little weird when you first start using it, but as soon as you get a good workflow going it's hard to go back
>>
>>56442023
and that's why i do security
>>
How do i get addicted to this and stop gayming?
>>
>>56442063
Install Gentoo
>>
>>56442063
Grow up
>>
how do i create a killer app so i dont have to get a job?
>>
>>56442005
Right now the Haskell community is going through some civil war shit with stack and haskell-lang and from the outside it looks pretty childish. Not sure what to think about that.
>>
>>56442077
love this meme
>>
>>56442157
>civil war
Explain
>>
How bad is it that I never use virtualenvs for my Python projects?
>>
>>56442147
go to http://tiffzhang.com/startup/

Whatever it gives you you slap it together in 2 days or so using node.js, Rust or Go, then get a .io address and start shilling on HN and Reddit
>>
>>56442191
Guy who created Stack (a build tool for Haskell) claims the Haskell devs are trying to shut him out by not shilling his program on their website

He did make some valid points but at the end of the day it's clear his real goal is to become "the Haskell guy"
>>
>>56442191
Like I said this is from my outside perspective but the people behind fp complete, the makers of stack, aren't happy with how Haskell.org is run and have registered their own domain (haskell-lang.org) which they are promoting over the official site. They also prohibited Haskell.org from using the design that had been donated, because the guy who made it is with fp complete. Then there's been some weird blog posts from another fp complete employee where the tone is more fitting of a school yard than a debate about how things should be run.

But this is just what I've gathered from what I've read. Might have misunderstood things, but this is how I'm seeing it and it makes me wonder if I should learn it or wait.
>>
>>56440240
oh my god

/g/ in a nutshell
>>
>>56441810
Humans and compilers are both good at different kinds of optimization.
>>
>>56442374
>>56442380

Oh wow. Thanks for the info.
>>
>>56442157
I have no idea about what this is
>>
so we can agree only traps and muhe.peen faggots code in hasklel?
>>
>>56442077
Explain how with an algorithm
>>
>>56442374
>>56442380
Wew, seems pretty retarded.
>>
>>56442502
for (;;);
>>
>>56440203
>you will never be forced by your cute girl classmates to dress as a girl
;_;
>>
>>56440203
What tags do I use to put source code in boxes?
>>
>>56442624
<code>
stuff
</code>

with [square] brackets
>>
>>56440203
Wth are you defragging an SSD?
>>
class foo
{
public:
int a;
};

class bar : public foo
{
public:
int b;
};

int main()
{
foo *f = new bar;
delete f; // new-delete-type-mismatch from ASAN

return 0;
}


Apparently this is undefined behavior in C++.
How the fuck am I supposed to do polymorphism with this shit?
>>
import Control.Monad
import System.Environment

alphatri' c = let xs = ['a'..c] in xs ++ (reverse . init) xs

alphatriList c = map alphatri' ['a'..c]

indent 0 = []
indent n = [replicate (n-1) ' '] ++ indent (n-1)

indentList c = indent $ length ['a'..c]

alphatri = zipWith (++)

main = do
args <- getArgs
let c = ((head args) !! 0)
mapM_ putStrLn $ alphatri (indentList c) (alphatriList c)


Can you show me to abstract this even further, /g/?
>>
>>56442676
virtual destructor
>>
why are name examples in code always foo bar?

what do they mean?
>>
>>56442676

You need to indent your public, private, etc declarations.
>>
>>56442691
Yeah I'm retarded, I just figured that out.

>>56442702
No I don't, why do I?
>>
>>56442690
what are you trying to achieve?
>>
chaotic map rendering program now on github if anyone wants to tinker with it or contribute code
>>
>>56442696
Because we aren't good at coming up with names.
>>
File: Attractor 2016-09-01 22-36-58-73.png (948KB, 1920x1080px) Image search: [Google]
Attractor 2016-09-01 22-36-58-73.png
948KB, 1920x1080px
forgot link

https://github.com/chris-liu/Attractor
>>
How pleb this code is to cut a text to a given width? (Yes this is a idea taken form r/dailyprogramming)

 import sys

def where_to_cut(text, width):
main_list = []
counter, i = 0, 0

while i < len(text):
if counter == width:
if text[i] == ' ' or text[i] == '\n':
main_list.append(i)
counter = 0
continue
else:
while (text[i] != ' ' and text[i] != '\n'):
i -= 1
main_list.append(i)
counter = 0
continue
i +=1
counter += 1
return main_list

def cutLines(s,width):
points = [0] + where_to_cut(s ,width)
lines = []
for i in range(len(points)):
try:
lines.append(s[points[i]:points[i+1]])
except:
pass
lines.append(s[points[-1]:])

for i,line in enumerate(lines):
if line.endswith('\n'):
lines[i] = line.replace('\n', ' ').strip()
lines[i] = lines[i] + '\n'
else:
lines[i] = line.replace('\n', ' ').strip()
return lines

text = open(sys.argv[1]).read()
print '\n'.join(cutLines(text, 40))
>>
>>56442787
>>56442826
you really need to change that god-awful debug font m8
>>
>>56442849
You're embarassing him anon
He thought it was a cool font
>>
>>56442390

its first weeks challenge at MIT
>>
>>56442828
Aren't you just reinventing the wheel, Python has list slicing
>>
>>56442828
what exactly is this supposed to do? ran it and it just seems to be stuck in an infinite loop, or it's just really really slow
>>
>>56442883
Second version:
 import sys

def cut_lines(s, width):
s = s.replace('\n', ' ')
words = s.split(' ')
lines = []
nline = ""

for word in words:
if len(nline) == width:
lines.append(nline.strip())
nline = "%s "%word
continue
if len(nline) + len(word) > width:
lines.append(nline.strip())
nline = '%s '%word
continue
nline += '%s '%word
lines.append(nline)

return lines

text = open(sys.argv[1]).read()
ntext = cut_lines(text,40)

print '\n'.join(ntext)
>>
>>56442902
https://www.reddit.com/r/dailyprogrammer/comments/4ybbcz/20160818_challenge_279_intermediate_text_reflow/
>>
>>
>>
Suggestions on in-depth git/github learning tools? I can use it well enough but I want to have a better understanding of it all. I don't want to just be of of those people who just does the commands they memorized and then asks for help or googles anything something is weird.
>>
>>
File: I AM HELPING.png (40KB, 1095x531px) Image search: [Google]
I AM HELPING.png
40KB, 1095x531px
What are peoples opinions on helping others on websites like stack overflow? I get 20 minutes worth of break (outside my hour lunch) and decided to take to the site to see what I can do.

Also it is late but I am going to start looking into meteor and react.
>>
Added a few issues if anyone's bored or wants something to program.

1. calculation of lyapunov exponent
2. gradient descent optimisation of lyapunov exponent to find local maximums
>>
>>56443040
sure why not
just avoid "stats" like the plague
>>
D is pretty underrated, really enjoying my time so far.
>>
>>56443153
D is seriously overrated in the big scheme of things, but compared to most common languages it is significantly better
>>
haskell is great lang
post cool haskell programs
>>
I'm working on your mum
>>
>>56443153
Why should I learn D?
>>
>>56443197
>D is seriously overrated in the big scheme of things
How so?
Not too far into the book, but it really seems to be a realistic c++ successor.
>>
>>56443236
import std.stdio;

void main()
{
int[10] first = 1;
int[10] second = 2;
int[] result;

result = first ~ second;
writeln(result.length); // prints 20
result ~= first;
writeln(result.length); // prints 30
}


now imagine doing the same in c++
>>
>>56443237
Seriously limited in expressive power
>>
>>56443217
I tried to write some haskell shit but it seems that for each type you have a function. Jesus Christ I got mad trying to convert dat <- getArgs to a Int.
I don't know if I got it right but I had to do:

whatever x :: Int
whatever x = read x
and then I said fuck this shit.
>>
Are code bootcamps worth it ?

It would pay for itself, even with a code monkey position.
>>
>>56443268
Because it has an operator for array concatenation?
>>
>>56443283
What are you actually trying to do?
>>
File: 1462144628852.gif (1MB, 305x280px) Image search: [Google]
1462144628852.gif
1MB, 305x280px
>>56443268
Wow, that's some nice real world usage right there
>>
Is geany the best IDE for c++?

also whoever warned me: kill yourself
>>
>>56443303
just one example.
>>56443318
what's one you'd prefer?
>>
>>56443332
Visual Studio is.
>>
>>56443332
>also whoever warned me: kill yourself
I hope you're talking about someone who warned you about how bad C++ is
>>
>>56443283
Often, you don't have to manually specify the type. It can be inferred at the usage site.
>>
>>56443332
Code Blocks
>>
>>56443306
I'm not a smart man

import System.Environment
--took it from somewhere else
primes = sieve [2..] where sieve (p:xs) = p : sieve [x|x<-xs, x `mod`p/=0]

toInt :: String -> Int
toInt x = read x

main = do
fstArg:args <- getArgs
putStrLn $ show $ take (toInt fstArg) primes
>>
Is Vim the best IDE for C#?

No memes.
>>
>>56443389
Visual Studio is.
>>
File: bill gates.gif (643KB, 1500x2100px) Image search: [Google]
bill gates.gif
643KB, 1500x2100px
>>56443407
>>
>>56443378
Try reading the error message.
>>
>>56443420
I really like this meme
>>
>>56443378
since toInt is literally a redefinition of read with a type signature, toInt is exactly equivalent to

(read :: String -> Int)

Since read is:
(Read a) => String -> a
And there exists an instance Read Int
String -> Int
is a subset of the type of read

So you can force it to be this subset, and then there are no issues.

Though in this case, that really shouldn't be an issue anyway. Take's second parameter is an int, so the compiler should know this anyway (and annotating should be redundant)
Are you using GHC?
>>
>>56443456
Yes, it worked but I meant that it was so hard to find this out that I was burned out after all this.

I tried using digitToInt from Datar.Char but it only worked from 0 to 9

What I meant was that: If something this simple is this hard imagine more complex stuff. I'm too dumb for Haskell lmao.
>>
>>56442949
Why not?

It's version control not rocket science
>>
>>56440580
Check if your shaders compiled successfully.
Are you making proper use of glGetError, try checking/flushing the error queue after every single gl* call.
>>
>>56441978
just use a Linux VM m8
>>56443506
the learning curve is pretty sharp with Haskell, but after a while it gets really easy to solve hard problems. in fact, I've heard Haskell described as "a language that makes hard problems simple, and easy problems difficult"
>>
>>56443506
I don't see what the problem is in the first place.
Why did you need to do "toInt" rather than just read?
GHC's typechecker can infer that

It's not really that complicated
read :: (Read a) => String -> a
Can be read as
read :: String -> (any) Readable a

So when you call [read "1234"], the result is literally any readable value.
As soon as the type checker knows which specific readable type you want, it will instantiate it all.

So you could say
x :: (Read a) => a 
x = read "1234"
-- x is any readable value
y :: Integer
y = x
z :: Double
z = x


Then when you do
take (read "1234") primes


The type of take is
Int -> [a] -> [a]

So GHC knows that the (read "1234") bit must have type Int
So it figures out to substitute a for Int in
(Read a) => String -> a
>>
>>56441978
Just use Java like a normal person
>>
>>56443283
read x :: Int
>>
>>56443506
>>56443569
In a way it's like variable templates from C++
(x from the example)

template <typename T>
constexpr T x = parse<T>("1234");
// assume there's some function "parse<T>" that parses a T from a string
// and if there isn't, that's like if there isn't an instance of the Read typeclass from Haskell


>>56443590
It's not clear whether (read x) or (x :: Int) binds tighter in this example
>>
>>56443508
>Not wanting to understand your tools
code monkey plz go
>>
How does someone who hasn't into programming in any way since HS get into it? I'm a fry cook at wendy's, i took web design classes like 6 years ago in HS though.

What books do you recommend?
>>
>>56443569
Wtf I tried it now and it worked but before when I was doing without toInt and only doing dat <- getArgs it said that dat <- getArgs was of type IO String and couldn't be passed to take or some shit like that. I already forgot how I was doing it.

I don't even know anymore lmao.
>>
>>56443739
Depends what your field of interest is m8.
webdev
systems dev
gamedev
full-stack
etc
>>
>>56443766
do
dat <- getArgs
... read dat ...

NOT

do
... read (dat <- getArgs) ...

because that wouldn't make sense
when you understand a lot more, you'll get why
for instance if you had

... a <- ma ... ... b <- m b ...
then it's not at all obvious in which order the side effect should be done and when
>>
>>56443767
How's learning c# and seeing how things go sound? it's flexible and not a meme, right?

also gamedev would be ideal since I'm a memer and not a wizard like everyone else who already does this shit anyway so I'll stay in my lane
>>
>>56443824
Sure. Can't recommend a book as I've never used it myself even though it's pretty much just a c++ flavor. But I can say to stay away from gamedev until you've been through atleast most of a book. Too many people think fragmented learning and google is a good approach, it's not.
>>
>>56443824
Just give up mate, you will never make it

People actually went to uni for this shit
>>
>>56443824
ignore >>56443880
>>
>>56443900
You really think a guy who cooks burgers for a living can suddenly become a game dev?

Lmao
>>
>>56443880
Many other good coders didn't.
>>
File: tim cook.gif (46KB, 644x447px) Image search: [Google]
tim cook.gif
46KB, 644x447px
>>56443923
>>
>>56443923
I think someone who has curiosity and can read books can learn how to code.
>>
>>56443923
Are you fucking dumb? Are you one of those /v/ fags? A fucking retard like you could be a game dev, it's not hard
>>
>>56440262
K&R is not outdated. The declaration style is outdated but you can pick that up anywhere.

Read K&R and C Programming: Modern approach side by side. Do the exercises. There's stuff in K&R exercises that teach you that won't be in C/Modern Approach book.

Read CS:APP (google it, see TOC)
Buy the dirt cheap pirate international 3rd edition. Do the exercises.

Read 21 Century C.

Now read the Linux kernel or *bsd style guide to see how modern C delcarations and other style is done. Read the first few chapters of 'Practice of Programming' to learn tests/software engineering best practices.

Finally get the book 'The Art of Software Security Assessment' and combine your knowlege of CS:APP plus C Programming to write memory safe programs.

Congrats you are a C developer now go forth to stack exchange and look for tag [c] to find a job or apply to any application security outfit like NCC Group or Accuvant they always hire C devs esp with knowledge of assembly on x64
>>
>>56443948
I don't doubt that, but it won't get you a job
>>
>>56444014
see
>>56443992
>>
>>56442690
my much simpler solution
{-# LANGUAGE ViewPatterns #-}
import Data.Char

tri = reverse . pad . make
where pad = zipWith space [0..]
space = \s b -> replicate s ' ' ++ b

make 'a' = ["a"]
make (toLower -> c)
= (h ++ [c] ++ reverse h)
: make (pred c)
where h = ['a'..pred c]
>>
>>56444099
>reading lyah
>ez as fuark
>everything makes sense and is really simple
>foldl, foldr, scanl, scanr, etc
heck
>>
>>56443824
C# is comfy, I really like it.
>>
>>56444164
did not mean to reply to >>56444099
>>
>>56444164
what about fold/scan?
haven't used scan but fold is extremely simple
>>
>>56442147
build a shopify app and sell it on their mktplace

>>56442949
The free book version control + MIT info
http://ericsink.com/vcbe/
http://web.mit.edu/6.005/www/sp16/getting-started/#git


>>56443298
Sure but you could do it all yourself if you had motivation. Do the free "book" 'Learn Ruby the Hard Way' on Zed Shaw's site, then Look up 'Agile development with Rails' on edx and take that for free https://www.edx.org/course/agile-development-using-ruby-rails-uc-berkeleyx-cs169-1x there's a part 2 coming out soon where you can get actual credit for it.. it's exactly the same as any bootcamp.

>>56443739
Read all these books then learn C++, also read every book you can on Linear Algebra as it's important for game dev >>56443992

If you can't program whatsoever then try this, Python is used everywhere (TensorFlow library is all in Python with a C++ 'back end'). https://learnpythonthehardway.org/book/ then do this after, Python intro to CS course at CMU (click on lectures, they lead to mini video tutorials) http://www.kosbie.net/cmu/spring-16/15-112/schedule.html

In my class we were given a C++ crash course and expected to implement a hash join operator by ourself for an in memory db. Because we all knew C and systems programming (that CS:APP book) it was not a problem. This is the only tutorial we were given: http://www.cplusplus.com/doc/tutorial/

>>56443948
John Carmack, says this is exactly how you learn to code. You read books on programming, implementing all the programs. You read them twice if you have to. Then you find an open source project somewhere and start by reading all it's documentation and poking at it's libraries. Then start by fixing bugs, writing features users have requested and fixing those bugs you just wrote as they pop up. Repeat and congrats ur a dev. There's also challenges for Jr Developers like stockfighter.io and memorycorruption.com to get a job with little exp
>>
>can't even get 6 lines into a glorified hello world without VS shitting the bed

Thanks for whoever told me this IDE was /g/ approved

pls gib alternatives
>>
>>56443274
How so, I'm interested in what would make a language less expressive than another
>>
>>56444234
The fuck did you do you dumbass
I don't think VS2015 has EVER crashed for me, and I've used it thousands of times
>>
>>56444243
in the grand scheme of things
>>
>>56444234
Code::Blocks
Built around C++, cross-plat,OS, and especially not bloated to shit with useless enterprise tools for non-enterprise users
>>
>>56444273
Code::Blocks is great.
>>
>>56444273
>try again
>this time it's a whole different error

Topwew

Looks Like I'm forced to if I want to do anything C related.

Does it just werk with C# too?
>>
>>56444326
Obviously something is wrong with your system, not the 2 IDEs. Likely a read only file system you keep trying to write to
>>
>>56444326
What the fuck are you doing?
But unfortunately not officially.
For C#, typically you'd use http://www.monodevelop.com/
>>
>>56444326
You are so retarded you can't even use an IDE that does everything for you

How did you even start the damn computer?
>>
File: saddest dog.jpg (50KB, 401x600px) Image search: [Google]
saddest dog.jpg
50KB, 401x600px
>>56444372
>>56444397
>download IDE that microsoft pimps to you
>it doesn't work from the getgo
>somehow this is my fault and I'm stupid

Programming is awesome
>>
>>56444164
>implying foldl and foldr as hard
whats hard is seq, an knowing when evaluation is going to happen

anyways, foldl just takes a starting value, a list, and a binary function that operates on both

since its foldl , the starting value is on the leftmost
you can think of
foldl (+) 0 [1..2] as
adding 0 to 1, reducing it to 1, and the 1 becoming the zero, so now you have foldl (+) 1 [2]
which is 1 + 2, which is 3
when foldl encounters an empty list, then it give back the accumulator, which is 3 in this case
>>
>>56444451
>i-it's totally not my fault that i have this problem nobody else does!
You are literally so retarded that you broke it

It is astonishing that you have managed to break it so quickly despite knowing fuck all
>>
>>56444491
*and a binary function that operates on the type of the starting value, and on the type of the list value
>>
>>56444505
We've all broken simple things with simple mistakes. Especially out of ignorance, simmer down you autist.
>>
>>56444527
>We've all broken simple things with simple mistakes. Especially out of ignorance, simmer down you autist.
Nobody's broken VS like that.
You are a new fucking kind of dumb.
This is fucking "the textbook fell apart when I opened it" tier shit
>>
>>56444538
I'm not even him m8.
>>
>>56442828

>continue
>>
File: the_kek.png (208KB, 541x456px) Image search: [Google]
the_kek.png
208KB, 541x456px
>>56440795
download sublime text
do this https://www.youtube.com/watch?v=wM2LbXCkLDI

fuck that cuck faggot that makes notepad++
>>
Hey all, been trying to learn some ASP.NET recently and I've got a class that has two relationships with the ApplicationUser class (EF Code First). The problem is is that it's only generating one of the relationships on one of the classes. Here's the code for both classes:


public class Job
{
public int Id { get; set; }

[Required]
public string Name { get; set; }

[Required]
public string Description { get; set; }
public DateTime CreatedDate { get; set; }
public DateTime DueDate { get; set; }

[DefaultValue(Status.Active)]
public Status Status { get; set; }
public virtual ICollection<Comment> Comments { get; set; }

public virtual ApplicationUser AssignedBy { get; set; }
public virtual ICollection<ApplicationUser> AssignedTo { get; set; }

[Required]
public virtual Magazine Magazine { get; set; }
}

public class ApplicationUser : IdentityUser
{
public async Task<ClaimsIdentity> GenerateUserIdentityAsync(UserManager<ApplicationUser> manager)
{
// Note the authenticationType must match the one defined in CookieAuthenticationOptions.AuthenticationType
var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie);
// Add custom user claims here
return userIdentity;
}


[DefaultValue(Status.Active)]
public Status Status { get; set; }
public ICollection<Comment> Comments { get; set; }

public virtual ICollection<Magazine> Magazines { get; set; }

[InverseProperty("AssignedBy")]
public virtual ICollection<Job> JobsAssignedBy { get; set; }

[InverseProperty("AssignedTo")]
public virtual ICollection<Job> JobsAssignedTo { get; set; }

}


The attached image is what I'm getting in terms of database fields. Any ideas?
>>
>>56444538
>bill_gates_discovers_VS_bugs_html
>>
How do I average two ints in C?
>>
>php
I want to check if a string contains only integer
For example, is there a function to differentiate between "3" and "3d"?
> if (intval("3d") == "3d") then it's not an integer
>>
>>56444717
You don't
>>
>>56444717

>psuedo

float c = ( int a + int b) / 2
>>
>>56444717

Cast to doubles and assign to a new variable
>>
>>56444773
WRONG

>>56444783
NOT WRONG
>>
so, people talk a lot about automating the task of programmers... well, what/were are these programs that can build other programs easily?

>>56444599
nothing wrong with continue

>>56444773
no.
>>
>>56444806
>well, what/were are these programs that can build other programs easily?


stuxnet
>>
>>56444806
visual scripting
>>
File: 1470860553898.jpg (45KB, 680x680px) Image search: [Google]
1470860553898.jpg
45KB, 680x680px
>>56444801
>not wrong
>>
>>56444451
Going to recommend you abandon programming for now and take a course on Logic, specifically Basic and Formal logic so you aren't so much of a total retard.

edx and MIT has plenty of these online, plus ample books. Nobody more illogical on this world exists than you.
>>
>>56444806
>using continue when an else would use 1 fewer line and make the code clearer
...
>>
Shit

#include "avglib.h"

int main(int argc, char *argv[])
{
avg(1, 2);

return 0;
}
>>
>>56444717
Please stop this averaging ints meme.
#include <stdlib.h>

int iavg(int n, const int arr[static const n])
{
int avg = 0;
int rem[2] = {0, 0};
int add[2] = {0, 0};

for (int i = 0; i < n; ++i) {
avg += arr[i] / n;

int a = abs(arr[i] % n);
int j = arr[i] < 0;

if (rem[j] >= n - a) {
rem[j] = a - (n - rem[j]);
++add[j];
} else {
rem[j] += a;
}
}

avg += add[0] - add[1];

if (avg < 0 && rem[0] > rem[1])
++avg;
else if (avg > 0 && rem[0] < rem[1])
--avg;

return avg;
}
>>
>>56444863
>It's logical to blame the end user for errors originating with no input error

t. microsoft
>>
>>56442828
main_list.append(i)
counter=0
continue

this happens in both halves of the inner if statement, it'd make more sense to just place it in the outer one.
>>
File: Something happened.png (5KB, 714x400px) Image search: [Google]
Something happened.png
5KB, 714x400px
>>56444898
>it's never the user's fault
t. microsoft
>>
>>56444326
>windows

>>56444234
>windows
>meme studio
>>
>>56444957
>switch to memebian
>compiler can't even figure out what universe we're in
>>
What should I go into if:

I feel like vomiting when I start looking into really complicated toolchains, frameworks that pull in a fuckton of dependencies, things like that
I think I could get into gritty low-level stuff but have no experience with it
I want a job
I want to spend more time struggling with the programming itself than struggling with the toolchain and making libraries play nicely
I like functional programming but I don't need it
I have some experience with c++ (up to the point of making linked lists in some class years ago, wasn't stumped by anything up to that point)
I'm not really excited about being tied to MS/.NET but could deal with it, maybe, I guess

Is it the year of haskell employability? I fooled with that a little and had a great time (except for shit cabal, again I hate grappling with that kind of stuff and would rather grapple with the actual code)

Do handheld devices use small-instruction asm? Do people hire for this if someone just has the knowledge, but not a related degree?

Thanks for any advice, inb4 kys
>>
>>56444863
>I don't know what formal logic is
We knew all along anon
>>
>>56444982
>Is it the year of haskell employability?
No.
>>
>>56444970
>>compiler can't even figure out what universe we're in
Who told you that? I never had any problem with gcc. If you had any problems you can ask however and I will do my best to help you.
>>
>>56444982
>Is it the year of haskell employability?
No.
>>
>>56444952
t. google
>>
>>56444982
>Haskell employability
Type haskell into hnhiring.me or stack overflow jobs listings site.

>handheld devices, small instruction asm
Yes, do this challenge and they will likely find you a job https://www.stockfighter.io/#jailbreak

There's tons of medical security corps that hire reverse engineers and asm developers for small custom devices too
>>
>>56440580
I love how you post a pitch black of your output and not of your fucking program.
>>
>>56444849
stuxnet was a program specialized in destroying uranium enrichment systems. I don't see how this has anything to do with replacing programmers.

>>56444857
that still needs a programmer

>>56444875
oh, lol, you are right.
I hadn't paid attention to the code...
>>
>>56444773
define myVarA as numd0type
define myVarB as numd0type
define myVarC as numd4type

let myVarA = 10
let myVarB = 20
let myVarC = 0

let myVarC = myVarA + myVarB
let myVarC = myVarC / 2


>tfw this is how I would have to do this in my current job.

'Higher Level' language that compiles into BCPL.
>>
>>56440927
Time is a construct though
>>
>>56445185
what job would u ever write that for? i just got done doing assignments with stupid shit like that.
>>
>>56445238
Oh my friend, I work at an insurance software house and some of the shit I have to write is literally unbelievable.

I might do a little show and tell with snippets,

I joined about a year ago and I have to debug code written in an ancient language and some of it is untouched since the 90's.

When the company started, the language couldn't support your own defined variables, so I have to debug shit where 'flag01' through 'flag20' is used, and re-used.
>>
>>56445297
How do you get a job like this? I imagine the pay is decent because it's not sexy webdev agile stories and probably hard to attract developers
>>
>>56443348

you are seriously fucking retarded
>>
>>56445356
???
>>
>>56445297
Im not even done with my first week in MIT intro programming and ive wrote this same code in python like 30 times already. I think you have an amazing job if you get to do that shit. But probably very frustrating aswell.
>>
>>56445336
i am only 22, pay is pretty good and I also just took over the role of weekly releases. So I will be pushing for more £££.

I worked a joke of a job, minimum wage, managing 2 servers, all of the internal IT, network and web dev for 2 ecom sites. It was as a favor so I put up with it.

Then I applied for jobs elsewhere, 4 interviews, 3 offers. Accepted this because it sounded interesting.

>>56445389
Yes, feels very rewarding when a bug gets reported and you solve it, its also surprising to sit there fixing a bug that has existed, un-noticed since 2008 and beyond. The only downside is the language isn't really used elsewhere so its not something I can say I have tons of knowledge of and walk into another job.
>>
i've made this code to rotate 90º a string, ie: test ->code->tset
can you guys give me some feedbacks? its working, but for me its looking quite spaghetty.
#include <stdio.h>
#include <stdlib.h>

int main()
{
int i=49;
char *word;
word = (char*)calloc(50, sizeof(char));

printf("Enter a string: (Max. 50 characters)\n");
fgets(word, 50, stdin);

for (i; i>-1; i--)
{
if (word[i] != 0)
printf("%c", word[i]);
}
printf("\n");
system("PAUSE");
return 0;
}
>>
File: 1444090021746.jpg (40KB, 640x480px) Image search: [Google]
1444090021746.jpg
40KB, 640x480px
>>56445426
>(char*)
>sizeof(char)
>system("PAUSE");
>>
>>56445426
Reading this gave me cancer.
>>
>>56445486
i have no idea how to manipulate strings
>>
>>56445426
asking for advice about being a programmer on /g/ means you will be a bad programmer
>>
>>56445507
i have nowhere to ask
also, i always learn something new here
>>
>>56445494
No shit, sherlock.
>>
>>56444982
>Is it the year of haskell employability?
it will never be

>I have some experience with c++ (up to the point of making linked lists in some class years ago, wasn't stumped by anything up to that point)
That's not experience at all, you barely scratched the surface. If you were stumped by making linked list you should be able to acknowledge you can't do basic memory management which is necessary in C++.

Libraries and toolchains are also not very difficult to put together, cmake and package managers literally handles everything for you. If libraries were difficult, no one would use them.
>>
>>56443880
pls, I didn't go to uni at all, or HS, and my code shits on yours.
>>
whats the format specifier for uintmax_t?
>>
>>56443237
It does come after C.
>>
>>56445426

1. If you want to allocate a fixed, small amount of memory (on the order of a few KiB or less), you can use the stack instead of the heap, as it can be done in one instruction, rather than a few hundred or more. In your current situation, the use of functions like calloc is also rather unnecessary, as fgets will do the job of appending the null terminator.

2. Your user can actually enter a string of 49 characters at most, 48 if we're not including the newline character that tells fgets to stop blocking.

3. If you want to print one character at a time, use putchar, rather than printf.

4. DO NOT USE system("PAUSE"), DAMMIT!
>>
>>56445426
not bad
to make it look better, you could include
int i=49

to
for (i; i>-1; i--)
{
if (word[i] != 0)
printf("%c", word[i]);
}

like
for (int i = 49; i>-1; i--)
{
if (word[i] != 0)
printf("%c", word[i]);
}

but you will have to include
-std=c99
in your compiler args
>>
>>56445426
Fix your indentation.
Don't cast void pointers.
Don't sizeof(char).
Don't even use malloc/calloc for such a small buffer.
If you continue to use malloc/calloc, free your damn memory.
Declare your variables in the for loop.
Don't use printf on a single character. Use putchar.
Don't do something as stupid as system("PAUSE")
>>
cygwin is comfy
>>
>>56445731
>Using a hackjob fake POSIX environment
>Not just using the real thing.
>>
File: 1462666392038.jpg (57KB, 415x440px) Image search: [Google]
1462666392038.jpg
57KB, 415x440px
>>56445755
>fake POSIX environment
>>
File: 1471488100811.gif (2MB, 220x190px) Image search: [Google]
1471488100811.gif
2MB, 220x190px
>>56441081
underfuckingrated
>>
>>56445573
>you barely scratched the surface
Well aware of that, just saying that's how far the class went and it wasn't difficult. I've never pursued it further because I've never had a reason to. I think memory management sounds kind of fun, but again no reason to do it.

Do people still hire for C++? Is it worth going into at this point? Seems like everything thinks it's a sprawling mess of junk duct-taped together, but seems like you can find any opinion on any language/framework so I don't know how much to trust or care about that. But I will say the sprawling tangle of the bit of Rails I've done really turned me off to webdev.
>>
>>56445771

It's "fake" in the sense that it's all userland code with some undocumented kernel API hacks.

It works well for what it is but dear goodness is cygwin just outright ugly. You should either use the Linux subsystem or a VM with Linux for all your POSIX needs or MinGW-w64 if you need win32 compatibility. There should be very few apps that really need Cygwin.
>>
>>56445679
i used calloc to have some zeroes and then use the the decreasing i

>4. DO NOT USE system("PAUSE"), DAMMIT!
whats wrong with it? its because its windows exclusive or just bad manners in general?

>>56445689
>Fix your indentation.
i have no idea how to improve this, but i'd really like to

>Don't cast void pointers.
>Don't sizeof(char)
can you tell me whats wrong with these? i always thought i should always cast void pointers
>>
File: 1469923172142.jpg (24KB, 360x270px) Image search: [Google]
1469923172142.jpg
24KB, 360x270px
Im currently working on implementing of multiplayer in muh gayme. client - server architecture with entity interpolation and dead reckoning if necessary. no problem. but lag compensation with reconciliation is kinda my problem.
how the fuck am I suppose to store complex data structures like the spatial shit in a way that I can reconstruct it into the past? sure I can just store the changes/ gradients but when the server has to run a simulation for all players and be able to quickly reconciliate by re-simulate the past all I see is exploding processors.
>>
Is learning python the hard way a good learning book? Or is it an exercise book? I'm scrolling through and the guy every now and then tells you to "go find out what _______ means".
>>
>>56445939
I have yet to see anyone say they like it
>>
>>56445917
git gud
>>
>>56445917
>when the server has to run a simulation for all players and be able to quickly reconciliate by re-simulate the past all I see is exploding processors.
All the dead reckoning/reconciliation/etc. happens purely on the client side.
>>
>>56445939
python is a meme
>>
>>56445954

looks like I'm not the only one that thinks this.
>>
Does anyone here know their makefiles? If so, judge mine. It is intended to be a relatively robust skeleton to be used by most of my small projects and be able to adapt it to larger ones.
Using GNU extensions because plain old makefiles are just too fucking limited.
I thought about doing multiple compilation targets (debug, release, etc) but it is too fucking much of a pain in the ass. Makefiles are a pain in the ass but oh well. I really don't like the design philosophy of most classic UNIX tools that include some form of scripting, much less GNU's but it is standard and they do work well if you can get past their obnoxious syntax.
BIN = newproject
SRCS = $(wildcard *.c)

INCS = -I.
LIBS = -lm

CFLAGS = $(INCS) -c -g -Wall -std=c99 -pedantic
LDFLAGS = $(LIBS)
OUTFLAG = -o
INFLAG =

CC = gcc
DEPGEN = gcc $(INCS) -MM -MP -MT $(patsubst %$(SRCEXT),%$(OBJEXT),$<)
RM = rm -f
TOUCH = touch

OBJEXT = .o
DEPEXT = .d
SRCEXT = .c
OBJS = $(SRCS:$(SRCEXT)=$(OBJEXT))
DEPS = $(SRCS:$(SRCEXT)=$(DEPEXT))

all: $(BIN)

$(BIN): $(OBJS)
$(CC) $(LDFLAGS) $(INFLAG)$^ $(OUTFLAG)$@

clean:
$(RM) $(BIN) $(OBJS) $(DEPS)

%$(OBJEXT): %$(SRCEXT)
$(DEPGEN) $< $(OUTFLAG)$(patsubst %$(OBJEXT),%$(DEPEXT),$@)
$(CC) $(CFLAGS) $(INFLAG)$< $(OUTFLAG)$@

%$(DEPEXT): %$(SRCEXT)
@$(TOUCH) $@

-include $(DEPS)
>>
so uninitialized pointers are given a random memory address
what does that mean, that it can alter any ram
can it also alter hdd or ssd
forgive me, but im a newfag to c
>>
>>56445898
with cygwin I can skip booting a linux vm and all the problems having one can bring while being comfy
>>
>>56445755
It does not confirm to POSIX so it is not a POSIX environment.
>>
>>56445972
but the server is authoritative and if go with the current model that all players except you are 1 tick behind you need to re-simulate events on the server
for example if you shoot someone and you inform the server of a hit the server has to re-simulate that shot to make sure its valid. at least that's what the tutorial says:
>When you shoot, client sends this event to the server with full information: the exact timestamp of your shot, and the exact aim of the weapon.
>Here’s the crucial step. Since the server gets all the input with timestamps, it can authoritatively reconstruct the world at any instant in the past. In particular, it can reconstruct the world exactly as it looked like to any client at any point in time.
>This means the server can know exactly what was on your weapon’s sights the instant you shot. It was the past position of your enemy’s head, but the server knows it was the position of his head in your present.
>The server processes the shot at that point in time, and updates the clients.

http://www.gabrielgambetta.com/fpm4.html
>>
>>56446040
Not random. Undefined is very different from random.
And no. The OS still protects you from accessing memory not assigned to you. You can make a pointer point to anywhere, but that does not mean the OS will actually let you access that particular piece of memory.
>>
>>56445899

>i used calloc to have some zeroes
As previously mentioned, fgets will automatically null terminate your string, so you don't need the extra zeroes. If you really need to zero the entire thing, you can use memset on a stack-allocated buffer. It is still faster.

>whats wrong with it? its because its windows exclusive or just bad manners in general?
Multiple reasons. Aside from the fact that it is Windows-only as you just mentioned, it is also worth noting that your problem only exists on Windows, and only if you are a moron. With the Windows Portable Executable format (.exe), there are two types of applications -- console applications and Windows applications. When a console application is run, it needs a console as context. If you double click on it, or run it from the start menu, or really from any context other than an existing console, it's going to create a new console for the duration of the program, and then destroy that console once the program has terminated. The solution is to run it from a console, or from some other sort of script. If you are using Visual Studio, you would hit f5 to build and "run without debugger". This will run a script that's more or less going to look like this.

./your_program.exe
pause


Your program should not be the one to implement pausing. It is to process its input, spit out output, and then quit as soon as possible. You aren't building a GUI or TUI application that is supposed to stay open until explicitly told to stop. It is up to the controlling context to figure out what the hell to do with what you just printed to stdout.

Beyond this basic fact that your program shouldn't wait for user input unless absolutely necessary, there is also the fact that you are launching a goddamn shell to run an application to pause your program, when there are far easier methods. You might have noticed that fgets() will pause it until user input is provided. Try that if you must.
>>
What's a book I can pick up to learn C? I hear that K&R's book is outdated.
>>
>>56445899
Void pointers are automatically converted into other pointers and vice versa in C. All a cast does is unnecessarily repeat information.
sizeof(char) is guaranteed to be 1, so it's pointless.
>i have no idea how to improve this, but i'd really like to
Pick a style. The most important thing with code style is consistency.
Your program with proper indentation (Linux kernel style):
#include <stdio.h>
#include <stdlib.h>

int main()
{
int i = 49;
char *word;

word = (char*)calloc(50, sizeof(char));

printf("Enter a string: (Max. 50 characters)\n");
fgets(word, 50, stdin);

for (i; i > -1; i--) {
if (word[i] != 0)
printf("%c", word[i]);
}
printf("\n");

system("PAUSE");
return 0;
}


How I would write the program:
#include <stdio.h>
#include <string.h>

int main()
{
char word[50];

puts("Enter a string: (Max. 50 characters)");
fgets(word, sizeof word, stdin);

size_t len = strlen(word);

// Remove trailing newline
if (word[len - 1] == '\n')
--len;

for (int i = len - 1; i >= 0; --i)
putchar(word[i]);
putchar('\n');
}
>>
>>56446079
C is outdated unto itself.
>>
>>56446058
Oh, I see. In that case, all you really need to store is where the players and potentially some objects (if they can move and block a shot) were for a little while back. "Reconstructing" is probably the wrong word to use.
>>
>>56446025

I roll my own Makefiles for most tasks. They strike me as far more simple than CMake or other tools. I don't like build tools that try to abstract the build process. I'd prefer instead that the entire process be explicit, so that it's easier to debug the build process, although Make at the very least allows me to write less code for writing a build script, even if the syntax is terrible.

As for your own Makefile... if it builds the project, and it's extensible for your needs, it's fine.
>>
>>56445426
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define SATDIF(a, b) ((a) > (b) ? (a) - (b) : 0)

typedef int (*interact_t)(char* restrict, FILE* restrict);

static int
interact(interact_t f,
FILE* restrict istream,
FILE* restrict ostream);

static int
rfputs(char* restrict line, FILE* restrict ostream);

static void*
reverse(void* m, size_t n);

static int
interact(interact_t f,
FILE* restrict istream,
FILE* restrict ostream)
{
assert(f != NULL && istream != NULL);

char* line = NULL;
size_t n = 0;

while (getline(&line, &n, istream) != -1)
{
int err = f(line, ostream);

if (err < 0)
{
free(line);
return err;
}
}

free(line);
return 0;
}

static int
rfputs(char* restrict line, FILE* restrict ostream)
{
assert(line != NULL && ostream != NULL);

size_t span = strcspn(line, "\n");

return fputs(reverse(line, span), ostream);
}

static void*
reverse(void* m, size_t n)
{
assert(m != NULL);

for (size_t i = 0, j = SATDIF(n, 1); i < j; ++i, --j)
{
unsigned char *mi = (unsigned char*) m + i,
*mj = (unsigned char*) m + j;

unsigned char tmp = *mi;

*mi = *mj;
*mj = tmp;
}

return m;
}

int
main(void)
{
if (interact(rfputs, stdin, stdout) < 0)
{
perror("interact_reverse");
return EXIT_FAILURE;
}

if (ferror(stdin))
{
perror("interact");
return EXIT_FAILURE;
}
}
>>
File: 1472593208317.jpg (43KB, 500x500px) Image search: [Google]
1472593208317.jpg
43KB, 500x500px
>>56446089
>>56446077
thanks for the patience, guys
>>
>>56445803
>I've never pursued it further because I've never had a reason to.
What kind of mentality is this.

>Do people still hire for C++?
Yes, it ranks a little bit under Java for demand
>>
>>56446200
Oh I forgot to remove `SATDIF`, which is now useless. That's not a big issue tho.
>>
>>56446175
I never used any other build tools really. Just the built-in codeblocks project compiler (which works very well, but it is only suited for small projects) and ANT, which is garbage. I still think make could be so much better without needing to abstract the build process.
Building a makefile for every single project is too much time consuming. Either that or all of your makefiles are one-off designed to work strictly with one project and on one platform, which I do not like. Rather spend the time to write something more extensible and reusable.
>>
>>56446232
Wait he is not. That's why I should not post at 3:16 A.M.
>>
>>56440203
Very nice webm there.

I'll be sure to use those programming jokes at some time.
>>
>>56446077
>>56446208
you forgot to mention that a batch script called "PAUSE" can be thrown into the same folder as the .exe and it will be run. Some unsavvy person might be looking online for some help with the program if it gets distributed, and some mean person will give them a malicious script called "PAUSE" that they tell them to throw in and it will fix their problems. Then it gets executed and some bad stuff happens.
>>
>>56446217
C++ is still very much in demand, so is Java which I would say is the #1 demand due to literally anything 'enterprise" being written in java still like Elastic Search, Oracle junk ect.

Big projects like java because of all the junit/assert tests built in that automatically run as you build the program in cancerous OOP.

C++ every machine learning library, data science and visualization tool is all done in C++ with some kind of Python friendly API so scientists can use it. Browsers are all still done in C/C++, Node.js is C++ ect. Embedded shit is all still done in C, nothing has really changed.

I would rank Java/C++ most in demand followed by Objective-C and C/LLVM knowledge for iOS/Windows work. For webdev pajeet tier it's React.js plus Golang rapidly taking over everything that used to be Rails and Node.js. Parallel execution and distributed computing is big right now and growing.

Due to extremely large, non volatile memory coming out by Intel in 2017 at Level3 cache speed everything will need to get rewritten such as databases who rely on old I/O block systems. File systems will be totally redone as well. I imagine they will want to do this in functional languages with no side effects so they can implement parallel execution across networks of non volatile memory though at first it will just be a total rewrite in C++ like most in memory databases are right now.
>>
>>56446344
>I imagine they will want to do this in functional languages
>>
>>56446025
I use the one at the bottom of this page
http://mrbook.org/blog/tutorials/make/
it's served me well. I use cmake if I want to make a shared library though

>>56446344
you responded to the wrong post, I never questioned the demand of C++.
>>
Does anyone get the feeling that if they aren't programming at least 10h/day they're only going to get left behind?

It's not so much imposter syndrome (I know my shit), but more that there's an ocean of things to learn and not enough time to do it.
>>
>>56446380
http://www.cs.cmu.edu/~15210/schedule.html

Side effects
>>
Write me a linked list in C++
>>
>>56446487
How much will you pay
>>
>>56440203
Write me a linked list in C++
>>
>>56446487
>>56446516
std::cout << "linked list";
>>
>>56446487
#include <list>

Done.
>>
>>56446392
Quite honestly, that is a extremely simple example and not particularly well done.
I would recommend you to use mine instead. Less standard than the one you linked, but more more powerful.
For example, automatic resolution of the .c dependencies is extremely useful (so you don't have to manually type in which .c files use which headers).
>>
>>56446487
>>56446516
"a linked list in C++"
>>
File: Martin Fowler.jpg (36KB, 420x420px) Image search: [Google]
Martin Fowler.jpg
36KB, 420x420px
Does anyone else think Martin Fowler is a blight on the industry who has held back progress by at least a decade? He is the only developer I know who can refactor code and have it come out more complex. If he told his cultish followers that drinking bleach would make them better programmers, I would buy stock in Clorox.

He takes a relatively simple problem and spins it into 100+ micro-classes with no methods longer than 5 lines and endless delegation. What was once a cohesive function is now spread across no fewer than a dozen packages. When my coworkers pull this crap and try to justify it with "blah blah design patterns, blah blah Martin Fowler", I always say that they "fowlered their code".

I'm not advocating for god classes or 500+ line methods. I think there is a healthy middle ground between god classes and the do-nothing micro-classes. I've always been able to reduce fowlered programs to around half their original line count. More cohesive functions also make bad algorithms much more apparent and I can easily optimize the performance.
>>
>>56446576
The more mindless abstractions you make, the less real work you have to do.
>>
>>56446487
Please do not make fun of me on this forum
>>
>>56446516

Ok.

class node
{
//node properties
node * next;
};
typedef node * pnode;
class list
{
public:
pnode first, aux;
//methods or whatever
};


This is basically it, you can define the behaviour as you please.
>>
>>56446407
>Does anyone get the feeling that if they aren't programming at least 10h/day they're only going to get left behind?
I just feel that I won't be able to find a job.
But eve though I enjoy study and programming a lot, there's a limit, I burn out.
>>
>>56446679
>no templates
nice
>>
>>if i in bob:

This made me laugh, thanks. Have some code

def get_bobs_fat_cock(search):

# Use descriptive variables you sick fuck...
occurrences = 0

for i in range(0, len(search) - 2):

test = search[i] + search[i + 1] + search[i + 2]

if test == 'bob':

occurrences += 1

print occurrences


get_bobs_fat_cock('azcbobobegghakl')
>>
>>56446729
Looking at other people's ads on like hnhiring.me or wherever makes me feel like I'm already a failure. But I think people often go like "hadoop yeah I skimmed something about that, better list it as a skill"
>>
>>56446747

Also how do I format code, now you can laugh at me.
>>
>>56446576
I interned at BigTech search corp for 2 semesters at university but decided not to work there after.

While I was there, they were angrily shredding the entire base of OOP cancer because Fowler-ish microclasses had turned a standard build into a 3 week long nightmare of bug chasing. The most productive month I had there was simply everyday showing up and destroying method after useless method in Ad tech software while another department completely rewrote it all in a sane manner.

Fowler should be convicted of being a heretic imprisoned in the tower of london until the cancer of OOP stops spreading.
>>
>>56446200
but how quickly does it reverse the king james bible
>>
>>56446758
There's also a similar monthly 'who wants to be hired' thread instead of hnhiring.me which just lists the consultants ergo they are all senior devs

https://news.ycombinator.com/item?id=12405700
>>
File: chinaman.jpg (34KB, 480x360px) Image search: [Google]
chinaman.jpg
34KB, 480x360px
>>56446797
>all those scrubs who wrote Resume instead of Résumé
Do they even want a job?
>>
>>56446758
Yep, but they could also be lying. Because there's skills that you actually use on a daily basis and skill that you have basic knowledge.
>>
>>56446576
lol. Yeah man, the other day when I went to write code this cocksucker popped up and wouldn't allow me to write code.
Anyone is free to spew their garbage and let sheeple follow. IE twitch.tv

--Aside:
Started writing in PHP and C++ the last week where was writing in python. Looked at coworkers code and feel like he is constantly reinventing shit that is pre-existant in Python. That and if you have to use an IDE/compilers
"special sauce", how can you bother to write code in that language? You are then a stone cold subscriber to that IDE, rather than it just being a toolkit. C++ seems to be very efficient but jesus, it seems like a long-gone train wreck to avoid if it isn't needed.
>>
>>56446792
For [this version](http://www.gutenberg.org/cache/epub/10/pg10.txt) it takes 0.172s (real) on my laptop (0.020 user, 0.130 sys).
>>
>>56446731
Thanks. I think this is a simple approach, even if you are using objects.
>>
>>56446859
>>56446792
If I redirect the output to /dev/null, it only takes 0.009s (real), 0.003s (user) and 0.003s (sys).
>>
File: d96.jpg (27KB, 600x600px) Image search: [Google]
d96.jpg
27KB, 600x600px
>>56446859
>>
>>56444099
>simpler
Seriously, pull the mapping out of your make function, why would you do that? Here's an actually simple and more general implementation:
putLines = mapM_ putStrLn
tri = reverse . pad . map mirror
. reverse . drop 1 . inits
pad = zipWith (++) (iterate (' ':) [])
mirror xs = xs ++ drop 1 (reverse xs)


*Main> putLines (tri ['a'..'g'])
a
aba
abcba
abcdcba
abcdedcba
abcdefedcba
abcdefgfedcba
*Main> putLines (tri "yer a fagit")
y
yey
yerey
yer rey
yer a rey
yer a a rey
yer a f a rey
yer a faf a rey
yer a fagaf a rey
yer a fagigaf a rey
yer a fagitigaf a rey
>>
good ideas for a c++ project to show on portfolio?
>>
>>56446909
because I don't wanan write
 h = [if c < 'A' then 'a' else 'A' .. pred c]

urs doesn't even work properly, wtf is with that slant
>>
>>56446923
make a linked list
>>
>>56446329
I always forget that security vulnerability. Probably the worst part. That said, I personally like to persuade people that they don't need to pause the program in the first place, because using shit like cin.get() or whatever as a replacement is still mildly annoying.
>>
>>56446977
Why would you wanan write that? What slant?
>>
>>56447018

seriously? thats it?
>>
>>56446977
Stop typing like a retard.
>>
>>56446923
Make a DB engine
>>
Trying to program a new text hud for my game, this engine makes huds kind of tricky.
>>
>>56447420
Which engine?
>>
New thread >>56447470
>>
>>56446079
not this person but I'd also like knowing a recommended way to learn C
>>
>>56444234
>c:\user\administrator\documents
>>
File: 1473131431.png (11KB, 352x93px) Image search: [Google]
1473131431.png
11KB, 352x93px
>>
>>56444234
vi
>>
>>56447640
>he doesn't use 4chanx
>>
File: lelelel.png (490KB, 449x401px) Image search: [Google]
lelelel.png
490KB, 449x401px
>>56447640
>>56447666
>>
File: 1458721091134.jpg (100KB, 682x600px) Image search: [Google]
1458721091134.jpg
100KB, 682x600px
>>56449200
>lelelel.png
Someone should end himself
>>
File: saddayforusall.jpg (117KB, 700x774px) Image search: [Google]
saddayforusall.jpg
117KB, 700x774px
>>56449210
Thread posts: 331
Thread images: 38


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

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.