Quantcast
[ 3 / biz / cgl / ck / diy / fa / g / ic / jp / lit / sci / tg / vr / vt ] [ index / top / reports / report a bug ] [ 4plebs / archived.moe / rbt ]

Due to resource constraints, /g/ and /tg/ will no longer be archived or available. Other archivers continue to archive these boards.Become a Patron!

/g/ - Technology


View post   

[ Toggle deleted replies ]
File: 166 KB, 1280x720, dpt programming club.jpg [View same] [iqdb] [saucenao] [google] [report]
64576041 No.64576041 [Reply] [Original] [archived.moe] [rbt]

old thread: >>64571072

What are you working on, /g/?

>> No.64576080
File: 430 KB, 600x524, catmoot.png [View same] [iqdb] [saucenao] [google] [report]
64576080

Based china spammer, bringing back old 4chan. Now we just need some gore and scat for the full experience.

>> No.64576082

>before bump limit
no

>> No.64576085
File: 12 KB, 400x123, Capture.png [View same] [iqdb] [saucenao] [google] [report]
64576085

Guys i love this program called Rockbox but I barely know shit about how software development, only took 2 semesters of java. How do i get started on this so I can get this working for other devices, specifically my Cowon plenue d?

>> No.64576114
File: 10 KB, 264x191, pep.png [View same] [iqdb] [saucenao] [google] [report]
64576114

>>64576041
>"Project 1: write an LRU CPU cache simulator in c++ and calculate statistics"
>don't know c++
>don't know how caches work
>don't know statistics
>entire project is due in less than a week

yabba dabba doo, my existence is poo

>> No.64576173

>>64574090
chicken scheme uses a sort of amortized trampoline. uses the C stack to allocate stuff in the gc nursery, and just uses C function calls directly. When the nursery/stack fills up, it copies live data from the nursery/stack to the heap, and blows away the rest of the stack with longjmp.

Gives you fast tail call support and allocation.

>> No.64576206

>>64576114
and instead of learning these you are shitposting here.

>> No.64576239

>>64576114
start here
https://en.wikipedia.org/wiki/Cache_replacement_policies#Least_Recently_Used_(LRU)

then here
https://leetcode.com/problems/lru-cache/discuss/

>> No.64576270
File: 21 KB, 496x594, Capture.png [View same] [iqdb] [saucenao] [google] [report]
64576270

whats this public static thing called?

>> No.64576278

>>64576270
Method header.

>> No.64576284 [DELETED] 

>>64576278
so if thats a method header, whats a method?

>> No.64576295
File: 15 KB, 381x198, capture.jpg [View same] [iqdb] [saucenao] [google] [report]
64576295

>>64576284
nevmnd, found something on google

>> No.64576301

>>64576270
inefficiency

>> No.64576314

>>64576173
>chicken
>"sane"
it's amongst the slowest scheme implementations.

>> No.64576319
File: 45 KB, 215x309, mpv-shot0031.jpg [View same] [iqdb] [saucenao] [google] [report]
64576319

Anyone know some place where I can go and make programs people request for free?
I want to get experience making stuff people actually ask for. I feel no passion for projects that I do for the hell of it.

>> No.64576347

>>64576314
it's still pretty neat and it works well

>> No.64576370

>>64576347
after some test, even chicken is turning tail call into goto.

>> No.64576379

>>64576270
entry point?

>> No.64576396

>>64576270
A static """method""".

>> No.64576444

So in C and C++ the rule of const keyword are pretty consistent. It always make something left of it as const:
T //datatype T, modifiable
T const //datatype T, can't be modified by any means
T const & //reference to a constant T
T const * //pointer to a constant T
T * const //a pointer that always point to a T, and can't be changed to point to other object. The T is not constant
T const * const //a constant pointer to a constant T
//In a method:
void Foo::Bar() const //a method that callable by constant Foo, and can't change any value in the *this object

But why lots of people still write it as const T foo; ???

>> No.64576668

Learn Agda first.

>> No.64576698

Avoid Agda at all costs.

>> No.64576715

is there any way to make the java compiler allow emoji class names?
I know the jvm definitely allows it

>> No.64576758

If Agda is too difficult for you, then consider finding another hobby.

>> No.64576760

>>64576041
What is the best function in C that allows me to read from a file (i.e. copy the char from a file into a array of chars) until a certain character?

>> No.64576765

What's a good IDE for OpenGL programming on windows?

>> No.64576770

>>64576319
bump this question

>> No.64576784

>>64576765
emacs

>> No.64576788

>>64576114
*dabs*

>> No.64576802

>>64576784
stop

>> No.64576803

>>64576760
http://en.cppreference.com/w/c/io/fread

>> No.64576809

>you should learn javascript first
>if you think otherwise, it means javascript is too difficult for you

>> No.64576816

>>64576809
>you should learn javascript first
>>>/g/wdg

>> No.64576820

>>64576114
lru is piss easy
write a prototype in python or javascript or any other language you know then translate it to sepples

>> No.64576824

>>64576816
he was quoting someone idiot

>> No.64576830
File: 8 KB, 349x104, gvim emoji.png [View same] [iqdb] [saucenao] [google] [report]
64576830

>>64576715
Quite surprised to find that Gvim renders Emojis in color.
Sadly, this does not compile.

>> No.64576833

>>64576824
Who was he quoting?

>> No.64576840

>>64576833
no clue

>> No.64576841

>>64576809
Whomst are you quoting?

>> No.64576842

>>64576833
Whom

>> No.64576846

>>64576803
But that funtion will read until n-1 charachters, which is not what i want. I want it to read until a certain charachter appear. In this instance it is \n

What is the equivalent to this function int feof(FILE *stream) but to test end of line?

>> No.64576851

>>64576842
Are you from the early 20th century?

>> No.64576859

>>64576270
>forcing OOP so hard that standalone functions must be implemented as public static methods under some arbitrary class

>> No.64576866

In another thread, someone mentioned they made a script to check if a word was a palindrome

Trying to get out of braindead end user support gig and back in programming but I cant even picture the pseudo code for this in my head.

Halp

>> No.64576872

>>64576859
Correct use of static methods in my opinion returns the class it is encapsulated in with some special stuff that the constructor can't do.

>> No.64576881

>>64576866
1. reverse the string
2. check if the result is the same as the original string
not the most efficient approach but it's hopefully easy to understand

>> No.64576884

>>64576841
>whomstvnt're art thou quoting
/dpt/sms.

>> No.64576893

>>64576872
so this is the power of oop

>> No.64576896
File: 34 KB, 370x699, 325705.jpg [View same] [iqdb] [saucenao] [google] [report]
64576896

Alright my negroes, I'm shitting myself with simple stuff like chars and pointers.
Consider the following prototype:

void TestFunc(char input[])

And the function being called:
int main()
{
TestFunc("Fuck me in the ass!");
}


This will give an error because const char * can't be implicitly converted to char *. Alright, but then why the fuck does this work: char input[] = "Fuck me in the ass!"

>> No.64576904

>>64576866
Step through the strong from front to mid and back to mid simultaneously and check for characters?

>> No.64576907

>>64576866
Have 2 index variables, one that starts at the beginning and goes forward, and one that starts at the end and goes backward. Keep checking until the indexes cross (you have a palindrome) or until the characters don't match (you don't have a palindrome).

