[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: 336
Thread images: 24

File: elite hacker.png (618KB, 1024x576px) Image search: [Google]
elite hacker.png
618KB, 1024x576px
Previous Thread: >>56615154


What are you working on, /g/?
>>
Integrating relational parametricity with observational equality.
>>
>>56619119
So useless junk which won't help you at all then. Have fun.
>>
>>56619068
so what is your http://acm.timus.ru/ranklist.aspx ranking, /dpt/?
>>
>>56619157
Never fucking reply to me again unless you are contributing to the thread.
>>
File: fb.webm (2MB, 292x304px) Image search: [Google]
fb.webm
2MB, 292x304px
rate my fizzbuzz, guys
>>
>>56619178
Never heard of it
>>
>>56619194
>.js
>>>/g/wdg/
>>
>>56619195
its like codefights.com but for "real programmers" who can implements algorithms and data structures and such. Like some of /dpt/ claims to be.
>>
>>56619235
>it's like codefights.com but for "real programmers"
Can't wait until we get the website that's like acm.timus but for "real programmers"
>>
>>56619250
spoj?
>>
>useless 'code challenges' which aren't really challenges at all and would be considered the most trivial parts of any project
Lame. If you attach any sort of value to a score on these sites please submit your resume to my trashbin so I can search for you if you ever send an application.
>>
>>56619188
Never reply to me or my son ever again
>>
trying to get visual studio 2015 enterprise installed on windows 10. this isn't pulling teeth it's trying to jerk off a bull after it threw it's rider. microsoft should spend some money on not sucking.
>>
>>56619402
>microsoft should spend some money on not sucking.
But that means hiring good programmers and saving money on firing the bad programmers.

That's a net positive. They can't spend money on that.
>>
>>56619402
>download vs_community_ENG.exe
>run
>press next
>visual studio is installed
whew laddy what an adventure
>>
>>56619119
Aahahahaha

Literally web-dev tier.
>>
File: vs.jpg (56KB, 1000x550px) Image search: [Google]
vs.jpg
56KB, 1000x550px
>>56619445
>>
>>56619445

you like cheap android smartphones and tablets
>>
>>56619470
What?
>>
>>56619507
wat

>>56619486
Same thing. Unless 2015 dramatically changed the enterprise installer. Which based on the fact people have been bullshitting about how hard it is to install vs since at least 2010 despite being ridiculously simple to install, I'm going to assume it hasn't.
>>
>>56619445

and 30GB of diskspace being wasted.

for references, my devtools folder, which including git, cmder, sublime text, mingw, ruby, python2/3, elixir, erlang, postgresql, nodejs and some other random stuff still doesn't reach 2GB in size.
>>
So I'm taking intro to programming, total novice pleb. Regular on /fit/ so obviously I made this plate calculator thing. Please tell me how I can optimize/improve it or what to do next. Idk how you guys treat newfags but programming and I are in some sort of a honeymoon phase so I thought I'd post, I'm having a lot of fun.

Link to code: http://pastebin.com/9j7xs4sZ
>>
>>56619562

you like crappy versions of good things. no, people don't bullshit about installation problems. i can get vs installed, but i had to download the sdk and a bunch of components then install by hand.
>>
>>56619194
>15 then 3 then 5
>The e
>The close tab button over the text
>The 9 instead of (
Wow, how long did you work on this
>>
>>56619662
Visual studio includes dozens of programs, languages, the .net framework, multiple compilers, multiple languages, git, team foundation server, unit teasting libraries, debugging tools, analysis tools, several enterprise specific features, multiple web development tools, mobile app tools, a gui builder, intellisense, sql and god only knows what else. It's the entire windows development ecosystem in a single package. Plenty of people appreciate that because it suits the manner you write .net code. If all that's too much, use an older version with a newer compiler, or install the relevant compilers and hook them up to visual studio code.
>>
>>56619676
Before the >java shitposts flood in, I just wanted to say well done, anon. You're off to a better start than many of the novice plebs who appear here.
>>
>>56619676
looks fine to me anon. keep up with good indentation.
>>
>>56619820
From your post I assume people don't like java around here, mind explaining why?

>>56619829
thanks dude!
>>
>>56619811

you can unselect most of those things if you don't want them and you should see what the analysis tools can do. event tracing in windows 7+ is slick especially in windows components.
>>
>Set up C++ to automate calculus homework finding averages
I know it's absolutely in impressive and nothing special but I still feel cool
>>
>>56619676
Some strange indentation there. Better than when I started though
>>
>>56619864
not the same anon, but people dont like java here because it's object oriented, and in my personal opinion the syntax is god awful. there are other reasons but im sure youll get plenty of replies
>>
>>56619811
>Visual studio includes dozens of programs
which you don't use, and don't have the right to uncheck.

I didn't even install VS, just C++ build tools, and lol they installed load of database tool craps.
>>
>>56619875
Haven't really been taught what is and what isn't proper indentation (yet). If anyone got a link or whatever I'd eat that shit up
>>
File: last.png (14KB, 965x301px) Image search: [Google]
last.png
14KB, 965x301px
Trying to optimize my mbox parser for no real reason, it's already pretty fast, it can parse a ~280MB mbox with ~51k emails in less than a second on my machine, in comparison mutt takes 5 seconds to load the same mbox.
>>
>>56619868
Ya they are top notch.

>>56619904
As the above anon pointed out you can uncheck plenty of them.

>how dare a thing do the thing it sets out to do.
Visual Studio makes no bones about what it is, it's a massive total ecosystem development tool targetted at windows. But again, the finstall size CAN be reduced. Just not to eclipse levels or whatever.

>>56619915
Look up k&r and allman indentation styles.
In general only indent things further when they are inside curly braces.
>>
fuck loonix
>>
File: new game brun 46.png (389KB, 669x1000px) Image search: [Google]
new game brun 46.png
389KB, 669x1000px
>tfw finally found a programming language that I really like
>tfw there are 0 jobs that require it
Why do everyone bully Prolog
>>
Anyone familiar with Visual Studio?

I'm writing a small utility library for myself, but how do i use it in my other projects?

I could just copy the source files into every project that wants to use the lib, but there's got to be a better way of doing it.
>>
>>56619999
Prolog is pretty domain specific if my memory is well
>>
>>56619999
>Prolog
Honestly, it's a goddamned mindfuck and nobody can understand how to use it.
>>
>>56619871
>feelings
That's SJW fuel. Have you at least learned something?
>>
File: 5Vat1UK.jpg (103KB, 622x486px) Image search: [Google]
5Vat1UK.jpg
103KB, 622x486px
Why does everyone hate on C++?

It's like best language desu
>>
>>56620035
Because everyone who's smart enough to use it without tying their brain into a knot goes directly to C.
>>
File: Mikasa.jpg (457KB, 1252x1350px) Image search: [Google]
Mikasa.jpg
457KB, 1252x1350px
>>56620016
Not really but then again I might not have touched on the mindfucky bits, right now I am trying to identify the mastermind that controls a spy ring from a set of persons that have relationships with each other. It's pretty comfy if you have had a rigouros course in mathematical knowledge desu
>>56620035
Bloated as fuck and age related problems, I would like a new C++ with much of the old shit removed
>>
>>56620007
Depends on if both the library and the projects are in the same solution or not.
If they are, simple right click the project, add->reference>fromsolution->youLib

If not, compile the library with the release flag (where it says debug up top, select release). Then go to libraryDir/bin find the .dll of your library then add a reference to it(it doesn't have to be in the project directory as far as I know but it's nice to have everything in one place)
>>
>>56620081
>Then go to libraryDir/bin find the .dll of your library then add a reference to it
I'm sorry, i don't know what this means.

The utility library is in it's own solution.
>>
>>56620073
>age related problems
Please elaborate.
>>
>>56620081
>.dll
Haram
>>
>>56620073
>age related problems
Programming languages don't really have those. You're thinking of backwards compatibility baggage, which can happen to any language no matter how old it is. Scheme, for example, is older than C++ but a million times more pleasant to reason about.
>>
>>56620150
After you build you library, go to its folder in windows explorer so you know where it is. The library file will be in a folder called release, which will be inside a folder called bin. While you're here, click on the url bar of windows explorer and copy the path.

On the project name in visual studio, right click and hover over "add", then select "reference", a window will pop up of libraries you can use. At the bottom will be a "browse" button. Click on that and now you can either naivgate to your file, or paste that path you copied into the url bar again, then select your .dll file
>>
>>56620279
Thanks.
>>
Anyone know of a site like repl.it that runs code client side instead of server side? I was trying to play Dwemthy's Array, but it lags really bad when printing a ton of lines.
>>
>>56620296
NP. Good luck with your devving anon.
>>
File: Homotopy Type Theory.jpg (117KB, 675x900px) Image search: [Google]
Homotopy Type Theory.jpg
117KB, 675x900px
>>56620231
Yeah, Scheme is great and a real pleasure to write code with but I still feel that C++ feels old and clunky, can't really point to one thing desu. It's probably have to do with the mess that is headerfiles, compilation of large programs, no modules etc
>>
>>56620310
a...compiler?

You could try ideone. It's not a repl but it sets up the boilerplate and creates it's output before it sends you the result rather than on the fly
>>
>>56620348
What I'm trying to say is, it has nothing to do with being old. Go, for example, is very new, but in many ways it's still clunky and "outdated."
>>
>>56620383
Well, for Dwemthy's Array, you play the game using a repl, so it's not an option. I guess I'll have to wait until I get home. I'm on a school computer, so I usually program using online interpreters and such. Maybe I should make one that does what I want.
>>
Let's say I have variables a, b, c, d and x.

From a, b, c and d I know they are all positive integers, and exactly two match each other. This is their pivot point. Any combination of two can be a pivot point.

How can I most elegantly get the pivot point and determine if x is between the minimum and pivot or maximum and pivot?

I'm cooking something up like compairing the four pairs, putting the pivot there but then I'm making a mess figuring out the minimum and maximum, functions everywhere. Can't I just do this in 5 lines?
>>
>>56620415
>>56620348
i get what your saying is that you need a big fat cock to fill up your guts so your constant faggot lust for novelty stops getting in the way
>>
>>56620438
Sometimes I feel bad about shitposting on /g/.

Then I see posts like yours.
>>
>>56620427
I see. Never heard of it before. No good to you now, but you could possibly set up a repl on your home computer and ssh into it
>>
Hey guys, I haven't paid attention the last year, what are the best github alternitives?
>>
>>56619068
Finished my android game and am desperate for downloads.

FYI it's free of charge, ad free and no micro transactions either. I made it purely because I liked making it.
>>
>>56620463
im just telling you that you are paying unwarranted attention to irrelevant things, like your feels about a language being 'clunky', and i said it in a creative and fun way

i would have never guessed you were an actual homosexual, didnt mean to be a jerk
>>
>>56620488
gitgud for the extra meme factor
>>
>>56620471
Oh, right. I forgot about the obvious solution.
>>
>>56620504
Link it.
>inb4 requests permission to use camera, phone, microphone, messages, my anal cavity and any women I may be about to have sex with in future
>>
>>56620348
>tfw univalence still doesn't have a decent computational interpretation
>>
Is it a bad idea to store 5mb worth of images in a git repo?
Will my repo grow 5mb in size on every commit?
>>
>>56620525
It doesnt ask for any permissions either.

https://play.google.com/store/apps/details?id=planc.refugeeraft

It DOES, however have an agenda some people won't like
>>
>>56620488
GitLab
>>
>>56620567
>Enrich the west
lel
>>
>>56620567
>Sorry! This content is not available in your country yet.
Your agenda is xenophobic to my country
>>
>>56620508
>>56620568
thanks.
>>
how hard is it to make these phone apps

seems like pretty easy
>>
>>56620608
Nope my bad, just the web link. Downloads fine from my phone
>>
>>56619992
I take that back, I was trying to read the virtual memory of a process starting at offset 0x00 instead of 0x08048000.
>>
>>56620608
I dont know why it's like that. I set the distribution to world wide
>>
>>56620640
Oh, cool
>>
>>56620567
So Smuggle Truck for boats?
>>
What text editors do you fa/g/s use?
>>
>>56620565
unless you change image content, then no it won't increase 5mb after every commit.

git commits are like c pointers, its mostly just references.
>>
>>56620692
I was using atom, but it's performance was so bad, I switched to VS Code and it's pretty awesome.
>>
>>56620692
vim
>>
>>56620692
nano, geddit, or worse case netbeans
>>
>>56620736
I love code. I like atom too. But code is slicker.
For those who don't know, ctrl-' brings up the inline terminal, which was a pretty nice surprise.
>>
>>56620348
Looks like Emma with crows feet.
>>
>>56620769
I just got it yesterday, so I still need to figure it out, but that sounds nifty.
>>
What do you guys think of Scala?
>>
>>56620873
As verbose as Java
>>
Holy fuck, I knew C had a reputation for being hard but I didn't think it would be *this* hard. I'm struggling on the most basic K&R exercises.
>>
>>56620567
>enrich the west
kek
>>
What's the best way to learn vim?
>>
C++ pleb here
what's wrong here?
 if (argc == 3 && argv[2] == "-g") {
booleanvalue = true;
}

even if the second argument is -g it doesn't seem to trigger the if
>>
>>56620993
>C is hard
Everyone back in the day built shit in C so it's not hard if you are a normal functioning human being
>>
>>56621022
>second argument
>argv[2]
That is the third argument
Print out argc and see if it is 3
>>
>>56621022
Does == string work like than in cpp? I don't know to be honest
Also that's the third argument, index starts at 0
>>
>>56621022
Here's a quick way to check: print out EVERYTHING in argv, and see what you get. (you have an off by one error, btw)
>>
>>56621075
1st in argv is filename
>>
>>56621055
>>56621143
?
I mean the second argument to the program like
program input flag

wouldn't flag be argc == 3 and argv[2] because argv counts from 0 and argc counts from 1?

>>56621099
I'll try that real quick
>>
>>56621143
he wasn't alone
>>
>>56621075
std::string works line that but he's using two char * so that's why.

He either has to convert argv[2] to std::string (pointless) or just use good ol' strcmp().
>>
>>56621022
just use getopt like a normal human being
also i know in C u use strcmp against strings but u can also do argv[2][1] == 'g'
>>
>>56621169
This is why C++ is a disgusting mess
>>
>>56621169
That was my thinking alright, but I had no idea how c++ deals with it. I assumed there'd be some kind of legacy there from c
>>
>>56621188
delet[] this;
>>
>>56621147
argv[0] is always the relative path of the program itself. and count is always at least 1 because of that.
e.g.
./program test a

will have the following argvs:
argv[0] = "program"
argv[1] = "test"
argv[2] = "a"
>>
>>56621099
here's the output from giving it:
program-name 2 -g

program-name
2
-g
>>
>>56621220
edit:
argv[0] = "./program"
>>
>>56621225
string(argv[2]) == "-g"
>>
>>56621025
>Everyone back in the day built shit in C so it's not hard if you are a normal functioning human being
Well, at the moment I'm being asked to replace every tab, space and backspace from user input, but I have absolutely no idea how I'm supposed to represent a backspace in C
>>
>>56621225
Convert it to std::string or use strcmp as discussed by the laddy explaining it to me
>>
>>56621255
http://www.asciitable.com/
>>
>>56621255
https://en.wikipedia.org/wiki/Escape_sequences_in_C#Table_of_escape_sequences
>>
>>56621255
Escape sequences.
http://en.cppreference.com/w/c/language/escape
>>
>>56621241
terminate called after throwing an instance of 'std::logic_error'                                                                                                                                                    
what(): basic_string::_S_construct null not valid

>>56621258
will try
>>
>>56621255
you use 8
>>
>>56621255
>I'm supposed to represent a backspace in C
"\b \b"
Note there's a space there. For non destructive backspace it's just '\b'
>>
>>56621169
>strncmp
ftfy
Let's play safely now children.
>>
>>56621020
run vimtutor

>>56621255
you were asked to? are you being paid for this, by chance?
>>
>>56621302
I still don't get why you need a safe strcpy function.
You just have to ensure both arguments are NULL-terminated byte strings. If you can't do that you should quietly walk away from C.
>>
Can anyone give me any tips on using interrupts on an arduino?

I'm making a sex toy, I want to be able to press a button to cycle through presets. If I want to make just one preset, I have the motors spin in a sequence pattern and just put it in the loop section, but if I want multiple presets, I have to be able to interrupt the sequence with new instructions.
>>
>>56621347
fuck, wanted to say strcmp
>>
what's more hipster-ish, JS or Go?
>>
>>56621377
Go
>>
>>56621377
JS is the definition of not hipster. Go by induction must be more hipster. Only technologies built on js can be hipster, like node
>>
>>56621377
I hate to admit it, but Go is even more hipsterish than JS

There IS something worse than JS
>>
>>56621258
tried strcmp like so
 if (argc == 3 && strcmp(argv[3], "-g") == 0) {
booleanvalue = true;
}
>>
>>56621347
if the receiving buffer is too small it will cause issues
i.e.
char buff[8];
char *original = "this is really long string";
strcpy(buff, original); // ???
>>
>>56621397
>>56621402
>>56621414
isn't Go being sold as "a new C"? how can it be hipster, then? do I have a completely wrong view of what "hipster" means in the context of computer programming?
>>
>>56621479
>>56621258
fug, hit reply by accident

it gave an address boundary error
>>
>>56621479
argv[argc] is a NULL pointer.

>>56621495
>a new C
It's garbage collected, so it immediately lost all viability to replace C, even slightly.
>>
>>56621495
Not really. It was originally but google have changed their definition of systems language a bit since it was announced. It's more like c for the web at this point, the web seems to be their primary market for it. It's only like C in it's lack of keywords/features and c-based syntax.
>>
>>56621495
>isn't Go being sold as "a new C"? how can it be hipster, then? do I have a completely wrong view of what "hipster" means in the context of computer programming?
What would "a new C" be, if not hipster?
>>
>>56621511
>argv[argc] is a NULL pointer.
ayy, thanks m8
i'm not sure when i changed 2 to 3 there
>>
>>56621479
>
if (argc == 3 && strcmp(argv[2], "-g") == 0) {
booleanvalue = true;
}
>>
>>56621528
>>56621495
If anything rust is the new c (though it's more of a c++ competitor in the making, the three languages share a domain)

>>56621534
Went full circle and made the mistake we all thought you made to begin with.
>>
>>56621351
what are you powering?
just set it to off and then switch to that preset?
>>
>>56621558
kek
>>
>>56621568
Two motors. So a preset would be like "spin 50% 2 seconds spin 100% 2 seconds and loop forever until the preset button is pressed"
>>
>>56621479
>>56621539
booleanvalue = (argc == 3 && strcmp(argv[2], "-g") == 0);
>>
>>56621495
>"a new C"
Every "a new C" is a hipster language.
>>
I'm willing to spend 1700 on a laptop for school.

I'm a CS major with a shit laptop and I've been saving up to buy a nice laptop that can fulfill my needs.

I have a 200 off discount for apple since I'm student, and a 5 percent off from razer.

I've been looking at the macbook pro and the new razer blade.

I've been waiting for the new MBP and people are speculating that it'll be out next month. It'll probably cost me around 1300 with my discount.

The razer blade will cost me 1600 after discount.

What do?

I need a computer that will last me for the next 3-4 years until I have a job and then I can upgrade. I'm buying this now because I'm going to transfer in about 10 months and I want to be ready and rigged out.

Pls hlp
>>
>>56621636
get a thinkpad or business class dell.
>>
>>56621636
>a nice laptop that can fulfill my needs
Which needs are these?
>>
>>56621481
see >>56621363

but even so
const char *src = "This is an even longer string, check and mate!";
const char *dst = malloc(strlen(src)+1);
if (dst != NULL){
strcpy(dst, src);
}
>>
>>56619068
That's VHDL, right?
>>
>>56621688
>const char *dst
I can into code tonight, maybe i schould just go to sleep ...
>>
Learning Python in intro Comp Sci course. Any chance of using Python in a practical way? Any grade A games utilize Python in more ways than just developer tools/things that don't actually make it into the game?
>>
>>56621732
no. python is only really useful for making tools with. but it's second to none in that respect
>>
File: 1471719526619 (1).gif (844KB, 800x786px) Image search: [Google]
1471719526619 (1).gif
844KB, 800x786px
>>56621732
>Any chance of using Python in a practical way?
>>
>>56621732
>games
oh boy
>>
What is DirectX good for? Why would you write your game for DirectX when you can do it for OpenGl?
>>
>>56621636
You could get a desktop/build for half the price while not reducing performance. Though you probably think CS will require you to have laptop with you at all times. Assuming your school isn't shit, you should have ample desktops running very good PCs (newer i7 cores) in the CS department labs. You really do not need a laptop, at least not an expensive one.

My recommendation is too put 800-1000 into a desktop build (learn something new and relevant to CS) and buy a cheap 300-400 laptop that you can use for low performance tasks on the go (though a smart phone may accomplish the same).
>>
>>56619068
I made a craiglist type iPhone app a while back but stopped working on it when I realized that LetGo and OfferUp had that market covered.

since its basically an app that lets you post pictures then shows you posts that are close to your location i'm thinking of spending a few hours to turn it into some kind of local meme board then reposting to the App Store
>>
>>56621665

Playing the latest games, and also some Indie games from Steam.
>>
>>56621814
Standards compliance for OpenGL is pretty shoddy.
>>
>>56621732
You can use Python to script part of your game but don't even think about writing a game engine with it.
CCP Games, the guys behind Eve Online use it extensively, go read their dev blog.
>>
File: i just want to make games.png (99KB, 561x595px) Image search: [Google]
i just want to make games.png
99KB, 561x595px
>>56621732
>muh gejms
How about you kill yourself?
>>
>>56621793
or software, whatever.

>>56621756
So basically it is terrible for anything that will be used in the final product by the user, but great for throwing together high level tools? Is it because the language is so accessible/easy to debug?
>>
>>56621592
so put a loop in your main loop for each preset
>>
>>56621836
>being an elitist
What, you're only allowed to program if your passion is kernaldev? Get a life anon
>>
>>56621897
>kernal
>a
>>
>>56621836
Take it easy >>56621840
>or software, whatever.

It seems more likely that the user base of /g/ would be able to relate to games more so than other programming topics. And it is safe to assume that if no game devs utilize Python in their actual source code, then it probably isn't used in other software either (except for the dev tools mentioned earlier).
>>
>>56621732
Python is only really used for scripting in games but it's a sub-par choice compared to e.g. Lua, simply due to how Lua is designed to be embedded.
>>
>>56621665

Programming in Unity, etc.

I've been noticing a lot of time wasted compiling code on my shit laptop.

Oh and HD porn that doesn't overheat it would be nice
>>
File: min fv.jpg (196KB, 720x720px) Image search: [Google]
min fv.jpg
196KB, 720x720px
>>56621897
If you want to become a code monkey working on games, please take another major. It is thanks to brainless jerkoffs that just want to make gejms that are ruining this fucking major
>>
>>56621840
totally, it's just super quick and easy to write. the interpreter does almost all of the heavy lifting for you, and there are so many general purpose libraries available that you rarely have to write a line of code.
unfortunately, like any interpreted language it just isn't fast enough to justify using on any resource intensive applications
>>
>>56621930
Actually they end up dropping out, so shut the fuck up, you uneducated retard.
>>
File: 1472774910996.png (21KB, 420x420px) Image search: [Google]
1472774910996.png
21KB, 420x420px
>tfw taking high level maths specializing in type theory while working on a programming language with the use case of a game engine
>>
>>56621819

Well I already have a desktop with sub-par components that I can work on.

I want a laptop that's strictly for school/work.

The one I have right now, that's strictly for school/work, is horrible.

I want a laptop that can last me a while. Doesn't have to have a standalone GPU to play games. But it needs a nice processor and at least 8 gigs of ram because I have a lot of shit going on at once.
>>
>>56619068
how do I get better at ruby programming?
>>
>>56621961
Kill yourself, you stupid frogposter.
>>
>>56621961
>use case of a game engine
>stupid frogposter
Should've fucking known
Stay in your fucking robot containment hole
>>
>>56621930
>If you want to become a code monkey working on games
Ya john carmack is the definition of a codemonkey. Only a codemonkey thinks gamedev doesn't have exciting and complicated logic. I bet you think game dev is making a textured cube in unity. There's no such thing as graphics programming, physics engines, lighting or ai.

>>56621910
>not making popcorn in opengl
Do you even watch movies
>>
To those that don't program games, what do you program?
>>
File: deus ex.jpg (329KB, 760x572px) Image search: [Google]
deus ex.jpg
329KB, 760x572px
>>56621960
>dropping out
And cause the first year to be dumbed down to stop people from dropping out, thus ruining my education
>>
What's with all the hate for games?
>>
>>56621992
Game engine development != Game development
>>
>>56621994
Here's a tip I picked up:
If they think gamedev is for codemonkeys, they don't program at all.
If they just think gamedev is cool but/or too hard for them then they're webdevs.
If they think the underlying engines of gamedev are exciting they do systems programming or desktop applications.
>>
>>56621992
>there's no such things as things Unity does for you

>>56622003
Games are okay. Kids that major in CS because they want to make games is not okay. My university has a major titled Game Design specifically for this reason.
>>
>>56622000
>thus ruining my education
if you need to pay to have someone else teach you stuff i think you've got bigger problems than other people "ruining your education"
>>
>>56622000
wrong
>>
>>56622008
>implying the two aren't linked
>implying you can gamedev without intimate knowledge of your engine
>implying engine dev isn't game dev

And kerneldev isn't osdev right?
>>
>>56622015
You're retarded.
>>
>>56622035
Ass devestated nodev detected.
>>
>>56622034
A kernel is an operating system
A game engine is not a game

>intimate knowledge of your engine
Right, all of those fags using Unity, RPG Maker, or whatever could totally implement it themselves.
>>
File: musaigen headphoneschan18.jpg (78KB, 1280x720px) Image search: [Google]
musaigen headphoneschan18.jpg
78KB, 1280x720px
>>56622031
I dont pay since I live in a civilized, first world country mate, it still causes me to have to waste time turning in easy "lab"-work etc. Time that I could use doing something productive
>>
>>56622053
>want to be game dev
>here people shitting on it
>pretend to not want to be game dev
>>If you think game dev is cool, you're probably a real programmer.
>>
Programming a game without an engine involves programming stuff that's in an engine.
>>
>>56622058
my point was that university isn't a necessary pursuit if all you're looking for is an education, not whether or not you have to pay for it in your country. which you likely either do or will in one way or another anyway
>>
>>56622056
>A kernel is an operating system
triggeredstallman.gif
>A game engine is not a game
It's still gamedev.
>Right, all of those fags using Unity, RPG Maker, or whatever could totally implement it themselves.
You don't need to know how to implement it, you need to know what it does and a basic understanding of how. RPG maker is the loosest possible form of gamedev, and really is game design.

Besides that, ai is not engine dev, and to do anything more complicated than a unidirectional sidescroller you need to be able to write decent, performant algorithms.

As I said, the people who hate gamedevs are nodev. At the very least, and at it's very worst, gamedev is still far ahead of webdev on the respectibility scale.
>>
>>56622018
>My university has a major titled Game Design specifically for this reason.
So did mine. It lasted one year. I heard it was worthless. No one who graduated got any work.

They also have a major titled Game Development. That one was pretty tough.
>>
>>56621732
pygames
>>
>>56622095
I know someone majoring in Game Design and they're learning JS. Huge meme.
>>
>>56622072
>>>If you think game dev is cool, you're probably a real programmer.
Gamedev IS cool. I don't do it, but I recognize it for what it is. It's an exciting world with exciting technologies and exciting applications. If nothing else, it gives you an opening to deeper, more complex systems.
>>
>>56622105
Because game design courses are a scam designed specifically to keep the riff raff wannadevs out of computer science/engineering. The only people who get jobs with a game design degree are young women with no particularly noteworthy programming skills are far as I can tell.
>>
File: 1455758460481.png (304KB, 500x500px) Image search: [Google]
1455758460481.png
304KB, 500x500px
>>56622092
We dont hate on game devs, we hate people that want to become game devs. There is a big difference
>>
>>56621840
It's great for pretty much any product that has a somewhat tech savvy userbase. Server-side anything, numerical computations, automating tasks, web-framework, etc etc.

Or you can use it to make your own runescape clickbot in just a few lines. Whatever you want.

Lua is much more common as a game scripting language and desu I like it better than python myself, but it is obscure and rare outside of games programming.
>>
>>56622131
No there isn't. The only devs who deserve hate are nodevs and people working towards becoming nodevs. If gamedev has a disproportionate number of nodevs that's no excuse to hate on gamedev
>>
Writing automation tests for work. We're mostly a Microsoft shop but we're using an MVC.NET framework.
>>
File: vb.png (25KB, 256x256px) Image search: [Google]
vb.png
25KB, 256x256px
Retard reporting in.

Currently working on updating some ancient VB for the insurance company I work at.
Pretty comfy language tbqh, not sure why it triggers so much angst among internet nobodies.
>>
>>56622092
Game engine development is actually a challenging programming task and requires you understand data structures, algorithms, and some math (particularly linear algebra).
Game development (at the level most 4chan posters would be at) consists of click-and-drag gooey shit, where you put a bunch of pre-made sprites onto a grid or whatever.

One of these things belongs on /dpt/. One of these things belongs on >>>/vg/agdg

Go back to your containment thread.
>>
>>56622072
reminder that gamedeveloper and webdeveloper are 80% the same
>>
>>56620348
I feel bad for you son. Youve got 99 problems but a job will never be one.
>>
>>56622151
>working towards becoming nodevs
>gamedev has a disproportionate number of nodevs
Wait what? Whats a nodev?
>>
>>56622180
But this IS our containment thread!
>>
>>56622180
>Game development (at the level most 4chan posters would be at) consists of click-and-drag gooey shit, where you put a bunch of pre-made sprites onto a grid or whatever.

he fact that you think that means your opinion has no weight on the matter, since you clearly have no idea what you're talking about.

>One of these things belongs on /dpt/. One of these things belongs on >>>/vg/agdg
I do systems dev and working on moving to kernel dev. Talk more shit retard.

>>56622198
Basically this guy >>56622180

People who spend their days hating on what people like to program while not doing any dev themselves. They're the scum of online forums and try to hide behind shitposting about, in particular: gamedev, java, c, c++ or any language trying to compete with c/++
>>
>>56619999
Algol has mind share and there's a network effect. Most CAD is logic programming though. You describe what you want and the relations between things, and then the computer creates what you want.
>>
>>56622224
That's what i originally thought. It's /dpt/'s word for poser.
But why would you work towards being a nodev? Unless you're sick of you day job and trying to get yourself fired.
And how are you a game dev if you don't dev?
>>
>>56622273
Nodevs like to clamp down on whatever the first thing they learned was and think they never have to do anything again. They shittalk everything else, don't keep up to date with the thing they like and their only experience is whatever they have no choice but to do in work(if they're professionals).

You're a nodev gamedev if you work towards being a gamedev then just become a shitposter about gamedevs when the going gets tough or the willpower fades.
>>
>>56622224
>he fact that you think that means your opinion has no weight on the matter, since you clearly have no idea what you're talking about.
I did a paper in university about "game development" (I was just wanted an easy paper to get some credits), and that is exactly what it consisted of.
>I do systems dev and working on moving to kernel dev. Talk more shit retard.
Nobody cares.
Also, we don't need a bunch of faggots talking about the sprites they're making in these threads.

>>56622273
>It's /dpt/'s word for poser
I don't think I've ever heard anyone anyone say that here, at least in my recent memory.
If I'm not mistaken, it's a agdg term.
>>
Powershell's range operator is weird. It behaves lazy until you assign it to a variable.

This consumes little to no extra memory:
foreach ($i in 1..100000000) { echo $i }


This consumes about 3 gigs on my system (Which strangely enough indicates that it's using around 30 bytes per element, but that could just be the fact that Powershell has a memory leak):

$ary = 1..100000000
foreach ($i in $ary) { echo $i }


Why can't .NET have a proper range type like Ruby? It literally only needs the memory for two integers.
>>
>>56622303
>I did a paper in university about "game development" (I was just wanted an easy paper to get some credits), and that is exactly what it consisted of.

So you're bragging that you delibierately didn't do game dev and wrote a paper, essentially, on game design using tools that do the work for you(thus limiting your game to whatever the program can automatically do with some gui boxes and drag and drop)
>>
>>56622322
I don't know what your country uses the term "paper" for, but where I live, it just means a university course (but also has the meaning of a research paper and is usually clear from context).
I wasn't aware that it was different elsewhere.
>>
File: 1437880916205.jpg (360KB, 848x1042px) Image search: [Google]
1437880916205.jpg
360KB, 848x1042px
>>56622300
>You're a nodev gamedev if you work towards being a gamedev then just become a shitposter about gamedevs when the going gets tough or the willpower fades.
I did that, and now I'm learning functional programming. Save me senpai.
>>
>>56622348
Ah. I think credits is our equivalent if I understand. Any way point is, what you described isn't really game dev, I'd call it game design but it's some hybrid of the tw
>>
>>56622321
it's an array of (i assume) 32bit integers. It should be about 380 MB.
>>
>>56622377
Functional programming is cool. I've heard.
>>
does anyone know how to install pygame for windows 7 and python 3.5?

its driving me fucking crazy
>>
>>56622174
VB is honestly pretty ok for Windows, I learned VB at my community college's intro course. VBA is hella useful but hella limited and kind of unstable.

>not sure why it triggers so much angst
It's a MS-only language so it doesn't cross platform at all, which is stupid since although it was only recently even C# finally went cross platform. VB only exists because places like insurance companies view programmers/developers as an extraneous cost and modernize at a glacial pace. This thread from like 2006 should elucidate why people sperg about VB (there's also a bit about VB.NET):
https://ubuntuforums.org/showthread.php?t=170516

also
>me.[whatever]
>not this.[whatever]
STOP
>>
>>56622544
>install pygame for windows 7 and python 3
https://www.google.com/search?q=install+pygame+windows-7+python-3
>>
What languages can I use to write a browser? Are there any languages that can't practically handle a web browser?
>>
>>56622689
C#/c++, incorporate webkit
>>
>>56622689
Anything that you can get to render text and pictures on the screen, can parse a text string and has a netsock implementation.
>>
>>56622689
>write a browser
Do you mean "use webkit and slap some buttons on it" or actually write a browser?
>>
>>56622754
Wow, look at me shitposting it up with the best of them.
>>
>>56622606
i've already been googling it m8 nothing seems to work
>>
>>56622785
ah, I guess you can't find binary installers for it? tried installing it through pip?
if that doesn't work... ask the devs, try to compile it yourself (painful and the compilation process could fail), or, the best option IMO: use another version of python
>>
>>56622785
>>56622854
https://gamedev.stackexchange.com/questions/108998/pygame-for-python-3-5
http://www.lfd.uci.edu/~gohlke/pythonlibs/#pygame
install the .whl files with pip
>>
>>56622468

Correct, but killing the process freed up 3 gigabytes of memory. The reason is, I've got an alpha release of Powershell that has a known memory leak in it. It was patched recently, but Microsoft hasn't put up a new release build, so it could be that the current set of commits is still buggy as fuck.
>>
>>56622879
>python
>pip
>.whl
>.WHYLIVE?
>>
I am looking at ways to find popular chat rooms on my site.

Does averaging out the posts per minute make sense? (Assuming I account for spam). What can you geniuses suggest?
>>
life.c
#include <stdlib.h>
#include <time.h>
#include <string.h>

#include <ncurses.h>

#define MIN(a, b) ((a) < (b) ? (a) : (b))

int y=0, x=0, **st;

void cpst(int ny, int nx) {
int **ptr = calloc(ny, sizeof(int)*nx);
for(int i=0; i<MIN(y,ny); i++) {
for (int j=0; j<MIN(x,nx); j++)
ptr[i][j] = st[i][j];
} free(st); y=ny; x=nx; st=ptr;
}

void nextgen(void) {
int nst[y][x]; int adj;
for (int row=0; row<y; row++) {
for (int col=0; col<x; adj=0, col++) {
adj = st[row==0 ? y-1 : row-1][col]
+ st[row==y-1 ? 0 : row+1][col]
+ st[row][col==0 ? x-1 : col-1]
+ st[row][col==x-1 ? 0 : col+1]
+ st[row==0 ? y-1 : row-1][col==0 ? x-1 : col-1]
+ st[row==0 ? y-1 : row-1][col==x-1 ? 0 : col+1]
+ st[row==y-1 ? 0 : row+1][col==0 ? x-1 : col-1]
+ st[row==y-1 ? 0 : row+1][col==x-1 ? 0 : col+1];
if (st[row][col]) nst[row][col] = (adj == 2 || adj == 3);
else nst[row][col] = adj==3;
}
} memcpy(st,nst, sizeof nst);
}

void clutter(int n) {
for (;n--;)
st[rand() % y][rand() % x] = 1;
}

int main() {
srand(time(0) + clock());
int y, x; initscr();
noecho(); cbreak();
halfdelay(3);
while (1) {
getmaxyx(stdscr,y,x); cpst(y, x);
clutter(50);
refresh(); nextgen();
if (getch() == 'q')
break;
else clear();
} endwin();
return 0;
}


stdout
$ ./a.out 
Segmentation fault (core dumped)


???
>>
>>56623076
>$ ./a.out
>Segmentation fault (core dumped)
try
$ gdb -ex r ./a.out
>>
I just built a clover apk and its file name is app-normal-debug.apk.

Why is it that? I followed the instructions on the github page.
>>
>>56623155
Program received signal SIGSEGV, Segmentation fault.
0x0000000000401058 in clutter ()
>>
File: 2527742941.jpg (200KB, 1000x1000px) Image search: [Google]
2527742941.jpg
200KB, 1000x1000px
>>56622879
ok thank you I got it to work this time

Just had a frustrating day I guess
I was using the wrong whl files so it kept saying that they weren't supported, and I wasn't using pip right

thanks alot
>>
>>56623186

Because that's what Android Studio does by default. You can rename it if you wish though.
>>
>>56623195
well, that should give you some clue alreay...
but if you want more clarity, do this:
compile the program again, this time pass the -g flag to gdb. then run it again like this:
$ gdb -ex r -ex "bt f" ./a.out

>>56623195
yw
>>
>>56623076
Do you have to write your code is such a disgusting and annoying to read way?
>>
>>56623195

then try
# rm -r ./*
>>
Would you guys suggest going to school for programming? Or just become a shut in until proficient?
>>
>>56623250
also add
-ex "print x" -ex "print y"
to gdb

>>56623254
no

>>56623270
>Or just become a shut in until proficient?
you won't become proficient being a shut in, unless you have a lot of motivation
>>
>>56623234
So it's not going to run in debug mode? it's going to run like it's supposed to?
>>
>>56623252
pic
>>56623250
I just want to make st to point to an array that changes dimension
>>
>>56623295

You've been at this for about 2-3 days. What does this thing do (or rather, what SHOULD it do?)
>>
>>56619194
51 seconds I'll never get back. Fuck you
>>
>>56623292

Eh, it would depend if you compiled it as debug or release, but as I recall, it'll always default to debug in the filename if you're using the default debug key for signing it. I don't believe in application signing, so I always use the debug key.
>>
>>56623284
I realize that.

My local community college offers an associate program or a certificate program that shows that "this guy took a class."

Do employers usually skip those with "certificates" and go for people with degrees and or portfolios?
>>
A ruby script periodically checks the network for new devices using nmap (wip).
#!/usr/bin/ruby
# -*- encoding: utf-8 -*-

puts "\ncheck_lan.rb"

require 'nmap/program'
require 'nmap/xml'
require 'timers'

DELAY = 60 * 10

$timers = Timers::Group.new
$devices = Hash.new

def silence
stderr = $stderr.clone
stdout = $stdout.clone
$stdout.reopen(File.new('/dev/null', 'w'))
$stderr.reopen(File.new('/dev/null', 'w'))
yield
$stdout.reopen(stdout)
$stderr.reopen(stderr)
end

def check(subnet, xml)
Nmap::Program.scan do |nmap|
nmap.syn_scan = true
nmap.service_scan = true
nmap.os_fingerprint = true
nmap.xml = xml
nmap.targets = subnet
end
end

def add_host(host)
unless $devices.has_key?(host.ip)
puts "New device: IP:[#{host.ip}] MAC:[#{host.mac}]"
host.each_port do |port|
puts " #{port.number}/#{port.protocol}\t#{port.state}\t#{port.service}"
end
end
$devices[host.ip] = host.end_time
end

def read(xml)
count = 0
Nmap::XML.new(xml) do |xml|
xml.each_host do |host|
add_host(host)
count += 1
end
end
count
end

time = 0

# Check subnet 192.168.0.* for ips and ports
$timers.now_and_every(DELAY) do |interval|
puts "Running Nmap"

xml = "scan.xml"
silence { check('192.168.0.*', xml) }
hosts = read(xml)

time = (Time.now + DELAY).strftime("%I:%M:%S %p")
puts "#{hosts} hosts were found. Next LAN check at #{time}"
end

# Check each ip that was found on a 10 second interval. Is the device up and latency

loop { $timers.wait }
>>
I'm being forced to use javascript and I'm already looking up how to reimplement standard C string functions in javascript.

I hate javascript so fucking much.
>>
>>56623355
What exactly is the difference between debug and release for clover? if there is any.
>>
>>56623330
https://en.wikipedia.org/wiki/Conway%27s_game_of_life

but, I want it so that when I resize a window, the program takes notice
st is supposed to point to the ever changing array of y*x dimensions

cpst (copy state), creates a new array with ny by nx dimensions, and copies enough information from st to nst (new state), and makes st then point the the calloc
>>
>>56623412
*ever changing array of whatever dimensions
>>
>>56623363
I forgot to set expandtab and retab :s
>>
>>56619676
good habit to get into (and maybe this is preference, but I still think it looks better), is to

1. keep a space between your if and the first bracket, then a space between the closing bracket and opening brace.
e.g.
if(){
//...
}

becomes
if () {
//...
}


2. get in the habit to ALWAYS use braces in single-statement conditionals and loops. Write code for the next guy who has to maintain your code and change things. It's just a pain in the ass to go back and add braces.
e.g.
if ()
//statment
else
//statement

becomes,
if () {
//statement
} else {
// statement
}
>>
>>56623412
Why do you have to be so cryptic? Why can't you just name the function CopyState?
>>
File: hereyougo.gif (88KB, 10000x10000px) Image search: [Google]
hereyougo.gif
88KB, 10000x10000px
>>56619068
Just finished watching thenewboston c++ tutorials on youtube. Decided to try and make my first program, tell me what you guys think.
http://pastebin.com/L75CYxHA
>>
>>56623481
can you help me?

why strrev and not stringreverse()
why memcpy and not MemoryCopy
>>
>>56623363
Talk about over-doing it.
#!/bin/bash

old=""

while true; do
new=$(ip neigh)
comm -13 <(echo "$old") <(echo "$new")
old="$new"

sleep 1
done
>>
Does any other (compiled) language have a HTTP lib as nice as requests?
>>
>>56623369
I can feel you man, I actually enjoyed working with strings in C. Also, you should start looking into regex.
>tfw hate a bit php
>start implementing some php functions (str_replace) in Sepples
>>
>>56623412

Best of luck with your debugging efforts.
>>
>>56623076
That's a tradition owing from way back when harddrives were small and you wanted your source code to not take up unnecessarily much space. It does not apply anymore.

Now you're just making your code a little faster to type and a lot harder to read.
>>
Teaching myself Java. Can someone tell me why I'm not able to get the value from one method's variable and store it in a different method's variable? I'm getting no syntax errors but it's only returning '0', the default value of
Calories
, when I print out the value of oCal.

public class Manual_Input {
double Calories = 0; //Initial value for variable

public void m() {
Scanner input = new Scanner(System.in);
System.out.print("Please enter the Calories per serving: ");
Calories += input.nextDouble(); //Variable gets new value
}
}

public class Get_Totals {

public void t() {
Manual_Input man = new Manual_Input();
double oCal = man.Calories; //Should store previous value in new variable but doesn't
}
}
>>
>>56623527
ip neigh pulls from the arp cache. Also doesn't check that the machine in question is up
>>
What is the best way to start into machine learning?

Is there a recommended book/article on neural network implementation?
>>
>>56623385

Debug and release in general mean:

Debug - Has debugging information in the binary, compiled with less optimization flags

Release - Has no debugging information present, useless sections of the binary are stripped for minimal binary size, as many optimization flags as possible are set to maximize performance.

But what all each of these detail can vary based on the build system. I am not intimately familiar enough with Android Studio to know all of the little details.
>>
>>56623595
You're not calling m.
>>
>>56623076
fuck, this took me a while... it's difficult to debug, because your program keeps corrupting many things, I guess
mate, you aren't defining st as a2D array, but as a pointer to pointer. also, you keep calloc'ing ptr in cpst(), but you then you free st...
also, you defined x and y twice, as global vars and inside main()
also, instead of
>st[rand() % y][rand() % x] = 1;
do something like
    int a, b; 
for (;n--;)
a = rand() % y;
b = rand() % x;
st[a][b] = 1;

in short, fix your shit (and learn how to use gdb, if you don't know already)

>>56623250
>yw
for >>56623221 ...
>>
>>56621961

>game engine

lol
>>
>>56623641
Wouldn't that just repeat the steps in m()? I don't want to ask for the Calories a second time.
>>
>>56623701
Well, you haven't called it on that instance, at least.
>>
so, I'm trying to make a multiplatform map app (android, web, ios/desktop if possible) from linux...
tried C#/.net with monodevelop/vscode and I just can't find a fucking lib that works. can someone help me? :/

>>56623665
btw, my C is rusty as fuck, so you probably have even more problems with your code. but I think the crashes come from the fact that you keep allocating and freeing the wrong things.
>>
>>56623514

newboston is for faggot plebs
>>
>>56623595
i don't see where you're invoking the function "m"
>>
File: samelevel.jpg (58KB, 960x720px) Image search: [Google]
samelevel.jpg
58KB, 960x720px
>>56623720
But what about my program, is it any good?
>>
>>56623514
>http://pastebin.com/L75CYxHA

>two headers containing Windows APIs

DISCARDED
>>
>>56623701
I call it in an earlier different class. I don't understand why it won't transfer the value to the other object's variable.
>>
>>56623739
Meant for >>56623707
>>
>>56623712
>so, I'm trying to make a multiplatform map app (android, web, ios/desktop if possible) from linux...
electron :^)
>>
>>56623736
lisp/scheme's higher level than human language
>>
>>56623739
It's a different object.
>>
>>56623736
>C++ High level language
>Computer hardware is language
wew lad
>>
>>56623688
?
>>
>>56623736

Machine language is a step above binary, is it not?
>>
>>56623609
If the machine isn't up, then the entry will go stale, but yes, you won't get the most timely updates.
>>
>>56623739
Can you give an example?

You're creating a new Manual_Input object inside of Get_Totals.t(); that Manual_Input won't have the same Calories as the other Manual_Input object. If in another part of the program you're doing:

manualInput = new Manual_Input();
manualInput.m();
totals = Get_Totals();
totals.t();


totals won't know about the manualInput you created because it's creating a brand new man Manual_Input object.
>>
>>56623789
Binary is not a language. It's a number base.
Also, machine code IS represented in binary and is probably what you're thinking of.

>>56623736
>Putting natural languages in the same list as machine languages
>No microcode
>No transistor logic
>>
>>56623369

I haven't seen a worse lingua franca language than Javascript. Like how do you even get to the point where people write one function left-pad libraries with that shit? Even C has a better standard library than Javascript.

At least people built good stuff on top of C that are still being used to this day. Hoping ES6 fixes a lot of this or better yet, Webassembly gets finalized and Javascript can die.

>>56623575

String handling is still not consistent with some functions NUL terminating your strings for you and some that don't, along with silent truncation and security with buffer overflows. Good performance and consistent naming is the only two good parts about C's string library.

You need at least Java-level string handling for it to be at least good IMO, but I would rather have Python or Perl string handling if possible.
>>
>>56620692
emacs...
>>
>>56623845
>some functions NUL terminating your strings for you and some that don't
Every C function null terminates the string, except for the mem* functions (technically not string function, but are in string.h) and strncpy.
strncpy is the exception because of what it's designed for. It's for writing non-null terminated strings and copying the string into the middle of another string.
Some people confuse it for a "safe" strcpy, which it isn't.
>>
>>56623800
What you posted is really useful there's no doubt about that but I'm also particularly interested in nmap's estimated uptime, the port scanning component and the os detection functionality
>>
>>56623665
st can't be defined because if it is, it will have set dimensions
the point it that st points to an array which has array of ints (either 1 or 0, I could've _Bool but int is faster to type and looks prettier)

I free st before making it point somewhere else

x and y in main are supposed to overshadow the global ones

>st[rand...
thats just style
>>
>>56623814
That's essentially what I'm doing, more or less. I'd give you more info but I'm on my phone and its a little hard to navigate.
How can I then use the value of a variable in a previously executed method as the value for a variable within a later method?
>>
>>56623712
He's allocating ptr and then assigning ptr to st, so he frees the allocated memory from one call of cpst in the next call to cpst. That should be fine.

Except i'm not seeing that he allocates st for the first time. That means the first call to cpst tries to free garbage, which is bad.
>>
>>56623940
so
st = malloc(0);

before the while loop?
>>
>>56623890

strcpy_s is safe :^)
>>
>>56623968
Yeah, i guess.
>>
>>56623940
Global and static variables are initialised to 0.
Also, calling free(NULL) is defined to be a noop.
So the first time he frees st is valid (assuming NULL is represented as 0).
>>
>>56623994
except that it still segfaults
>>
>>56623992
>Micromeme pushes for Annex K
>Have no intention of supporting it fully, let alone supporting C11
I really hope they remove it, or at least deprecate it in C2X.
>>
>>56621700
fortran I think
>>
>>56624000
nice trips
so if this is true, what's the problem? where is anon's program crashing, and why?

btw, I just noticed:
>int nst[y][x];
then
>memcpy(st,nst, sizeof nst);

>sizeof nst
isn't this wrong?
>>
>>56624054
nst is the same size as st in this case
>>
sizeof char
>>
>>56623935
Google search -- 'what is the difference between a Java class and object'.

A class defines a kind of 'template' for objects -- the class itself, however, does not hold data unless it is static. If you create an instance of that class, it's an object, with its own variables, memory location, etc. If you create a second object (man = new Manual_Input()), it refers to a different object, with a different memory address, and different variables, than the other.

So if you do:
Manual_Input man1 = new Manual_Input();
Manual_Input man2 = new Manual_Input();

man1 and man2 have their own set of variables (Calories, here) that are unrelated to each other; changing Calories in man1 won't affect man2.
Or you need to pass in the reference of the object you're using, so it knows which object's calories to use:
public class Manual_Input {
double Calories = 0; //Initial value for variable

public void m() {
Scanner input = new Scanner(System.in);
System.out.print("Please enter the Calories per serving: ");
Calories += input.nextDouble(); //Variable gets new value
}
}

public class Get_Totals {
public void t(Manual_Input man) {
double oCal = man.Calories; //Should store previous value in new variable but doesn't
}
}

Manual_Input man = new Manual_Input();
man.m();
Get_Totals totals = new Get_Totals();
totals.t(man);


Another solution could be to do things statically, which would mean you don't need to make an object reference:
public class Manual_Input {
static double Calories = 0;

public static void m() {
Scanner input = new Scanner(System.in);
System.out.print("Please enter the Calories per serving: ");
Calories += input.nextDouble(); //Variable gets new value
}
}

public class Get_Totals {

public static void t() {
double oCal = Manual_Input.Calories;
}
}

Manual_Input.m();
Get_Totals.t();
>>
>>56624054
At a glance, he has all sorts of problems with his code, with the main one being
int **ptr = calloc(ny, sizeof(int)*nx);
which is NOT how you allocate a 2D array.
2D arrays are just a hassle and using a 1D array + stride is a much better idea.
I really can't be bothered trying to read through his disgusting code to find all of the details though.

>>sizeof nst
>isn't this wrong?
No.
>>
>>56624085
wtf, so c can't even into 2d arrays
I have to use a hack to bypass
>>
Virtual machine Linux or just straight up dual booth? Im learning C and just how to use BASH and Linux in general
>>
>>56624018
Fuck.
I'm gonna see if i can't get this thing to compile.
>>
netflix isn't working on my linux and i need some /dpt/ related youtube channels, got any?
>>
>>56624129
packer -S google-chrome
>>
>>56624105
Dual boot
>>
>>56624105
balls deep
>>
>>56624105
wipe the drive
install gentoo
become the linux
infuse yourself into the code
>>
>>56624099
It can, but it's not worth the effort of doing, especially since it's not statically sized.

Here is how you allocate a 2D array using malloc in C:
// 5 x 10 array
int (*arr1)[10] = malloc(sizeof *arr1 * 5);
arr1[4][9] = 10;
//or
int (*arr2)[5][10] = malloc(sizeof *arr2);
(*arr2)[4][9] = 10;


However, his array is variable sized, so it needs to know the size of the dimensions at the declaration:
int x = 5;
int y = 10;

// 5 x 10 array
int (*arr1)[y] = malloc(sizeof *arr1 * x);
arr1[4][9] = 10;
//or
int (*arr2)[x][y] = malloc(sizeof *arr2);
(*arr2)[4][9] = 10;


However, you cannot have a global/static variable be variably sized, because its size is not known at compile time. You also cannot return a pointer to a variable sized array from a function (but you can pass it in as an argument).

I can sort of think how you could change his program to use malloced 2D arrays like this, but it would require basically changing his entire program, which I cannot be fucked doing.
>>
File: neopepe.gif (607KB, 800x792px) Image search: [Google]
neopepe.gif
607KB, 800x792px
>>56624206
>become the linux
>>
>>56623665
>>56623712
>>56624054
OK, so all my guesses are incorrect and bullshit
clearly, I never learned C properly...
I've been debugging the program, and I still don't know where the fuck it crashes, lol
>>
>>56624223
so, I can't malloc some variable sized array
and make a global point to it?
>>
>>56624083
Went the static way. Seems to be working now. Thanks a bunch man.
>>
>>56624243
dumb frogposter
>>
>>56624030

s-shut up!
>>
>>56624273
With a 1D array, it's just pointer + length.
With a 2D array, (unless the y dimension is static) you cannot without losing type information.

Really, using a 1D array with a size (x) and stride (y) is a much better idea.
>>
>>56624309
ok, I'll go your way
>>
>>56624273
you could allocate a one dimensional array, like you've done, an access it by
arr[i*x + j]

instead of
arr[i][j]
>>
>>56623825
Binary is an alphabet. Let's get pedantic!
>>
>>56623825
actually 2 is a number base, not binary. you dont say something is base binary
>>
is there a command to show the most used files on a certain drive
>>
>>56624369
>>56624401
Fine, it's a numerical system of radix 2.
You know what I meant.
>>
New thread:
>>56624512
>>56624512
>>56624512
>>
>>56622501
>>56622377
biggest meme because
>muh functions!!!! OBJECT ORIENTED PROGRAMMING IS A MEME LMAO USE ONLY FUNCTIONS!!!
>>
>>56624335

Basically, see https://gustedt.wordpress.com/2014/09/08/dont-use-fake-matrices/ for rationale.
Thread posts: 336
Thread images: 24


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