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

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

Thread replies: 255
Thread images: 21
File: lelouchdiesattheend.jpg (123 KB, 1280x720) Image search: [Google]
lelouchdiesattheend.jpg
123 KB, 1280x720
old thread >>54206286

what are you working on /dpt/?
>>
>>54211104
First for traps!
>>
>>54211116
fffffffuck offffffffff
>>
>>54211104
No Nichijou?
>>
>>54211128
Three times in a row I thought I'd change it around a bit
>>
File: 10.jpg (76 KB, 619x704) Image search: [Google]
10.jpg
76 KB, 619x704
>>54211104
>>
File: sqlitebrowser.png (114 KB, 725x641) Image search: [Google]
sqlitebrowser.png
114 KB, 725x641
I'm recompiling a program written in C++ that I modified. It's on Macintosh.

It requires the qt library, and the sqlite library, which the makefile recommends installing by homebrew.

The problem is, whenever I compile it, the compiled version looks for the homebrew installation of those two libraries, instead of bundling them inside the application.

How do I compile this thing for release so the user doesn't have to manually install the two libs via homebrew? (The application released by the main devs does not require any user-action, it's all bundled).

Pic related
>>
>>54211104
what's the difference between a programmer and a code monkey?
honestly...
>>
>>54211163
A programmer has a conscience
>>
>>54211163
Code monkeys have no idea what they're doing and can't write library code.
99% of their code output is because their job requires it and their code consists entirely of glue code that uses other people's apis and libraries.

They're the replaceable, disposable workforce that routinely gets outsourced to pajeets.
>>
>>54211208
/g/ users can talk about their notions of what a programmer is, or is not, but they can't actually answer programming questions
>>
>>54211151
static linking
>>
>>54211222
trips confirmed
still wishing for that single page java cheat sheet
>>
>>54211222
I don't see any programming questions presented nignoramus
>>
>>54211233
>single page java cheat sheet

Unpossible.
>>
>>54211225
I'll be looking into this. Pretty much a noob, never had to deal with libraries on Mac before. On linux I just throw the -static flag into my clang make routine and it just werks.
>>
>>54211280
What if you print in size 1 font?
>>
>>54211301
use a magnifying glass and you can get it around 10 pages like the opencl cheatsheet
>>
>>54211287
>never had to deal with libraries on Mac before. On linux I just throw the -static flag into my clang make routine and it just werks.

Same deal on OS X dummy. Worst case, you can link against copies of the libs in an include dir that you distribute with the application (app is a container).
>>
>>54211151
this explains everything
https://www.akkadia.org/drepper/dsohowto.pdf
>>
>>54211225
apparently qmake automatically generates a "bundle" which is like static linking on OSX.

Still, the app won't work on a clean machine until the dependencies qt and sqlite are installed via homebrew
>>
>>54211301
>>54211280
>>54211319
not the whole oracle documentation...
just the most common stuff, basic reference
>>
>>54211383
whats a homebrew?
>>
>>54211387
>just the most common stuff, basic reference

Still not possible, lad.
>>
>>54211398
a black man in israel
>>
>>54211383
basically there's no Frameworks or Resources folders inside the .app package
>>
How do I register an input on MIPS? I have to show a menu(of 8 options) and receive which number the user pressed. I tried the following:

li $v0,8
la $a0, op
li $a1, 3
move $t0,$a0
syscall

but it doesn't seem to work. Can someone help me on this one?

Notes:
I use a branch after that, like

beq $t0, 1, op1 (op1 is where the first option of the menu is executed)

also, op is declared as:

.data
op: .space 3
>>
>>54211419
>>54211383
All the answers you need have already been posted. Time to review and research.
>>
>>54211435

I haven't done assembly in years but I did a frogger program back then that you moved by tapping the W and R keys

.ktext 0x80000180

move $k1, $at
sw $a0, save0
sw $a1, save1

mfc0 $k0, $13

srl $a0, $k0, 2
andi $a0, $a0, 0xf #extract exception code field

bnez $a0, done #if the exception code is not a 0 then we don't care so just return to the line


done:
mfc0 $k0, $14 #bump EPC
addiu $k0, $k0,4# do not re execute code that set off the exception

mtc0 $k0, $14 #EPC

mtc0 $0, $13 #clear the cause register for new exceptions

mfc0 $k0, $12 # fix status register for new exceptions
andi $k0, 0xfffd #clear EXL bit
ori $k0, 0x1 #enable interrupts
mtc0 $k0, $12

lw $a0, save0 #restore registers that were used
lw $a1, save1
move $at, $k1

eret

.kdata
save0: .word 0#memory block to save a0 and 1 memory points
save1: .word 0
>>
>>54211509
That's all of it? I don't know where you're getting the imput there (I just know how to do it through syscall)
>>
>>54211626

some more on the file. there is some more shit for running the right command on the right keys if you want those.

moveleft:
addi $sp, $sp, -4
sw $ra, 0($sp)

la $t4, X #constant x
lw $t7, 0($t4) #load pointer x into t7 to be checked
beq $t7, 0, win # if t7 is a at 0 then player has won