>> No.64576913

>>64576881
why am i retarded?

I was picturing a loop comparing the first and last, then increasing the first index and decreasing the last index

>> No.64576916

>>64576872
>>64576893
>believing java has anything to do with OOP

>> No.64576925

>>64576370
that probably depends on the C compiler and how much optimization it does. chicken just generates C code.

>> No.64576928

>>64576913
that would work too and probably be faster, but trickier to implement correctly

>> No.64576932

>>64576896
the second one, the compiler knows how long the string is. the first one not so much. you can kind of just imagine the compiler slipping a sneaky `19` in to make it `char input[19] = ...`. it can't (or doesn't) do that for a function's argument.

>> No.64576943
File: 345 KB, 633x720, 1506432289658.png [View same] [iqdb] [saucenao] [google] [report]
64576943

Employed Haskell programmer here

>> No.64576949

>>64576846
ssize_t getline(char **lineptr, size_t *n, FILE *stream);
ssize_t getdelim(char **lineptr, size_t *n, int delim, FILE *stream);

>> No.64576957

>>64576846
fgetc
loop it

>> No.64576960

>>64576932
correction: would be [20] rather than [19]. i'm still drunk from last night though so yeah. deal with it. good luck learning computer.

>> No.64576962

What's the best set up for using GCC on Windows?

>> No.64576964
File: 37 KB, 800x535, Umbrella Cockatoo picture 2013 06.jpg [View same] [iqdb] [saucenao] [google] [report]
64576964

>>64576943
Employed Idris programmer here

>> No.64576973
File: 137 KB, 340x340, 729.gif [View same] [iqdb] [saucenao] [google] [report]
64576973

>tfw there's a greater number of employed Brainfuck programmers than Haskell ones

>> No.64576982

>>64576925
>>64576370
unless chicken itself is optimizing away some function calls, which is also possible

>> No.64576990
File: 26 KB, 480x480, cs_was_a_mistake.jpg [View same] [iqdb] [saucenao] [google] [report]
64576990

>>64576973
To be fair that's probably true for most language.

>> No.64576993

>>64576943
i don't think i know of anybody who *only* knows haskell. everyone i know who makes any money with niche platforms (yes, haskell is a niche platform) is familiar with all the basic boring stuff too, and uses them in some capacity.
javascript on the other hand - there are plenty of people who genuinely know no other language and would be utterly lost if you sat them down in front of something that didn't look vaguely like C.

>> No.64577002

>>64576932
Ok, got it senpai.
After a little googling I learned that I can cast it like this: TestFunc((char*)"Fuck me in the ass!");

Is this really the best way to handle this? This function will be called a lot and I don't wanna having to put a casting every fucking time. I can also handle things on the function side, but I can't figure it out how to do that without having to use a buffer variable.

>> No.64577008

>>64576896
>This will give an error
it werks for me

>> No.64577032

>>64576846
fgets then

>> No.64577033

>>64577002
>After a little googling I learned that I can cast it like this:
Not him, but just don't do that. The reason the compiler screams on you is that string literals are embedded in the binary's data segment, and if you try to modify them, you will probably die from a segfault. If your function doesn't need to modify its input, just do this:
void testFunc(char const *input) {
}

int main() {
char bar[] = {'b', 'a', 'r', 0};
testFunc("foo"); // okay
testFunc(bar); // also okay
}

>> No.64577044

>>64577032
>>64576846
http://en.cppreference.com/w/c/io/fgets

>> No.64577056

>>64576896
The first one fails because input is not an array, it's a pointer.

Second one works because input is actually an array.

>> No.64577061

I'm on the loops chapter now.

import java.util.Scanner;

public class Main
{
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
boolean okay;
do {
System.out.print("Enter a number: ");
if (in.hasNextDouble()) {
okay = true;
} else {
okay = false;
String word = in.next();
System.err.println(word + " is not a number");
}
} while (!okay); //What is this?
double x = in.nextDouble();
}
}


I'm confused as to what's happening with the while condition. Like "okay" is a boolean with no assignment right? Then it gets assigned inside the do statement right? So how does "!okay" work as a condition?

>>64576943
>Haskell
Someone told me to learn Haskell first since I have a(n unused for years) maths background but I already bought the books for java.

>> No.64577062

>>64577002

>>64576932 here
>>64577033 is spot on. way more concise than what i was typing, too.

>> No.64577072

>>64577033
I know this is true for C++, but is this true for C too?

>> No.64577076

>>64577061
>I already bought the books for java
oh shit anon, what are you doing

>> No.64577103

>>64577076
Why? It wasn't expensive, it was the humble bundle set from a few months back.

>> No.64577123

>>64577103
you's got mo money than brains niqua

>> No.64577130

>>64577033
That's what I was going to do, but I wasn't sure. Also, I'm going to have to create a new variable inside my function because I actually need a char * (to pass as an argument to a system function) and not a const char *. But if that's the proper way to do it I don't mind it.

>> No.64577133

>>64576896
i have no error with clang nor gcc

>> No.64577153

>>64577072
>is this true for C too?
Yes. I guess it's worth noting that you can create a normal array using the string literal syntax like this: char arr[] = "str"; You're allowed to modify that, and sizeof(arr) will actually actually give you the length of the string (terminator included).

>> No.64577209

>>64576949
>>64576957
>>64577032
>>64577044
>Parsing stops if end-of-file occurs or a newline character is found,
Didn't read the part "newline"

thank you, my niggas

>> No.64577226

>>64577123
It was 10 quid. Can you help with my problem anyway?

>> No.64577248

>>64577130
>(to pass as an argument to a system function)
What system function takes a non-const char *?

>> No.64577249

>>64577226
What is "quid"?

>> No.64577266

>>64577061
It stays in the do while as long as okay is false. When it's true because there's a double in the input in, it leave the loop.

>> No.64577305

>>64577226
the boolean variable isn't being assigned, it's being evaluated (and negated)
the while statement takes the result of the evaluation, and if it's equal to true, it keeps looping, otherwise it steps out of the loop

>> No.64577331

>>64577266
>It stays in the do while as long as okay is false. When it's true because there's a double in the input in, it leave the loop.

I understand that but how does "!okay" = not true if the boolean isn't assigned true from the beginning?

>> No.64577339
File: 200 KB, 704x480, 21851774831057.jpg [View same] [iqdb] [saucenao] [google] [report]
64577339

>>64577248
A Windows one

>> No.64577340
File: 42 KB, 580x318, Capture.png [View same] [iqdb] [saucenao] [google] [report]
64577340

whats wrong with james?

>> No.64577344

How to determine if a number is divisible by 4 in x86 assembly? Like 01100100 which is 100, is divisible by 4 and I wanna jmp if that is true. Having trouble breaking this down.

>> No.64577345

>>64577305
Ok, I understand now.

>> No.64577351
File: 1.91 MB, 1491x2095, ses2wc1xnqd01.png [View same] [iqdb] [saucenao] [google] [report]
64577351

>tfw a brainlet tries to program in haskell

>> No.64577360

>>64577340
He just realized that OOP objectifies women and girls.

>> No.64577364

>>64576913
That's fine as well.

>> No.64577379

>>64577340
He browses /g/

>> No.64577381

I want to be able to detect commercials on tv and black them out. What can I use to do this? OpenCV? ffmpeg?

>> No.64577386

Just what the fuck are some values in COCOMO II based on?

0.22 for defects?
Time per men? Who came up with this bogus?

>> No.64577389

>>64576896
You have a type conversion error because a const can’t be demoted to a non const. You can however promote to const.

So, according to your compiler, a string literal is const.

And if it were to work (like people are saying) then the string would be undefined if you were to change the string in any way. Your solution might be to make your function parameter const char[]

>> No.64577409

>>64576319
Pick an open source project of your choosing and look at it's bugtracker/feature requests?

>> No.64577424

>>64577344
test reg, 0b11
jz divisible_by_four

>> No.64577427

>>64577389
And the answer is due to your const correctness. Has nothing to do with pointer/array differences when passing them through functions (like people are saying)

>> No.64577440

>>64577331
The boolean is always assigned because of the if else. !okay just means we will do the loop while okay is false.

>> No.64577454

>>64577344
>How to determine if a number is divisible by 4 in x86 assembly?
A number is divisible by 4 if it's divisible by 2, and the quotient is also divisible by 2.
A number is divisible by 2 if it's even.
You know a number is even if the least significant bit is 0.
If the two LSBs are 0, the number is divisible by 4.
You can check this by zeroing them out and seeing if the number has changed.

>> No.64577511
File: 579 KB, 1080x1080, 1472778212337.jpg [View same] [iqdb] [saucenao] [google] [report]
64577511

What's the difference between 16-bit and 32-bit code?

I know a bit about programming in C++ but what specifically do I have to do to make a program either 16-bit, 32-bit, or 64 bit?

>> No.64577524
File: 9 KB, 689x140, c.png [View same] [iqdb] [saucenao] [google] [report]
64577524

>>64576896

>> No.64577528

>>64577511

The number of bits

>> No.64577529

>>64576114
better start selling your ass to pay for those class credits

>> No.64577530
File: 52 KB, 664x291, 1486448582291.png [View same] [iqdb] [saucenao] [google] [report]
64577530

>anime analogy

>> No.64577541

>>64577511
there are variables such as MAX_INT or whatever given to you. use them. don't make a program tailored to a certain hardware architecture

>> No.64577548

>>64577530
C++ has to be stopped

>> No.64577565

i'm unsure whether i suck at java or if the language sucks, but everything just feels so clumsy and shitty about this language. i'm stuck trying to do a pretty simple thing, but i can't find a tidy way of doing it. i could solve this with pointers in like a second but i guess the language doesn't have them LOL

>> No.64577570

>>64577409
I don't know how to even begin to tackle large code bases.

>> No.64577573

>>64577565
Just wait until you have to JSP.

>> No.64577574

>>64577565
>the language sucks
yep
>everything just feels so clumsy and shitty about this language
yep

>> No.64577580

>>64577565
what are you trying to do?

>> No.64577599

>>64577565
just use the snake

>> No.64577609

>>64577599
down that path lies madness and ruin

>> No.64577612

>>64577511
>What's the difference between 16-bit and 32-bit code?
There is none.

>I know a bit about programming in C++ but what specifically do I have to do to make a program either 16-bit, 32-bit, or 64 bit?
Nothing; you can compile non-broken C++ code for 32-bit or 64-bit (or indeed, 16-bit) platforms depending on the compiler setting.

You can fuck up your code to the point that it only works properly on a particular bit size, like trying to interpret an integer as a sequence of 4 bytes (the number of bytes you actually need depends on how large your ints are). As long as you don't do that, it will run anywhere.

>> No.64577619
File: 427 KB, 978x478, 979819896927042233.gif [View same] [iqdb] [saucenao] [google] [report]
64577619

>>64577530
What the fuck, I love anime now!

>> No.64577625

>>64576270
The first word defines it's scope. Public means any class can call it, where private means only methods in the same class can call it. I'm less sure about the rest

>> No.64577626

Best languages:
1. Agda
2. Idris
3. PureScript

>> No.64577632

>>64577249
A currency

>> No.64577636
File: 24 KB, 447x261, 785591633.jpg [View same] [iqdb] [saucenao] [google] [report]
64577636

>>64576270
>static main
>static
>main

>> No.64577637

>>64577632
Oh wow - is that where "quidditch" in Harry Potter comes from? Like, a sport that wizards bet money on? A 'quid ditch' into which good money is thrown after bad?

>> No.64577648

>>64577249
It's 1 GBP.
>>64577305
>>64577440
Thanks. What's a reasonable timeframe for me to learn java to an employable level? I have a 7 year old maths degree and 4 years worth of shelf-stacking experience.

>> No.64577657

sucking black dick and writing Rust! also got a cock cage on.

>> No.64577669

>>64577648
don't learn java, learn javascript
with a math degree you're already smarter than half the frontend monkeys
and it pays good, 80k

>> No.64577674

My mother asked me to make an application for workers to schedule vacations. I think I can do it with a webpage where workers fill out a form with their vacations days. When they submit, it fills out a google calendar with their vacations as events.
Are there better ways to do this?

>> No.64577677
File: 1.84 MB, 9810x2700, humm.jpg [View same] [iqdb] [saucenao] [google] [report]
64577677

>>64577636
What's wrong with static functions?

>> No.64577681

>>64577580
i am very new to this language so i might sound like a retard here, but basically here's what i want to do. variable names changed because fuck you

i have an object (Car) that has sub-objects (Mustang, Ferrari, etc.) that inherit some properties from it. in main, i'd like to declare an array of 4 objects that can be filled with any of the sub-objects i'd arbitrarily declare later. however, if i declare an array of 4 objects in the beginning of the program, i apparently have to pick the type of object they are. this seems to inhibit me from putting the correct sub-object on the object variable since i would be doing the following:

Car vehicle[0] = Mustang new(0, 0)

which fucks everything up. so basically i'd like to have the array have nameless objects until i later decide what objects they become. or something like that.

>> No.64577683

>>64576916
Java is an OOP language though

>> No.64577689

>>64577669
and cover up your shelving, pretend you were writing a novel or had to help a dying relative or transitioning or some shit

>> No.64577706

>>64577681
Car[] cars = new Car[5];
cars[0] = new Mustang();

so youre actually just an idiot and have no valid criticisms

>> No.64577707

>>64577677
they're stateful

>> No.64577708

>>64577674
how does it feel to be part of the 1%?

>> No.64577720

>>64577707
Actually, they're the opposite of stateful.
Non-static functions in poo-langs are the ones dragging state everywhere.

>> No.64577723

>>64577706
actually i dont understand what the fuck you said>>64577681

>> No.64577727

>>64577706
see i do that and it apparently can't call the functions in said sub-object since it can't find them.

>> No.64577730

>>64577720
It's not so bad if your classes are immutable and you don't use inheritance

>> No.64577745

>>64577706
I think it’s funnier that so many people agreed with him, and knew nothing of the problem.

I imagine they were all having syntax errors as well, and came to the same conclusion

>> No.64577746

how do i call by reference in python?
def popmin(parent):
if parent.l == None:
result = parent.val
del parent
return result
else:
return popmin(parent.l)