li $a0, -1
li $a1, 0
jal blit_frog
jal emitworld


addi $sp, $sp, 4
lw $ra, 0($sp)
jr $ra

moveright:
addi $sp, $sp, -4
sw $ra, 0($sp)


la $t4, X #constant x
lw $t7, ($t4) #load pointer x into t7 to be checked
beq $t7, 8, win # if t7 is a at 0 then player has won

li $a0, 1
li $a1, 0
jal blit_frog
jal emitworld


addi $sp, $sp, 4
lw $ra, 0($sp)
jr $ra
win:

li $v0, 'w'
addi $sp, $sp, 4
lw $ra, 0($sp)
jr $ra


#UNTESTED FUNCTIONS------------------------------------------------------------------

teechar:
addi $sp, $sp, -4
sw $ra, 0($sp)

la $t0, 0xffff0004 #load the character and then dereference and send to $a0
lb $a0, ($t0)
jal emitchar #call emit character

addi $sp, $sp, 4
lw $ra, 0($sp)
jr $ra

frogger:
addi $sp, $sp, -4
sw $ra, 0($sp)

jal teechar
jal update_frog

bne $v0, 0, exit # if v0 is not 0 then save to the condition global variable and then return v0


exit:
la $t0, condition
lw $t1, ($t0)
sw $t1, ($v0) #store the value in v0 to t1

addi $sp, $sp, 4
lw $ra, 0($sp)
jr $ra


>>
what's a good, quick project to learn C# ?
>>
code monkey == programmer = false
programmer == software engineer = _______?
>>
>>54211705

Fibonacci using a windows form?
>>
>>54211705