In the first if statement, I want to delete the node parent from the tree, but I can't do this. If I was using C i would just call by reference but this doens't appear possible in python?

>> No.64577749

>>64577727
because youre not using inheritance right
you can only use methods declared in the Car class

in your car class you can have
public void refuel() {
// refuel car
}

and in a sub class you can override this
@Override
public void refuel() {
// different implementation for fueling the car
}

>> No.64577785

>>64577669
>>64577689
>and cover up your shelving, pretend you were writing a novel or had to help a dying relative or transitioning or some shit

For 4 (+3 NEET) years? Also how different is Javascript from Java?

>> No.64577804
File: 105 KB, 800x371, 1517026397110.gif [View same] [iqdb] [saucenao] [google] [report]
64577804

>>64576114
>>64576206
>>64576239
>>64576788
>>64576820
>>64577529
huh, this stuff is starting to make sense now
i think i'm seeing the light at the end of the tunnel lads

pic related, me when understanding the basics LRU caches (but with emacs instead of starwars)

>> No.64577810

>>64577785
JavaScript is to Java as ham is to hammer.

Best comparison I’ve ever read.

>> No.64577817

>>64577810
JavaScript is to Java as shit is to shitty.

>> No.64577850 [DELETED] 

>>64577817
>javascript is better than java
lol

>> No.64577862

>>64577749
ok thanks

no need to bully me guys i told u im new to this language

>> No.64577864

>>64577850
String[] strings = new String[5];
Object[] objects = strings;
objects[0] = BigDecimal.valueOf(3);

>> No.64577870
File: 19 KB, 520x520, 51155319[1].jpg [View same] [iqdb] [saucenao] [google] [report]
64577870

>>64577817
>>64577810
Should I at least finish the book I'm reading/doing exercises from and learn the basics of coding at least? I'm on chapter 7 : Loops.

>> No.64577872

>>64577785
program in javascript if you're a hipster making 6 figures
program in java if you're an indian making 4 figures

>> No.64577878

>>64577870
What is "coding"?

>> No.64577881

Why doesn't this work?

fgetc(fptr)!='\n'

And what do you niggas listen to when programming?

https://www.youtube.com/watch?v=ts3YWVFUnvU

>> No.64577904

>>64577785
say your loved one got aids and slowly died

>> No.64577910

>>64577878
Programming, I mean.

>> No.64577922

>>64577881
>And what do you niggas listen to when programming?
nightcore, of course
https://www.youtube.com/watch?v=dV_m1H3hDio

>> No.64577939

>>64577881
Aphex Twin on shuffle.
>C

>> No.64577940

>>64577881
>And what do you niggas listen to when programming?
Why my favourite friend simulator, RLM on repeat.

>> No.64577951
File: 288 KB, 527x439, 73539.gif [View same] [iqdb] [saucenao] [google] [report]
64577951

>>64577881
edenofthewest.com

>> No.64577960

>>64577904
>say your loved one got aids and slowly died
Seems like it would be hard to keep up if I get hired.

>> No.64577965
File: 187 KB, 960x1200, 1517332776247.jpg [View same] [iqdb] [saucenao] [google] [report]
64577965

I'm learning C. Is it possible to convert an ascii character such as 'a' to 'A' by adding 32 or subtracting 32 for vice-versa? I tried to use bitwise operators, but failing.

>> No.64577971

>>64577965
Err ignore my ignorance. A=64 a=96.

>> No.64577983

>>64577881
Well you should be checking for EOF, and make sure your file stream is open + valid

http://www.cplusplus.com/reference/cstdio/fgetc/

Use the snippet at the bottom

>> No.64577998

>>64577965
Yeah. You could just add 'A' though, no need to remember the number. Also check out the toupper() standard library function.

>> No.64578001

>>64577965
Yes.

Untested example:
char test = 'A';
test = test | 32;

>> No.64578005

>>64577983
This desu senpai baka

>> No.64578010

>>64577983
I already found the solution, just copied the funtion here in the first answer, ty nonetheless bro

https://stackoverflow.com/questions/4293475/reading-c-file-line-by-line-using-fgetc

>> No.64578015

>>64577870
There’s no reason not to. Hell, read it all, then read a js book. It’ll trip you up, but you’ll learn more concepts.

>> No.64578023 [DELETED] 

>>64577878
So should I finish it?

>> No.64578024

You have 15 seconds to tell me how SCRUM isn't the absolute best Software development framework

You can't

>> No.64578075

I have no programming experience. should I learn ruby or perl (6)? I will be taught python on the job. netsec focus

>> No.64578100
File: 54 KB, 557x624, 2211391306694.jpg [View same] [iqdb] [saucenao] [google] [report]
64578100

If you're not using malloc or new anywhere in your program, can memory leak still occur?

>> No.64578130

>>64578075
perl, it's installed in every linux box

>> No.64578160

>>64578015
>There’s no reason not to.
Well time is one reason, I'm (28 years) old and I could barely stand my wageslave job that I took a few months unpaid leave and right now I'm trying to use that time to do something productive.

>Hell, read it all, then read a js book. It’ll trip you up, but you’ll learn more concepts.
The java humble bundle came with a bunch of books, I started with Think Java as the first one since it starts with the foundations. How many can I safely discard? (Obviously I can drop Minecraft modding.)

Java in a Nutshell
Think Java
Java Generics and Collections
Java Pocket Guide
Java Message Service
Learning Java
Java Threads
Java 8 Lambdas
RESTful java with JAX-RS 2.0
Minecraft Modding with Forge
Java Network Programming
Java Cookbook
Java Web Services
Java Performance
Jenkins

>> No.64578181

>>64578130
should i learn perl 5 then rather than perl 6?

>> No.64578184

>>64578160
throw out all of them except minecraft modding
do that one

>> No.64578186

>>64578100
Unless you use functions that allocate memory internally I'm pretty sure it's not possible.

>> No.64578193

>>64578181
if you can't answer this question on your own you don't have what it takes to make it in netsec

>> No.64578217

>>64578193
obviously perl 5 is included in the LSB but I'm very intrigued by perl 6

>> No.64578218
File: 59 KB, 687x694, 266908.jpg [View same] [iqdb] [saucenao] [google] [report]
64578218

>>64578186
Good to know then.

>Unless you use functions that allocate memory internally
Usually the documentation of such functions warns you to use 'free()' after said functions have been used. I just wanted to be sure if there wasn't another way of fucking up my program that I haven't noticed.

>> No.64578279

>>64578184
Be serious dude, if I get a decent career I'll come back and drop some steam codes.

>> No.64578289

>>64578279
good luck anon. java is used quite widely in industry

>> No.64578294

>>64578279
the minecraft one is the only one that'll be fun enough for you to not drop it after two weeks

>> No.64578364

>>64578294
>the minecraft one is the only one that'll be fun enough for you to not drop it after two weeks

I'm not an idiot man, I did do a maths degree. (Though I guess it is debatable since I got a shitty 2:2 in maths. If I wasn't an idiot I would've got 2:1, but I'm digressing.)

>> No.64578380

>>64578364
programming involves memorizing a ton of bullshit and it's easier if you have a practical application

>> No.64578386

>>64578364
>uk degree grading
go to bed anon

>> No.64578423

>>64578386
I haven't been to bed before 5am for 4 years now. I don't know how to fix it.

>>64578380
>programming involves memorizing a ton of bullshit and it's easier if you have a practical application
What are you suggesting?

>> No.64578428

>>64578423
go 20 minutes earlier every day

>> No.64578436
File: 43 KB, 400x400, 1517192631459.jpg [View same] [iqdb] [saucenao] [google] [report]
64578436

Learnin C pt. 2. I'm try to copy a cmdline arg into a char array. What am I doing wrong?
#include <stdio.h>

int main(int argc, char *argv[]) {
char new[5] = argv[1];
printf("New value %c\n", new);
}

I'm geting an error: "Error: invalid initializer
char new[5] = argv[1];
^~~~"
Halp?

>> No.64578446

>>64578364
>>64578423
If you have a mathematical background then you might find SICP accessible. There's very little syntax memorization required.

Book website and full text:
https://mitpress.mit.edu/sicp/

Nicely formatted version:
https://sarabander.github.io/sicp/

Lectures:
https://www.youtube.com/playlist?list=PL8FE88AA54363BC46

>> No.64578450

>>64578436
Fuck. The problem is argv[1]

>> No.64578473

c++ is the greatest language of all time

>> No.64578546

>>64578473
C is the greatest language of all time. It's over four and half decades old, and it hasn't been replaced. It also won't be replaced any time in the forseeable future. Stop with c++ shitmeme.

>> No.64578566

>>64578546
Rust will replace C++.

>> No.64578571
File: 42 KB, 500x509, 1517229521713.jpg [View same] [iqdb] [saucenao] [google] [report]
64578571

>>64578446
Does it a lot of time to learn and become proficient in it? Is it an rapidly employable qualification?

I'm in month 2 of my leave from work and it's February, I'm closing in on 30, I don't have much time to waste.

>> No.64578578

>>64578571
>Does it a lot of time to learn and become proficient in it?
Depends on how quickly you go through it.
>Is it an rapidly employable qualification?
No.

>> No.64578587

>>64578181
6 is better than 5 in every conceivable way, however I have never seen it actually installed anywhere.

>> No.64578607
File: 142 KB, 850x1020, __izayoi_sakuya_touhou_drawn_by_sasa_kichi__sample-11071df6192d68bed9c9fbc2770891b0.jpg [View same] [iqdb] [saucenao] [google] [report]
64578607

C++ amateur here. I have a coding style question and I'd like to see some of ya'lls input:
Is there any way to avoid else if chains? I just recently programmed a simple blackjack game with glut (out of date but my programming class uses it for some odd reason) and I disliked how so much space was taken up by them. Switch statements actually took up more lines since you can't have more than two conditions for the expression.

>> No.64578613

>>64578607
nested ternaries, my dude

>> No.64578617

>>64578566
Idk. I doubt it, too many sheep use c++. Rust is good for autistic programs, but it will never replace C. Go won't even replace C. When we, humans, switch from silicon to quantum computing, we will see the end of dominance of C. C is the only lowest language that we can have without getting practically difficult.

>> No.64578630

>>64578613
>nested ternaries

I dunno if those work with conditional statements.Tried to use them but maybe I was not getting the syntax right.

>> No.64578634

>>64578630
nested ternaries shouldnt be used

>> No.64578643
File: 466 KB, 1600x1038, The+burning+monk%252C+1963+%25281%2529[1].jpg [View same] [iqdb] [saucenao] [google] [report]
64578643

>>64578578
>No.

Then I can't waste my time on it. I mean, if my foreseeable with learning SICP is shelf-stacking for another 4 years, I will go into my workplace and sit fire to myself.

>> No.64578674

>>64578607
Switch statements are very easy to read tho. And you can precompute the conditions. So you use a mask for the switch or something like that. ezpz, just comment each case.

>> No.64578702

>>64578630
Sure you can:

#include <stdio.h>

void zero() {
printf("your number is 0.\n");
}

void one() {
printf("your number is 1.\n");
}

void two() {
printf("your number is 2.\n");
}

void three() {
printf("your number is 3.\n");
}

void four() {
printf("your number is 4.\n");
}

void five() {
printf("your number is 5.\n");
}

void error() {
printf("fuck off\n");
}

int main() {
int mynum = 0;
((mynum == 0) ? zero : ((mynum == 1) ? one : ((mynum == 2) ? two : ((mynum == 3) ? three : ((mynum == 4) ? four : ((mynum == 5) ? five : error))))) )();
}

>> No.64578728

>>64578702
That's horrible, don't do it.

>> No.64578781

>>64578728
You're right, we should just make a lookup table and have a single ternary:
#include <stdio.h>

void zero() {
printf("your number is 0.\n");
}

void one() {
printf("your number is 1.\n");
}

void two() {
printf("your number is 2.\n");
}

void three() {
printf("your number is 3.\n");
}

void four() {
printf("your number is 4.\n");
}

void five() {
printf("your number is 5.\n");
}

void error() {
printf("fuck off\n");
}

void (*table[])() = {zero, one, two, three, four, five, error};

int main() {
int mynum = 0;
table[mynum >= 0 && mynum <= 6 ? mynum : 5]();
}

>> No.64578812

>>64578781
I don't think that codes 100% correct, but I like it a lot

>> No.64578985

>>64577570
Almost every development job involves you tackling a large code base. Might as well get experience in that.

>> No.64579029
File: 888 KB, 1120x478, e321-sidebyside.png [View same] [iqdb] [saucenao] [google] [report]
64579029

Just started learning image stuff for class. I think it's neat.

>> No.64579132

>>64576173
Not really a trampoline at all. Everything in chicken is a tail call because the compiler concerts to all code to CPS. The nursery thing is just a generational garbage collector. The unusual thing is the longjmp when the stack is filled plus the CPS

>> No.64579158

>>64578587
this is my take away as well, but there is so much hate for perl 6 because of the name. is it whiny neo-luddites upset that larry wall has overhauled perl?

>"b-but it's not really perl"
it says right in the documentation
>Larry is always by definition right about how Perl should behave. This means he has final veto power on the core functionality.

>> No.64579194

>>64579132
Another neat side effect of chickens approach is stack overflows are really hard to get unless you do something dumb like apply a fun to a stupidly huge list. In some ways its kinda a problem as say taking a naive factorial of a billion will OOM your computer instead of stack overflow.

>> No.64579232

>>64576444
syntactic sugar

reading "constant T foo" makes more sense that "T foo constant"

>> No.64579245 [DELETED] 

Noob question: how are you guys posting those snippets of code in the fancy boxes with the colours??

>> No.64579256
File: 23 KB, 598x552, 2018-02-03-190218_598x552_scrot.png [View same] [iqdb] [saucenao] [google] [report]
64579256

>>64579245

#include <stdio.h>

int main(void)
{
printf("see here\n");
}

>> No.64579258

>>64579245
buy a 4chan pass

>> No.64579260

>>64579245
code tags

>> No.64579267

>>64579245
While you've got your code selected in the text box, press Ctrl-W, and it will put the tags around it.
Just like with Ctrl-S and spoilers.

>> No.64579313

>>64578643
>actually trusting anything posted on 4chins
don't fall for the memes, niggas be retarded
don't fall for my shit either, I might be equally retarded
still