kernel
>>
>>54211706
pajeet pls go
>>
>>54211705
create an automated way to "install gentoo"
>>
>>54211705
consle emulator (GB is my recommendation if you've never done one, if you dont want the GB then SNES/NES are on par, sega genesis etc, all above that and then you have a bit more difficult to emulate processors and co-processors)
>>
>>54211705
forgot to mention, I already know (some) java, but I learned it like 10 years ago... so, no generics and other features
also, I use linux, so it'd have to exclude windows shit, I suppose

>>54211740
see comment above

>>54211752
nice, I'm gonna port my kernel from java to C#

>>54211783
not a bad idea.. I already have some scripts that install ubuntu pseudo-roots in "cloud" servers
>>
what languages are behind 4chan.org?
>>
>>54211694
None of those get the input, though
>>
True or false: switch case is the fastest implementation of a table of functions.
>>
>>54211813
>nice, I'm gonna port my kernel from java to C#

Should be straighforward. Best of luck.
>>
>>54211838
https://github.com/shiroyuki/Yotsuba
>>
>>54211838
A 20 year old hackjob piecemealed mess written in PHP.
>>
>>54211803
>quick project
>consle emulator
wat
>>
>>54211813

do a command line calculator
>>
>>54211104
RIP rurushu
>>
>>54211855

oh the interrupt handler I first posted grabs a char that the user presses or at least it should if my memory is correct.
>>
>>54211813
Create an RPN interpreter.
>>
>>54211942
>>54211999
I've never made a calculator... I guess I'll do this. thanks anons.

I should do this in many langs, just to learn some shit. (don't know much about UI stuff...)
>>
trying to build an app to folder dump on 4chan
bot sure what angle to attack first. catching the reply box, bypassing captcha, selecting images in order... ffs banging head on desk now
>>
>>54212079
Calculators are easy, writing the interpreter and having it function with arbitrary input is the fun part.
>>
>>54212181
you can't do it, fyi
>>
>>54212181
If you can't do that then don't even bother.
>>
>>54212181
Parse the JSON api and curl get the images, dummy.
>>
>>54212211
what the fuck did you just say to me?
try it in engrish plox
>>
>>54212148

If you are still here I can send you a link
>>
>>54212222
Just kill yourself.
>>
>>54212211
He's POSTING images, not downloading images

>>54212222
Even though he misunderstood what you're trying to do, if you don't know what he's saying, you're not going to get anywhere
>>
>>54212181
You'll need a 4chan pass first of all
>>
>>54212363
you should be asking what are the pros and cons are using an array rather than a vector
>>
>array
+ less overhead
- static size (unless you yourself resize of course)
>vector
+ dynamic size
+ some handy functions already written for you if you're using C++
- overhead

not much to it friendo
>>
Why is a stack limited in size?
>>
>>54212483
what? It's not, unless you require it to be for some reason.
>>
Rate my hex converter!
char *dec2hex(int num)
{
unsigned len = uintlen(num);
char *str = (char *) malloc(sizeof(char) * len);
int i = 0;
while (num > 0)
{
unsigned digit = num % 16;
if (digit > 9)
str[i++] = digit - 10 + 'A';
else
str[i++] = digit + '0';
num /= 16;
}
str[i] = '\0';
strrev(str);
return str;
}
>>
>>54212483

theoretically stacks shouldn't be limited in size.

even real world constraints shouldn't cause stack sizes to be a problem.
>>
>>54211104
How do I sort a 2D C++ array of strings by the first element in each column? The first element is a name, and I want the data to be sorted by name and then printed in order.
>>
>>54212585
memory constraints?
>>
>>54212576
have the user pass a buffer instead
>>
>>54212679
just like how you'd sort anything else friendo
>>
>>54212679

you can do a bubble sort /insertion/selection if you're lazy and don't mind the time complexity on average and best cases.

otherwise merge sort.
>>
>>54212761
I want to use qsort() because it's in the library, but all the examples I find are for integers.
>>
>>54212816
strings are an array of chars, chars are numbers encoded with letters. Figure it out
>>
>>54212927
I knew they were character arrays, but how exactly is alphabetical sorting done? If I just compare strings instead of the first letter, won't that give me the wrong answer?
>>
>>54212985
Have some intuition m8. A char is just a number. take the first char of each string and sort based on that. On all the strings of the same first char, sort the second char and so on until it's sorted.
>>
>>54212985

http://www.cplusplus.com/reference/string/string/compare/

just use fucking string compare. if you're concerned about there being a difference between char comparison and stirng comparison you can use the position parts to make it a char comparison.
>>
>>54211104
finishing this last lab for my Data Structures and Algorithms course.

We use Java.
God, I hate Java so much... this language is so fucking annoying...
>>
>>54213213
why do you find it annoying specifically?
>>
>>54213138
I found an example on GitHub. I'm going to use it.
>>
>>54213311
typical shitty programmer can't think of a solution to a simple problem even when spoon fed

Please leave
>>
>>54213335
How about no? I'm just learning C++, you elitist scumbag.
>>
>>54212748
How is the user supposed to know how much space to allocate?
>>
>>54213348
It's not a lack of C++ knowledge, it's a lack of programming intuition
>>
>>54213420
I can do this shit in Java all day, but I'm clueless in this new language. Do you even have a CS degree? No one on r/eddit is this rude.
>>
>>54211104
Who the fuck is lelouch?
>>
>>54213245
mainly the dumbass over-OOPing everything.

I always wind up coming back to this language for one reason or other, and 99% of the things that stop my program from running are based around their inane conventions, like main() being a static method inside a class.

I'm also not a huge fan of the idea that you don't have to clean up your pointers.

Passing EVERYTHING by reference is also annoying.

Basically... why is Java Java and not Mobile C++?

Usually, usually, it's tiny shit, but it's so fucking annoying.
This time, in particular, it's the main() thing again. I sat there a few minutes asking myself "Why the fuck is it giving me this error again..? I know I had to do something stupid last time to get it to stop..."
After pondering for a few more minutes, it dawned on me... oh yeah... in this language, the program ITSELF is a class...

Needing to make helper functions just to make main() work is dumb as shit. Worse is that you always have to remember to make an instance of whatever class HOLDS main().

Really just little things. Lots of lots of little, inane nuances about this language piss me off.
If it was 20% less like Java and 20% MORE like C/C++, I'd probably herald it as the best language around, but it's not, and I won't.
>>
>>54213500
That just confirms Java is for babbys

CE/CS

Yeah well reddit is a bunch of cucks

>>54213515
google is good for that sort of thing
>>
is codeblocks /dpt/-approved?
>>
>>54213564
are you seriously looking for something approved by faggots on 4chan?
>>
>>54213564
Codeblocks is a piece of shit. VS on windows, Xcode on mac, Emacs on Linux, Sublime text/Atom on anything else.
>>
>>54213564
Absolute shit

>>54213591
Vim is good too
What else is there? If anything can run Sublime text or Atom, it sure as hell can run Vim or Emacs.
>>
>>54213591

I don't like having to memorize 300 shortcuts, imo Emacs is shit.
>>
>>54213564

I'm a Visual Studio baby but I liked codeblocks once I got the fucking Debugger to work properly.
>>
>>54213564
I think it's pretty good.

>>54213591
>Codeblocks is a piece of shit
>VS on windows
u wot m8?
Dude, you best be trollin' faggit. I can accept that Code::Blocks isn't perfect. First and foremost, it's slow to load.
But Ho Lee Schitt, Visual Studio?! Fucking VISUAL STUDIO? Are you... like... one of those people that needs to wear a helmet all day?

I don't know how to put it nicer, but you can't possibly be that mentally retarded to think VISUAL FUCKING STUDIO is anything other than blood-and-shit-drenched half-decayed cocks.
Like, VS has NOTHING going for it. I reiterate, "Ho Lee Schitt".

Please, for the love of God and all things holy, PLEASE, I BEG YOU, tell me... that you were joking.
Damn, I'm frightened, now Anon. Please don't make me sleep with a nightlight tonight...
>>
>>54213667
>implying to have to learn every single shortcut

There's a toolbar in Emacs that's hella useful. It's like a GUI.
>>
>>54213760

what would you recommend for Windows OS in terms of an IDE anon?
>>
>>54213760
Dude are you retarded? VS has so many useful features it's nice when you're doing big projects. Codeblocks can't even live parse. What a shitty IDE. How new are you?
>>
why cant i just pass all the text inside a file to a program through shell?
>>
>>54213841

why not just open the file using the program itself?

what language are you using where you can't open a file?
>>
>>54213841
you're asking the wrong question
you mean to ask "How can I ..."

cat file | program
>>
>>54213841
you can using redirection. you'd still need to use input streams
>>
>>54213799
> for Windows OS in terms of an IDE
visual studio. Don't ask him any questions, he's obviously retarded.
>>
>>54213799
If not Code::Blocks, then why not Eclipse or something?
Could also use NetBeans. Although I'm not a fan of Java, I've used it a lot for Java, and it's not a bad interface.
Hell, even Dev-C++ is better than VS

>>54213802
VS has the worst UI I've ever seen for C/C++ development tools. I'd rather write using the VIM for Windows I downloaded.

I had to use VS for Visual BASIC for a class once. The environment is so fucking annoying. Also, when using C/C++, it adds dumbass shit to the file dependencies I don't want.

On a side note, VB has dogshit syntax... and trying to edit the files properly is a complete nightmare because of how VS puts the project together.

But, I avoid VS like the fucking plague.
>>
>>54213841
*needs context*
Have you tried cat?
>>
>>54213974
When was the last time you used VS lel
>>
>>54212222
You don't belong here if you can't understand what anon said
>>
>>54213873
>>54213883
>>54213886
>>54213995

i made a program that prints out argv[1] in reversed order
Aids -> sdiA

should i instead just take argv1 as a file name/path?
>>
>>54214053
yes
>>
>>54214053
Yes but you'd need to handle reading the file in the program as well.
>>
>>54214071
>>54214082

alright thanks goys
>>
hay guise
du yu prograham n:

Alice?
Blockly?
Scratch?
others like these?
>>
>>54214010
last year maybe?

>>54214053
how bout you make the program print it out AND THEN return that value, so you can run whatever program you need it to input into with the output of the reverser as a variable?

reverse AIDS | thatProgram
>>
>>54214129
what file do i have to print to, to make it count as an arg?
>>
>>54214125
Those are scripting languages designed for schoolchildren.
>>
>>54214125
awk and sed > everything else
>>
>>54214147
you shouldn't need to print it to any file at all.

it would be the equivalent of
cat someFile.txt | grep somethingInText
>>
>>54214233
is the contents of cat passed as argv1 there?
i try to do like that but its not working and im not good aneough with linux to figure out why
>>
>>54214125
you must be 18 or older to visit this website
>>
>be me
>35 yrs old
>was trucker, but now need to change careers
>most computer literate person i know
>but never coded, no CS classes
>i'm a semi-power user i guess
>but i never loonix, or iShill
question is: can i learn to code well enough to start working in the field? or what is the top age to begin learning coding?
>thinking Java since there's more demand for that in my area.
>>
>>54214255
Hmmm.... it should be, but desu I really don't use Linux or CLI that often. lemme build something real quick and try it.
>>
>>54214277
tbqh if you have no degree or understanding of higther maths, your job will be outsourced to india

try enrolling in a communtiy college
>>
>>54214277
You've got a long road ahead of you m8

Before anyone else says anything, start with c++ for god sakes please. It will tell you if you're good enough to be a decent programmer.

Pick a project
https://better-dpt-roll.github.io/
go here
http://www.cplusplus.com/doc/tutorial/
reference this
https://github.com/isocpp
>>
>>54214277
there is no top age
there will be a lot of competition since you don't have a degree
learn java, learn sysadmin stuff too for easy IT positions to start off with
read that java book that's blue and says Java in papyrus or whatever

also this >>54214304
>>
>>54214306
shit advice
no one should ever start programming like this
>>
>35 yr old trucker here:

to all of you:
how old were you when you wrote your 1st bit of code?
>>
>>54214324
Why
>>
>>54214358
22 probably
>>
>>54214358
Spent a couple weeks learning JS at like 8/9
Shitty GUI programming with WinForms with VB at 13
Started learning C and actually programming at 15 -- would consider this my first real real programming
>>
>>54214358
13 with ruby scripts and shit
>>
>>54214413
tfw i'm older than ruby and java
>>
>>54214358
Either some silly bash scripts or a bit of Lua for a WoW addon in my late teens.
>>
>>54214401
>learning JS at like 8/9
I wanted to say "underage b&", but then I remembered that JavaScript is only two years younger than me.
>>
>>54213393
Make a constant for that. e.g. for 32-bit integers the longest hexidecimal int is going to be 8 digits, so "#define MAX_HEX_INT 9". Saving like 3 "needless" bytes in your buffer by computing the width beforehand is actually a net-loss in terms of performance; those byte are completely negligible and the malloc() would probably allocate them anyways because of alignment.
>>
>>54214358

First started programming at 16. Can't really remember if I've done anything much before that. Might have tried playing around with batch scripts, and I think in middle school, I'd used something called squeak to make a shitty little game, but I don't think I really wrote any code before I started learning C++ at 16.
>>
>>54211146
>>>facebook.in
>>
File: cvhv7S5FEOD6f5DvfsQfWQYn.png (31 KB, 815x635) Image search: [Google]
cvhv7S5FEOD6f5DvfsQfWQYn.png
31 KB, 815x635
what would be a good structural dp for this? im thinking either facade, decorator or composite
>>
>>54214485
>>54214306
aha told you to learn c++ first.

fuck you >>54214324
>>
>>54214255
ok, for that it should be.
but, actually, i'm not sure why it's not working
>>
File: lol.jpg (9 KB, 289x175) Image search: [Google]
lol.jpg
9 KB, 289x175
>>54214501
>good design pattern
>>
trucker here

i just remembered that in 7th grade, toward the end of the school year we did a week or two in hypercard. and something else (maybe basic?) where we had to move a triangle called a turtle.

>>54214500
huh?
>>
>>54214277
>can i learn to code well enough to start working in the field?
Learn programming require time, effort and a clear idea of what do you want to do. A CS graduate spent 5 years studying just for pursuing an entry level job. Don't expect less than that, also you need some math background. That if you want to be employable, else you can try being freelancer.

>or what is the top age to begin learning coding?
There is not a top age. All depends on how motivated are you for learning new things. Don't learn programming because you want a job, learn programming if you want/like to solve problems than can be solved through code.
>>
>>54214527
Shitty facebook-tier meme about Indian programming language
>>
>>54214502
"Learning" C++ by picking a random challenge from dpt roll and looking at a shitty tutorial and the standard is shit
>>
>>54214501
What the hell are you making? Diagrams like that are usually a waste of time and cause you to over-engineer your problem and spend too long thinking about how to model your shitty objects rather than just programming your thing.
>>
>>54213564
it's shit if you use it on windows
there are better alternatives on linux
>>
>>54214585
its a uni assignment where we have been given someone's n-body solar system simulator from the previous assignment we did and we have to implement a structural design pattern into it
>>
>>54213760
hello_reddit
>>
>>54214358
My first code, not even a program, at 18. My first program for college at 19. My first noob project at 21. And my first serious project at 25.
>>
>>54214609
Redditors are worse than I thought
>>
>>54214233
grep [OPTIONS] PATTERN [FILE...]
>>
>>54214560
Ok then throw a book in there on top, whatever.
http://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list
>>
>>54214595
I'm sorry for you bud.
I think composite sounds like the only thing that would work.
Fuck design patterns man, these buzzwords are so complicated when you could design your objects as just data and it would be super simple.
>>
>>54214358
around 11
dad showed me C on his solaris box
>>
>>54214662
Here's what I gather
facade -> an interface
decorator -> a catamorphism
composite -> tree structure
>>
>>54214631
I don't use Reddit.
>>
>>54214277
>now need to change careers

I'm on the same boat.
>>
>>54214745
welcome aboard!
>>
>>54214757
i dont have a career yet, can i join?
>>
>>54214803
grab a life jacket and come on
>>
>>54214053
read from stdin, reverse input line by line. argv1 should optionally be a filename, which will be processed instead of stdin if present
>>
>>54214585

No lie. But you can go far with such things. It's what impresses the non-IT/programmer managers. Never mind the coding team worked on that *one* thing for five years which was some tiered CRUD app with 237 interfaces and they didn't have anything to show for it other than shit that wouldn't make it through a unit test - at least the white-board and ppt looked fancy. We'll just blame the failure on the contractors we hired. Meanwhile, Whiteboardy McHugechart gets a promotion and a raise.
>>
>>54214882
Dilbert? is that you?
>>
generic question on tech

if I usually "just do" things (and they work) and understand them, but I'm too lazy/don't want to read the docs for hours or even days... what do you think it means? am I harming myself by not learning the concepts in a formal(?) way?

I've always had this conflict between doing things "the right way" and just doing them. and I still haven't resolved it.
>>
>>54214915

Pretty much.
>>
>>54214967
only do it the right way if you have/want to show your work
>>
>>54214967
Too vague to properly answer.

If it works for you, then why fix what ain't broken? It's not like you have to remember the manpage of every program on your system inside out.

Learning by doing is a good method with most computing (OPINIONS!).
>>
>>54214732
it's a pretty nice website though, you should start
>>
>>54215013
so, if I want to get a job and show-off, I have to do things the right way? what, then, if I'm at work? I will be criticized by my peers for being a lazy fuck and a hack, no?
>>
>>54215055
really depends on the type of work
but generally yes
>>
some examples of when you need to use underscore to start the name of a variable in java?
>$, _, a, n, y, l, e, t, t, e, r,
>>
>>54215115
>need to
why?
>>
>>54215115
that's what i'm asking
>>
>>54215115
some people do it for private fields or args like this;

public int setNigger(int _nigger) {
nigger = _nigger;
}

it can also be done like this instead using the `this' keyword
public int setNigger(int nigger) {
this.nigger = nigger;
}
>>
>>54215013
>>54215039
>>54215110
thanks anons
>>
>>54215115
If you want to make a variable identifiable by numbers only (variables can't start with numbers)
When something in global namespace has the same name
>>
>>54215184
then why not just given the 2nd instance a suffix?
String stringvar stringint
>>
c newfag here
how do I write the prototype of a function that takes a 1d array and returns a 2d array

what's the best array size?
>>
>>54215206
Sure, you can do that too
>>
>>54215237
you cant return an array
instead do something like this
int array[10][10]
function ( &array[0][0] )
>>
>>54215237
just copy the function header and add a semicolon

int **return_2d_array(int *);
>>
>>54215254
so just an _option, but no _need for it, eh? then why even have _it?
>>
>>54215273
for stupid shit like >>54215173
>>
>>54215262
arrays are second class objects in C, you can return a pointer to an array (of arrays of arrays...) so long as it's locally allocated as part of the function call.
>>
File: 091256129.jpg (40 KB, 695x427) Image search: [Google]
091256129.jpg
40 KB, 695x427
>>54215237
>>
>>54215294
*so long as it's NOT locally allocated as part of the function call
>>
>>54215262
>array[10][10]
I don't wanna modify array[10]
I wanna modify array
unless that's syntax for an array that has 10 arrays

>>54215265
I've know the star is somehow connected to pointers, but I'm still not in the pointer chapter in k&r
>>
V͏͏̦̻̰̱͉̺̩͚̰̜̤̹͙͝Ì̫̬̱̹̲̙̯ͅŖ̣̤̰̠̟̘̪̠̠̭̞̯͉̻́̕U̷͇͚̞̰̱̼͕̤̻̟̤̞̕͜͡͞S̴̳͉͙̯͕̼̮̞̲̺̞̗̩̺͕̳ͅ


E͎̮͔͈̪̟RR̤̣O͓̪R̷.̮̲͇͟ ͈̩V͉͕͚̥I̙̖͙̝͉͘R̠̹͜U͏̯S̫̦̺ ͙̝̦̺͜D̶̙͕E̠̗T̠̤͖͙̖̮̻E̵̩͉͖̫̣ͅC̸̞̭̳T͇͎̗̠͇͜E̡͇̝̹͎̟͍̼D͇̟̦͢.̗̠̗̼ ̱SY͟S҉͉̟͎͖̼ͅͅT̢̠͖̘͕ͅE̤̞̞̟͝M̧̙͎̞͎̞͍͙ ̗̻̞͇͚̗̫R͖̟̖͕̙E҉̹̤Q͙͇͍̭̥̘̝U̫̘̙I̶͕̼͎R̹̤͈E҉͙͇͕̱̯S ̹̯͇M̧̯͍̻̠̞A͎̘̘I̭͍̥͙͚͜Ǹ̘̠̭T̹͎̜͉̖̙͇Ḛ̸͉̟̳̮N҉̺̥͚̤E̝̣͓N̖C͙̯̭̼̰E̸͓̳.̫͔͔ ̳̞̘̖Ș̷̯͍̙E͔̘̦̘͝N̲͈̤̝͕̙D̻̼I͏̱N͏͔G͚͙̠͓̠ ͔O҉̣̙̫͙̪̙̲Ṷ͖̺T̸͙͔̲͇͔ ̢̩͎̰͇L͔͍͙O̪̯͎͞C̷̘A̮͙L͖ ̪̪̙̬I̘̰T̛͕͇̣̩̘ ̫̻̪̟͝PRO̬̘̟̩̭͎ͅF̴͇̦̪E҉̦S̺͎̖͈͎S̛͚̮̝̞͖I̢̗̫Ơ͕̬̣̭̰Ń̝AL
>>
>>54215313
what exactly do you wish to do?
>>
Is there a good book that will bring me from being able to make short ~500LOC or less scripts to being able to make larger projects?

Choice of language the book uses is obviously less important as this is a more abstract topic, but a book that uses Python or C would be preferable.
>>
>>54215323
mate that's racist
>>
>>54215339
wtf
how so?
>>
>>54215313
anon, don't bother using array subscripts in function declarations, it's confusing as fuck.
Just return pointers, or pointers to pointers, or pointers to pointers to pointers.
>>
>>54215347
Are you kidding me?
>>
>>54215325
I want to make a function group() such that
group("nigger") yields ["n","i","gg","e","r"]
or group("aaaabbcdd") yields ["aaaa","bb","c","dd"]
>>
Currently working on an open source ai/automation platform. Kind of like android for ai, third parties can write apps (in several different languages) that use the speech recognition engine and so forth. It can also learn new skills on the fly by turning english into python
>>
>>54215364
nope. how is that racist?
are you a SJW who claims everything is racist and needs to go back to sucking his momma's tit?
inb4: that's sexist!
>>
>>54215365
Does group("aabcaaad") yield ["aa", "b, "c", "aaa", "d"] or ["aaaaa", "b", "c", "d"] or ["aa", "aaa", "b", "c", "d"]?
>>
>>54215365
why would you name that function "group" when it obviously partitions the string?
>>
>>54215398
>not knowing carl the cuck's catchphrase

>>54215410
the first one
>>
>>54215410
based on the description it seems like it yields
aa b c aaa d
>>
>>54215410
let me put it this way
concatenating the result of group(s) is equal to s
>>
>>54215420
>>the first one
Then why the fuck are you actually splitting this in to sub arrays instead of just parsing the string directly?
>>
>>54215417
what a bizarre thing for someone with severe autism to hone in on.

as for >>54215365
you could just start at the second element and just chomp through the string, like
def group(string):
output=[string[0]]
for n in range(1,len(string)):
if string[n]==string[n-1]:
output[-1]+=string[n]
else:
output.append(string[n])
return output

assert(group("aabcaaad")==['aa', 'b', 'c', 'aaa', 'd'])
assert(group("nigger")==['n', 'i', 'gg', 'e', 'r'])
>>
File: giphy.gif (983 KB, 450x337) Image search: [Google]
giphy.gif
983 KB, 450x337
>>54215173
>>54215365
>>54215173
>>54215365
>>
>>54215468
>a bizarre thing
criticizing people for misnaming functions isn't bizzare at all, it leads to bugs and more time spent on reading and understanding the code.
>>
>>54215453
so I can ignore non space arrays, and also because it's more general
>>
>>54215496
I named it that way because my first lang had a function like what I'm describing with the same name

would you rather have group_subsequences()?
>>
it should be called groupAdjacent
>>
File: 1448237034635.jpg (840 KB, 1772x1149) Image search: [Google]
1448237034635.jpg
840 KB, 1772x1149
>>54211104
Exercise #36 in "Learn Python The Hard Way" was a simple text adventure.

Let me share my meme-tastic masterpiece with you, technolo/g/ists. I call it "Gensokyo Adventure":

from sys import exit

def start():
print """
After many years a kissless virgin, you've decided to open a one-way portal
to Gensokyo. A foreboding rope hangs from your ceiling.

Tonight's the night, anon. No more pussying out like you always do...
"""
choice = raw_input("\nWat do? > ")
if choice == "hang self":
gensokyo()
elif choice == "browse 4chan":
print """
You procrastinate in quiet desperation, creating yet another
Gensokyo thread on /jp/. Your thread is quickly buried by sage and dubs.

Out of nowhere, Shia LeBeouf flashes on your screen yelling \"DO IT!\"
"""
start()
else:
print """
What are you waiting for? DO IT FAGGOT.
"""
start()

def gensokyo():
print """
After one last swig of Mountain Dew, you slowly climb the stepladder toward
almost certain oblivion. You wrap the rope around your neck, and kick the ladder
down under you.

You dangle for a bit as the living world fades away from you.

Suddenly, you're flying through a trippy tunnel toward a white light. You're not
sure if this is real, or just a dying dream. Instead of fading to black oblivion,
you're overwhelmed by a lucid, white bloom immersing your weightless body.

As if your "eyes" had finished adjusting, the light scatters and diffuses around
you into hundreds, if not thousands of little globes flying around in every
conceivable direction. Bullets. Could it be... ?

Cherry Blossom Trees dot an undoubtably oriental landscape whooshing by below you.
You slow your flight, and gracefully land in front of a Shinto shrine.
A brown-haired loli in a red and white dress looks at you longingly.

Congratulations, you are now in Gensokyo.
"""
exit(0)
>>
>>54215521
partition_by_same_char
>>
>>54215538
>>54215531
>>
>>54215537
WIP

Wat do, /g/? You get to program the game!
>>
>>54215537
"Eyes" is now \"Eyes\". Vim syntax didn't catch that one...
>>
>>54215468
thanks, I can understand how it works, but I don't think C has -1 notation for arrays
>>
>>54215610
it does, but it won't do what you expect it to do if you expect it to do what it does in python
>>
I've barely scraped C and it's already hard
props to people who can manage memory properly and design around it
>>
>>54215732
What are you having trouble with, senpai?
>>
>>54215732
>props to people who can
they can't unfortunately. People are notoriously bad at properly managing memory. If you plan to code in c or c++ you HAVE to learn to use valgrind. Although that's not a panacea either unfortunately.
>>
>>54215806
designing good programs
I can write Fizzbuzz but not the 500 line project that is readable, efficient , and considers generality and or modularity
>>
>>54215732
Avoid using global variables whenever possible and you won't have to deal with memory management problems.
>>
>>54215850
What kind of program are you trying to write, I can give you some guidelines on how to modularize it desu
>>
is 'String' functionally an 'array' of 'char's?
asking for java. but interested in answer for other languages as well
>>
File: D.jpg (42 KB, 512x512) Image search: [Google]
D.jpg
42 KB, 512x512
>>54215905
in the best languages
>>
>>54215041
Sorry, was busy finishing this project.

Nah, Reddit's not my style. It sucks ass, actually
>>
>>54215905
strings should be just an array of chars, not a defined type
>>
>>54215610
so C would be a lot more complex obviously, but the conceptual idea is the same, and there must be some way of referencing the last/ultimate element in a string and/or other container. I'm not really familiar with C but I'd be surprised if there was nothing to this effect.

>>54215496
Okay, so in the 3 posts I can confidently attribute to you, you've made a point of bitching about the function name and offering nothing else to the problem itself.

You're exactly what they talk about when people complain about bikeshedding. You belong on an ineffectual committee, as far removed as possible from the people who work and get shit done.
>>
>>54215905
yes, in Java, and most languages, a String is an array of chars.
I don't actually know of any that have a string as anything else
>>
>>54215963
python I think
>>
>>54215963
In Erlang, it's an array (List) of Integers.
>>
>>54215963
so then, can i call the array natively?
string = "my name is bob"
from here can i just ask for the 2nd char?
or do i need to define the string as an array first and then ask the new array for its 2nd char?
>>
>>54215963
Some scripting languages use ropes internally (although I believe most of them that do so still expose it in a way that looks like arrays in-language).
>>
>>54215983
in C too
chars are just ints I think
>>
>>54215983
A char is an integer anyways
>>
>>54215983
>array (List)
reeee
>>
>>54215958
If you use the C++ string class, you have access to the size() and length() methods.

For the last character in a string, you can then index it to str.length() - 1

Not too familiar with C yet. Want to learn it, but I assume you'd have to make a struct that emulates a class of string and stores an array of chars and counts them up to give you length.
>>
>>54216009
C has an entire header for null terminated char arrays (C strings) and binary memory operations
you can literally just do
strlen(str) - 1
>>
>>54215995
yes.

I actually did that in my Programming I class by accident. I didn't know about the at() function when we first started, so I just called it with brackets, and it worked fine. The string class actually overloads the operator[] to return the character, according to:
http://www.cplusplus.com/reference/string/string/
>>
>>54215958
> the problem itself
the problem itself doesn't exist. Dividing a string into a couple of substrings based on an extremely simple condition is only a problem to you, and only because you're retarded.
Misnamed functions are a problem that a lot of programmers deal with/contribute to, which actually should be pointed out when it happens. Bikeshedding here would be wasting time on writing out a solution to a non-existent "problem"

>people who work and get shit done
people who work and get shit done don't go to 4chan to ask to write a solution for every single smallest challenge they face, so it's not for you to judge who should work and who shouldn't.
>>
>>54216045
oooo, that's interesting
>>
File: tar.png (17 KB, 836x713) Image search: [Google]
tar.png
17 KB, 836x713
I have a tar file, and was wondering how I untar it and run it?
>>
>>54216076
man tar
>>
>>54215975
hmmm, the more I hear about that language the more annoying it sounds to use...

could be wrong, though. Don't know almost anything about Python yet.

>>54215983
case in point. I have never heard of that language, so therefore I did not know of it doing that.
I guess it'd make sense to store them as ints, though, so not too weird. But why a list?

>>54215998
hmmmm
>>
>>54216094
Didn't work, I just got a bunch of text printed out but I don't think this is the contents of the archive. Please don't post advice if you don't know what you're talking about
>>
>>54216076
tar xf file.tar
>>
>>54216076
try this
http://how-to.wikia.com/wiki/How_to_untar_a_tar_file_or_gzip-bz2_tar_file

I was gonna suggest something with bzip or whatever, but I'm not quite that well-versed with Linux, so I just Binged it.
>>
>>54216096
I agree
python was my first lang to a degree, and I shilled for it
but then I learned Haskell & C
python, although useful, is kind of shit
>>
File: Wolfgang-taped-model.jpg (49 KB, 660x440) Image search: [Google]
Wolfgang-taped-model.jpg
49 KB, 660x440
>>54216094
>>54216124
>>54216126
ok I got it thanks.

I forgot the syntax and was googling it with no luck, but wowie I got an answer coming here. I'm gonna come to this board more often and try to help in these threads as well, thx
>>
File: 1448880958061.png (3 MB, 1920x1080) Image search: [Google]
1448880958061.png
3 MB, 1920x1080
>>54215537
Gensokyo Adventures now officially a hentai game. A really shitty one.

http://pastebin.com/TJ0AQNPa

It's got an H-scene with Reimu and a failure state at the hands of [spoiler]Yukari[/spoiler]. What more could you ask for?

I'll come back to it later, when I learn how to make proper switch/dictionaries.
>>
>>54216076

tar -xvf filename.tar
>>
wanting to make game.
want it to be great, fun and something i'd play and be proud i made it.
also want it to make money.
the masses aren't as sophisticated as me
see: angry birds, flappy bird, candy crush, etc...
should i stick to my morals and make the great game?
or make the formulaic swill that the peasants will swarm upon?
>>
>>54216221
>the masses aren't as sophisticated as me
>should i stick to my morals and make the great game?
>or make the formulaic swill that the peasants will swarm upon?
dont you have a school shooting to commit?
>>
>>54216221

If it's truly a great game, it will sell. The market for angry birds and the like is oversaturated.
>>
>>54216257
don't be butthurt. some of us do have better taste.
you may prefer a big mac, cherry pie and diet coke, where as i'd prefer prime rib and asparagus and a dutch ale
>>
>>54216153
I use it when I have to interface with a network but that's about it. It's fun to write because it's easy but scoped indentation creeps me out after a while. The python devs seem like cucks unfortunately, at least there was an attempt.
Thread replies: 255
Thread images: 21

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

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.