focus on 20/80-ing dat bitch - 20% of the effort/knowledge, 80% of the goal ($$$, work/life balance, etc)

check what the job market's like in the areas where you'd consider staying
note that frontend webshit has a lot of offers, but it is quite the wild west
still, ask peeps from the industry how it is
then choose a field (backend, frontend, admin, qa, etc)
choose a tech stack
learn enough to have a chance at interviews (note that the bastards overinflate errthang in the requirements there)
and start interviewing + continue learnin n doin

e.g. python data science crap
lotta code monkeys there without the foggiest about stats, your math degree might come in handy there (especially if combined with decent communication skills)

>I haven't been to bed before 5am for 4 years now. I don't know how to fix it.
have you tried the usuals?
- lowest brightness of screens 1-2h before bed
- f.lux
- switching to phone instead of pc before bed
- switching to videos instead of reading/shitposting before bed
- switching to audio (podcasts) before bed
- switching to ambient shit (rain sounds etc) before bed
- switching off electronics 1h before bed
- enough physical activity during the day to be tired enough to be sleepy
- gradual cycling back to sane hours (not sudden jumps, but 1-2h earlier/later every day)
- habits such as mandatory morning shower at 9AM, mandatory grabbing food outside at 9:30, obligation to do something for somebody early-ish
- push comes to shove, occasional melatonin (0.3-3mg a night)
- etc

>> No.64579425 [DELETED] 

>>64579256
>>64579258
>>64579260
>>64579267
it worked?
geee it was complicated

#!/bin/ksh

# Specify the resolution of your monitor

ScreenresX=1920
ScreenresY=1080

>> No.64579629

Anyone have any experience in making a text editor?

>> No.64579674

I have a sorting function in C that takes as input an array pointer and returns a pointer to the sorted array.

I want to time a portion of the code inside the function and make that time available to the main function that calls it.

Any advice on how to get the time out of the sorting function, pls? I'm thinking of returning a struct containing both the sorted array and the time taken, but it seems a bit sloppy.

>> No.64579708

>>64574971
dumb frogposter

>> No.64579739

hey guys im new to c++ and one of my basic functions isn't working and im getting a ton of errors and idk where to begin

#include <iostream>
#include <string>

double addTheTemps(const char * tempa, const char * tempb)
{
a.toDouble();
b.ToDouble();

return a + b;
}

int main() {


std::cout << addTheTemps(10,20)

return 0;

}





go easy , i am still a novice.

>> No.64579747

>>64579739
> std::cout << addTheTemps(10,20)

You forgot the ;

>> No.64579751

>>64579739
>a.toDouble()
1) a doesn't exist
b) const char* doesn't have a "toDouble"
iii) that would be type-changing which C++ also doesn't support

>> No.64579757

>>64579674
I would go with clock(). I think it's in <time.h>.

So clock() returns the time in milliseconds since the start of the program. So just get the difference in your function.

If you call your function 4 seconds into the program, clock() will return 4000.
Make a variable at the start of your function equal to clocks output , and one at the end equal to clocks output and then get the difference.

That'll be the elapsed time.

>> No.64579759

>>64579747
Thanks! Also, how can I do this recursively?

>> No.64579766

>>64579739
>a.toDouble();
>b.ToDouble();
What the fuck

>> No.64579773
File: 34 KB, 132x143, 1502290500864.png [View same] [iqdb] [saucenao] [google] [report]
64579773

>A disadvantage of assembly language is that it is not portable, because each platform comes with a particular Assembly Language.
So fucking what? Nothing is portable and very rarely is something reusable.

So anon, why aren't you using asm?

>> No.64579775

>>64579757
That's what I'm doing, but I need to make that elapsed time available to the function that calls my sorting function. At the moment, my function only returns the sorted array.

>> No.64579782

>>64579674
Unless you're storing the sorted array in another array, then you should just return the time. Otherwise pass in as a parameter to that sorting function a pointer to where you want to store the time.

>> No.64579791

>>64579773
>Nothing is portable
b-b-b-but java

>> No.64579808

>>64579791
how many levels of abstraction you on dude

>> No.64579817

>>64579739
Bait, don't reply to this post

>> No.64579866

I'm using a 64-bit unsigned int to store signed floats, but I don't know how to shift where the decimal point is. So for instance I pull 10100011 base 2 from the 64-bit int, by default 10100011 will be 163 base 10, but I want it to be 1010.0011 where the leading 1 means it's negative, so it should be -5.8125. How do I go about this? Based on googling it seems like it has to do with fixed-point arithmetic but I couldn't really find a way to make it work.

>> No.64579903

>>64579775
Why not use a global?

>> No.64579906 [DELETED] 

>>64579629
I'm a caterpillar, not a capitalist.

>> No.64579909 [DELETED] 

>>64579739
[math]
#include <iostream>
#include <string> // Why? You're not using strings...
#include <stdlib.h> // has atof
#include <sstream> //has stringstream

double addTheTemps(const char * temp_a, const char * temp_b)
{
double a = atof(temp_a);
auto b = atof(temp_b); //you can use auto since the return type is double
return a + b;
}

double addTheTemps_option2(const char * temp_a, const char * temp_b)
{
std::stringstream s;
s << temp_a<< ' ' <<temp_b;//takes in temp_a and temp_b
double a, b;
s >> a >> b; //takes temp_a out of the stream, converts it to double, and puts it into a, then does so for temp_b into b
return a+b;
}


int main() {
std::cout << addTheTemps("10","20") << "\n"<< addTheTemps_option2("10","20");
return 0;
}

[/math]

>> No.64579931

>>64579739
#include <iostream>
#include <string> // Why? You're not using strings...
#include <stdlib.h> // has atof
#include <sstream>

double addTheTemps(const char * temp_a, const char * temp_b)
{
double a = atof(temp_a);
auto b = atof(temp_b); //you can use auto since the return type is double
return a + b;
}

double addTheTemps_option2(const char * temp_a, const char * temp_b)
{
std::stringstream s;
s << temp_a<< ' ' <<temp_b;//takes in temp_a and temp_b
double a, b;
s >> a >> b; //takes temp_a out of the stream, converts it to double, and puts it into a, then does so for temp_b into b
return a+b;
}


int main() {
std::cout << addTheTemps("10","20") << "\n"<< addTheTemps_option2("10","20.");
return 0;
}

>> No.64579951

>>64579866
floats are 32bits, not 64bits. Those are doubles.

>> No.64579998

when do you ever use octal numbers? is it some really old school thing or is it a myth?

>> No.64580002

>>64579951
Sorry I'm not explaining myself well, what I mean is I have a 64-bit unsigned int, and I'm using every 8 bits of it to represent a small floating point number. So there are actually 8 floating point numbers in this unsigned int, but if you look at just one of them, it should look like 0000 0000 for example. I want it to be formatted where the 0000 on the right are to the right of the decimal point, and the 0000 on the left are for whole numbers, except the leftmost 0 acts to tell whether the number is positive or negative.

>> No.64580007

>>64576896
1) Make it void test_func(const char input[])
2) Make it void test_func(std::string input)
3) Make it template<int n> void test_func(std::array<char, n> input)

>> No.64580020

>>64579998
>not using using base 32 numbers
pleb

>> No.64580041

>>64579998
When working with fields chunked into 8-bits. So file permissions and not much else.

>> No.64580043

>>64579866
https://www.youtube.com/watch?v=Zzx7HN4wo3A

>> No.64580050

>>64576085
isn't it dead

>> No.64580064

>>64579866
BRUh just use double lol

>> No.64580090

>>64579931
what the fuck man

>> No.64580118

How many bytes of memory does a pointer take up on a 64 bit machine?

>> No.64580199

>>64580118
64 bits. Or 8 bytes. Fuck I'm smart.

>> No.64580206

>>64580199
It's actually 4 bytes. Trick question.

>> No.64580227

pickling scraped web data

>> No.64580277

>>64580002
Then they aren't floating point numbers. Just numbers with shifted radix points.

>1010.0011 where the leading 1 means it's negative, so it should be -5.8125
No, that would be -(2+1/8+1/16)=2.1875. Are you storing them as 2's complements as well?

Here are simple functions to unpack them into floats doing it as numbers with a sign bit and 2's complemented numbers.
#include <iostream>
#include <array>

std::array<float, 8> longlong_signbit_To8floats (unsigned long long number){
std::array<float, 8> floats;
const unsigned long long value_mask = 0b0111'1111; //= 127
const unsigned long long sign_mask = 0b1000'0000; //=128
for(auto& butterflies : floats){
butterflies = number & value_mask; //filter out the number
butterflies /= 16; //shift the decimal 4 bits over
butterflies = number & sign_mask ? -butterflies : butterflies; // check sign
number >>= 8; //shift over 8 bits
}
return floats;
}

std::array<float, 8> longlong_complement_To8floats (unsigned long long number){
std::array<float, 8> floats;
const unsigned long long value_mask = 0b0111'1111; //= 127
const unsigned long long sign_mask = 0b1000'0000; //=128
for(auto& butterflies : floats){
if(number & sign_mask){
butterflies = ((~number) & value_mask) + 1; //undo 2's complement
butterflies = -butterflies; //make negative after the cast to double
}
else
butterflies = number & value_mask; //filter out the number
butterflies /= 16; //shift the decimal 4 bits over
number >>= 8; //shift over 8 bits
}
return floats;
}

int main()
{
auto num = 0b1010'0011ull;
auto flying= longlong_complement_To8floats(num);
for(auto& bee : flying){
std::cout << bee << std::endl;
}
}

>> No.64580283
File: 32 KB, 500x491, 1516810977546.jpg [View same] [iqdb] [saucenao] [google] [report]
64580283

>>64580199
>>64580206

>> No.64580301

>>64580206
in what context? 32 bit os/application?

>> No.64580352

>>64580206
Delete this before it goes on my resume. Delete this.

>> No.64580408

>>64580277
Ah I'm using the wrong terminology then, I left the thread for a bit to implement a ghetto function and it looks similar to what you provided, thanks for the assistance.

>> No.64580888

Just started learning

This program is supposed to print prime numbers, starting at 3, if you enter y it gives you the next prime number

Can anyone explain to me why it terminates after entering y once?

#include <stdio.h>

int main (void)
{
int number, modulus;
char cont;
number = 2;
start:
modulus = 2;
while (number % modulus != 0 && modulus * 2 <= number){
modulus += 1;
}
if (number % modulus == 0){
number += 1;
goto start;
}
else {
printf("\n%d\n", number);
number += 1;
printf("\nContinue? ");
scanf("%c", &cont);
if (cont == 'y') {
goto start;
}
}
}

>> No.64580937

what are some good resources to lurk to become a wizard windows c++ programmer

>> No.64580967

>>64580888
Why are you using a goto for this? Most people recommend never using goto because idiots will likely fuck up when using dynamically allocated memory, you don't need to use it especially being new, rewrite this using a loop and you will see what you did wrong.

>> No.64580976

Anyone here tried doing cryptoexchange automation using their API?

>> No.64580982

>>64580967
Ok, any other advice regarding my style?

>> No.64581000

>>64576993
I met a guy online who was an expert at Haskell but wasn't a career computer scientist -- can't remember what, but he did something completely different for work.

Programming was just a hobby for him and he didn't want it to be a job. Apparently he'd been using FP exclusively for so many years that imperative languages started to become hard to read at all.

>> No.64581018 [DELETED] 

>>64580982
>To use the Code tag, book-end your body of code with: and

>> No.64581034

>>64580982
>To use the Code tag, book-end your body of code with: \[code\] and \[/code\]
It'll help us actually see your style

>> No.64581043

>>64577804
I like your bugman gifs

>> No.64581063

Pulling my hair over stupid Javascript bullshit frontend code messing with my beautiful, sweet, majestic API

>> No.64581077

https://www.reddit.com/r/rust/comments/7utj4t/reddit_is_hiring_a_senior_rust_engineer/
>Reddit is hiring a Senior Rust Engineer
Mainstream acceptance is here.

>> No.64581102

>>64581077
The meme lives on

>> No.64581107

>>64581077
why do they even use markdown ffs

>> No.64581225

>>64581077
Rust is officially redditlang

>> No.64581246

>>64580937
Windows System Programming by Hart and/or Windows Via C/C++ by Richter and Nasarre
Then Windows® Internals by Russinovich, Solomon, and Ionescu

>> No.64581250

>>64576916
Because it is

>> No.64581254

>>64580888
int main()
{
int number = 2;
char cont='y';
while(cont=='y'){
int modulus = 2;
while (number % modulus != 0 && modulus * 2 <= number){
modulus += 1;
}
if (number % modulus == 0){
number += 1;
}
else {
printf("\n%d\n", number);
number += 1;
//std::cout << "\nContinue? " << std::flush;
//std::cin >> cont;
printf("\nContinue? ");
fflush(stdout);
scanf(" %c", &cont);
}
}
}

>> No.64581264

>>64581254
The line scanf("%c", &cont) grabs new lines and white spaces with the "%c". To get rid of them use " %c" with a space in front (or just use cout and cin like a normal person). Also just use a while loop if you have a trivial goto loop.

>> No.64581304

If a thread finish its function before the parent thread hit the join instruction,
Will the child thread do a busy waiting or suspended as normally?

>> No.64581336

>>64581304
The thread dies.

>> No.64581361

>>64581246
danke senpai

>> No.64581377

pep8 in pycharm is cancer

>> No.64581380

Reminder to read a lot of books and keep yourself hydrated.

>> No.64581399

Why did dpttxt guy stop posting?

>> No.64581400

>>64581380
books are for theory nerds
engineers that actually build shit, read stackoverflow

>> No.64581482

>>64581400
t. python ""engineer""

>> No.64581512
File: 80 KB, 540x720, I6CPeLm.jpg [View same] [iqdb] [saucenao] [google] [report]
64581512

>>64576041
What do I need to study if I want to make money?

I know JS, C#, Java, Lua, XML (+ JSON?) and have made a few projects. I want to learn more and do more and I eventually want money. What more is there?

>> No.64581555
File: 58 KB, 317x329, 1491341314209.png [View same] [iqdb] [saucenao] [google] [report]
64581555

>I know XML and/or JSON
This always me chuckle.
There's literally nothing to know, why do people even bother to mention it.
Even the cleaning guy with an IQ of 55 "knows" JSON.
You think it makes you look smarter because you have two more acronyms in your resume ?

>> No.64581566

>>64581555
> There's literally nothing to know
xsd, xslt, xpath, xquery, etc.

>> No.64581588
File: 135 KB, 1275x718, dont think imasine.jpg [View same] [iqdb] [saucenao] [google] [report]
64581588

how doe i stop being a wage cuck and start learning things again

all i do is dumb angularjs stuff 8 hours a day

>> No.64581596

Which IDE do you guys use for ANSI C?

>> No.64581597 [DELETED] 

So I'm learning over here... have started on Linux and liked it a lot (after being a Windowsfag overclocker) and have moved on to OpenBSD... the default shell is Korn shell.

I have #!/bin/ksh
for i in 1 2 3
do
echo "Print $i"
done
This prints:
Print 1
Print 2
Print 3

I read that #!/bin/ksh
for i in {1..3}
do
echo "Print $i"
done
would print the same, but it prints:
Print 1..3

Anyone got any ideas, tips? I really don't want to have to type in 1 2 3 4 5 6 7 8 for my loops
Cheers

>> No.64581604

>>64581336
rip

>> No.64581612

>>64581596
>ANSI C
use vim or emacs if you're going to be that much of a hipster fag

>> No.64581615

>>64581612
>hipster
That's what my university is making us learn.

>> No.64581619
File: 120 KB, 720x960, 1516397459959.jpg [View same] [iqdb] [saucenao] [google] [report]
64581619

>>64581555
>being this insecure about your intelligence
>being this resentful because of someone's competence

>> No.64581638

>>64581615
oh lord

don't they tell you what to use? try eclipse, it's underrated

>> No.64581652
File: 5 KB, 250x203, 1516523865685.jpg [View same] [iqdb] [saucenao] [google] [report]
64581652

>>64577730
>It's not so bad if your classes are immutable

>> No.64581668
File: 9 KB, 201x251, brainlet-suicide.jpg [View same] [iqdb] [saucenao] [google] [report]
64581668

>>64581555
>You think it makes you look smarter because you have two more acronyms in your resume ?
Yeah, that was pretty much my reasoning.

>> No.64581669

>>64579629
i made one in basic once

>> No.64581677

>>64581588
>how doe i stop being a wage cuck
You don't.

>and start learning things again
You just do it.

>> No.64581686

>>64581588
Join a start-up

>> No.64581697

>>64576859
in C++ you wrap functions in namespaces anyway it's not even weird

>> No.64581714

>>64581697
>namespaces are classes

>> No.64581730

>>64581697
>using namespace moot::cock::juices::semen::sperm::spermatozoa;

>> No.64581735

>>64581697
I don't.

>> No.64581745
File: 64 KB, 610x660, 1475455485173.jpg [View same] [iqdb] [saucenao] [google] [report]
64581745

>>64581730

>> No.64581747

>>64581714
java doesn't have namespaces, it's a different language get over it

>>64581730
>>64581735
kys

>> No.64581787

>>64581747
The Java analogy to C++ namespaces is packages.

>> No.64581826

>>64581787
// Nigger.java

class Nigger {
static void nig() {}
}


// nigger.cpp

namespace nigger {
void nig() {}
}


>BUT IT'S A CLASS REEEEE

>> No.64581827

>>64576859
Java doesn't even force oop hard. This is just retardation.
Look to self for actual oop.

>> No.64581843
File: 12 KB, 359x510, 1517560220884.png [View same] [iqdb] [saucenao] [google] [report]
64581843

Anyone know the font?

>> No.64581847

I'm generating a sequence of vector<int>, and I want to detect when a duplicate of a previous vector is generated. What do you think the best way to go about this would be? I thought maybe storing the sequence in an unordered_map would be suitable, but I'm not sure.

>> No.64581860
File: 277 KB, 3000x2584, JA1y4DR.png [View same] [iqdb] [saucenao] [google] [report]
64581860

Sink operation shouldn't be this much tedious, right? Am I missing something (apart from IQ)?

proc sink*[T](heap: var Heap[T], index: int) =
var i = index
if heap.kind == HeapType.Max:
# When sinking down the binary heap, these scenarios might happen:
# 1.1 Both children are smaller:
# Stop
# 1.2 One of them is smaller and one of them is bigger:
# Swap with the bigger one
# 1.3 Both bigger:
# Swap with the bigger of the two
# 2.1 One child, which is smaller:
# Stop
# 2.2 One child, which is bigger:
# Swap
while heap.size >= 2*i:
# if 2i + 1 exists (two children) (1.x):
if heap.size >= 2*i + 1:
# 1.3 and 1.2:
if heap.data[2*i] > heap.data[i] or heap.data[2*i + 1] > heap.data[i]:
if heap.data[2*i] > heap.data[2*i + 1]:
swap(heap.data[i], heap.data[2*i])
i = 2*i
continue
# else:
swap(heap.data[i], heap.data[2*i + 1])
i = 2*i + 1
continue
# else (1.1):
break
# else (2.x):
# 2.2:
if heap.data[2*i] > heap.data[i]:
swap(heap.data[2*i], heap.data[i])
i = i*2
# else (2.1):
break
# else if heap.kind == HeapType.Min:
# TODO!

>> No.64581876

>>64581860
you calculate 2*i and 2*i+1 a lot

>> No.64581877

>>64577878
fun

>> No.64581895

>>64577910
Oops, I meant Koding

>> No.64581900

>>64581847
Will you have arbitrary inserts or just push_back? Are you comparing to multiple 'old' vectors?
If you're doing pushback you can just check if the last element matches and when it doesn't you set a flag saying that you no longer match.
If you have multiple you can make an array (or vector) with a boolean element for each of the vector that you set as they begin to fail.
Not sure if branching on this bool to skip the additional compares is worth it. Hard to predict. For sufficiently many vectors it is though.

>> No.64581913

>>64581900
Just push_back. I am comparing to all old vectors for each new one I generate. I forgot to mention, but the program concludes when I've detected the first duplicate.

I'm doing this puzzle if you're interested in the details: https://adventofcode.com/2017/day/6

>> No.64581922

>>64581913
>Just push_back.
No, nevermind. I'm doing arbitary inserts, yea.

>> No.64581984

>>64581913
That's a bit different from what I was expecting. Because you're destructively modifying the banks you need to store them out somewhere to see if you match any of them after each step.
Storing them in a hash map isn't a terrible solution. But as with most competitive programming challenges they probably put in something clever for you to do.

>> No.64582012

New thread:
>>64582008
>>64582008
>>64582008

>> No.64582035
File: 257 KB, 1211x958, Screenshot from 2018-02-03 23-46-51.png [View same] [iqdb] [saucenao] [google] [report]
64582035

>>64581860
Sedgewick writes this as pic related. This does not check if 2k+1 is bigger than N in the first place.

This is so frustrating.

>> No.64582912

>>64581555
For a job I interviewed for, I was specifically asked if a "knew XML" because it wasn't on my resume, and afterwards they asked me to include it on there. Of course what they really meant was >>64581566. Luckily, despite being virtually clueless about these beforehand, they aren't difficult to pick up within a few weeks.

>>
Name (leave empty)
Comment (leave empty)
Name
E-mail
Subject
Comment
Password [?]Password used for file deletion.
Captcha
Action