[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: 30
File: K&R himegoto waifux2.png (1 MB, 1000x1400) Image search: [Google]
K&R himegoto waifux2.png
1 MB, 1000x1400
old thread: >>54017882

What are you working on, /g/?
>>
>Fagposting
Delete this shit and kill yourself
>>
>>54026777
F# of course
>>
>>54026777
himegoto sucked kill yourself
>>
>>54026777
fuck this thread, this is the real thread >>54026858
>>
File: kid.jpg (38 KB, 362x346) Image search: [Google]
kid.jpg
38 KB, 362x346
Where is a good place to start if I want to reverse engineer an MMO and make a private server for it?
>>
>>54026868
Mastering ollydbg and wireshark would be a start.
>>
>>54026868
not gonna happen
>>
>>54026868
stopping, and doing something else instead.
>>
File: 34761567_p0.jpg (1 MB, 1642x877) Image search: [Google]
34761567_p0.jpg
1 MB, 1642x877
>>54026777
How do I scale textures in OpenGL 3.3+ preserving aspect ratio?
I would like to also do interpolation in the shader.
Do I scale in the shader as well or no?
>>
>>54026868
If you have to ask, you're already in way over your head.
That said, Google information other people have found out, Wireshark, Olly.
>>
>>54026868
Assuming you have a source leak, just configure it to be buildable and then figure out how the game finds its servers i.e realmlist for WoW. Find that, change it to your server's domain or IP and your done.

If you don't have a source leak, disassemble the game into raw assembly with IDA or some that and reverse every single function relating to server/client communication and scrape together a C++ project that can handle multiple clients connecting and request packets at once, all accessing a database with all sorts of information (spells, player info etc) at once. To fill your database with information is your own deal. Then you still have to deal with desynch, changing the client server, handling movement, verifying the client isn't cheating, forming proper response packets etc.
>>
adding redundant dependencies to my project
>>
>learning openscenegraph
>osgexporter supports animation exports
>except it didn't for the past 3 years or so
>except the last release of the exporter is from last year so it can't export animations
>except the latest source version is broken and can't export anything at all
REEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE

What's the best way to export animations in that case? Should I just load the model in another software for animation only and then export that as a different format to load manually?
>>
Anyone know LC-3 Assembly and wants to do a programming assignment for me? $50.
>>
>>54026895
>>54026932
>>54026938
Thanks guys, I've done man in the middle type of stuff in the past to cheat in games, but never something this big.

I plan to take it nice and slow, no rush.
>>
>>54026999
>fucking $50
Unless you can explain what you want in less than an hour, you are literally not getting a single character of code out of that.
>>
>>54027015
>~60 lines of code for more than $50

I should have explained thoroughly.

I'm tasked with traversing two double-linked lists and being able to remove a node from one and add it to the other. This should be babby-tier work for anyone who programmed in LC-3 Assembly before, but if that's not $50 worth then I'm jealous of your $100k/yr position
>>
C newfag here.
is an array an expression?
can I do
switch (array)
case [1, 2, 3]:
killmyself();
break;
>>
>>54027000
https://github.com/TrinityCore/TrinityCore
Here's some more material, its an open source server for WoW. If you can understand some of the stuff going on it, try improving your programming skills and knowledge before going any further.
>>
>>54027055
no, arrays are just addresses. Unless bout your case and your array refer to the exact same array, and NOT simply an identical one, it won't work
>>
>>54027080
alright, thanks f.am
>>
>>54027055
unsigned i;
for (i = 0; i < obj->size; i++)
{
switch (obj->arr[i])
{
case 1:
case 2: /* fall through */
case 3: killyourself(); break;
default: break;
}
}
>>
>>54027055
int array[3] = {1, 2, 3};

switch (array) {
case array:
thisWorks = 1;
break;
case {1, 2, 3}:
thisWorks = 0;
break;
}
>>
File: 3f3ncsU.jpg (28 KB, 554x366) Image search: [Google]
3f3ncsU.jpg
28 KB, 554x366
>finally found where all the C and C++ jobs are at
>it's finance
>>
>>54027105
>
obj->size

sorry, but what does the "->" do?
>>54027116
I see, it just compares the adresses
>>
File: hpspectre.jpg (27 KB, 630x354) Image search: [Google]
hpspectre.jpg
27 KB, 630x354
is this code subpar?

Ho are you supposed to be sure that file was downloaded 100% properly. What if server will dc during download?

How to assure that nobody is trying to use file while you are overwriting this file with new version?

Is there any place that I could read about good practice for this kind of stuff?

try {
URL url = new URL(urlToDownload);
URLConnection connection = url.openConnection();
connection.connect();



InputStream input = new BufferedInputStream(connection.getInputStream());
OutputStream output = new FileOutputStream("/sdcard/BarcodeScanner-debug.apk");

byte data[] = new byte[1024];

int count;
while ((count = input.read(data)) != -1) {
output.write(data, 0, count);
}

output.flush();
output.close();
input.close();
} catch (IOException e) {
e.IOexception();
}

>>
File: akari eats chippus.png (131 KB, 256x256) Image search: [Google]
akari eats chippus.png
131 KB, 256x256
Still working on my tripcode searcher~
Now compatible with OS X and Windows!

https://github.com/microsounds/tripforce
>>
>>54027144
>Ho are you supposed to be sure that file was downloaded 100% properly.
You start your packet with a length and checksum. If either don't match then it's corrupted

>What if server will dc during download?
Your socket will error on write if it closed during it or a flush.
>>
>>54027142
it assumes that you're smart enough to abuse C structs and treat them like dynamically allocated objects

surely, if you're passing arrays between functions, you'd at least want to store the size, right?
>>
>>54027106

The best way is to do it this way. Int and string don't play nicely together.
>>
>>54027142
it's the same as saying (*obj).size
>>
>>54027142
>sorry, but what does the "->" do?
It's the arrow operator. It dereferences a struct/union pointer and accesses a member
It's equivalent to (*ptr).member, but much nicer to write.
>>
>>54026999
I was told that shit isn't used outside of babby's first assembly class.
>>
File: 1422280327271.jpg (152 KB, 787x578) Image search: [Google]
1422280327271.jpg
152 KB, 787x578
>>54027173
int *x = malloc(sizeof(int)*5));
int size = *(x-1);


Works on operating systems with a libc made for programming
>>
>>54027215
That's undefined behaviour, you dumb frogposter.
>>
Reminder that pointers are deprecated by move semantics and RAII
>>
>>54027215
I think you meant to offset by the size of 1 int? Otherwise you are indexing into uncharted territory.
>>
/dpt/ I've been hearing a lot about web dev dying.

Is that just front end, or is back end dev being replaced by shit like squarespace too??
>>
>>54027227
>>54027258
>Works on operating systems with a libc made for programming

wincucks get fucked
>>
>>54027284
That doesn't make it any less undefined you fucking retard.
>>
>>54027296
learn your system kid. There is well defined behavior for it once you learn to read your libc source.
>>
>>54027316
Do you even know what undefined behaviour means in the context of C?
Your libc is under no obligation to have consistent bookkeeping on its memory allocations, and could completely change it between versions if they wanted to.

Frogposters really are the cancer of this website. Fucking end your life.
>>
>>54027196
Thank you.
>>
>>54027354
Since you seem to have bad reading skills let me repeat:
>learn your system kid. There is well defined behavior for it once you learn to read your libc source.
>>
>>54027368
C is defined in terms of the C abstract machine, not your implementation.
Indexing outside the bounds of your memory allocation is undefined behaviour, no matter how you look at it.

If you think undefined behaviour in your program is acceptable, seriously end your life.
>>
>>54027384
Good to know you have horrible reading skills and have no clue how the program interacts with the rest of your system let alone libc function calls.
>>
>>54027399
Where in the standard does it say that "it's okay to index outside of malloc blocks, if you know how your libc was implemented"?
>no clue how the program interacts with the rest of your system let alone libc function calls
That has fucking nothing to do with what we're talking about. We're talking about all of your shitty programs exhibiting undefined behaviour.
>>
File: crying umaru.jpg (36 KB, 600x337) Image search: [Google]
crying umaru.jpg
36 KB, 600x337
Why do people make fun of me when they learn that I write all my programs in C?
>>
File: ZiA.png (221 KB, 1920x1080) Image search: [Google]
ZiA.png
221 KB, 1920x1080
what went wrong?
>>
>>54027422
You are very dense. Learn how programs actually work before posting again.
>>
>>54027427
People fear that which they do not understand.
>>
>>54027431
I know how programs and their ABIs work you fucking idiot.
Learn how standards work before posting again.
>>
>>54027428
your color scheme
>>
>>54027428
m8...
>>
>>54027439
You clearly don't if you think what was done is going to have undefined behavior given you know how your libc malloc works.
>>
File: 1432860473789.png (40 KB, 335x342) Image search: [Google]
1432860473789.png
40 KB, 335x342
>>54027454
You clearly don't know what undefined behaviour means, you colossal moron.
Just because something appears to "work", it doesn't mean that it's not undefined behaviour.
>>
>>54027428
>1999 + 17
>still using int where bool is appropriate
>>
>>54027491
Your ignorance of how a program executes after compilation is not grounds for trying to act like you know how everything works on /dpt/.

I get it, you don't know understand how the whole program actually operates on your OS and only know about what your petty standard tells you. It's okay to be wrong anon.
>>
>>54027427
Because other people are not as retarded as you are.
>>
>>54027505
>petty standard
I don't know how you can call yourself a programmer. I can't even comprehend your retardation.
>>
/g/, will back-end development still be a thing in a few years, or will squarespace replace that too?
>>
>>54027526
The only people who unironically use C in /dpt/ are all like that.
>>
>>54027262
Boost is awesome faggot. Fuck off.
>>
>>54027526
And I can't even comprehend your ignorance despite you trying to act like you know everything.
>>
>>54027531
You best find yourself a new line of work.
the webdev startup bubble is about to burst

startup culture where every company's goal is to get bought out is completely unsustainable.
>>
>>54027428
tard any number != will return true
>>
>>54027556
#include <stdio.h>

void fn1()
{
int a = 10;
}

void fn2()
{
int b;
printf("%d\n", b);
}

int main()
{
fn1();
fn2();
}

>Who cares if it had undefined behaviour!
>YUU JUST DUN KNOW HOW THE COMPUTA WERKS XDDD
>>
>>54027428
Name your god damn variables. There is no worse habit than using single character variable names.
>>
>>54026777
Kind of a novice at making programming projects that aren't for a class... I'm trying to make a music visualizer (Think the ones with the bars that give you the frequency at each instant).

I'm having a bit of an issue... I'm following this one stackexchange post that tells me to write the music file's raw data to an array through the use of a "circular bufffer," and then use an FFT.

I know (sort of) how a DFT works, and I copy+pasted the FFT code from Princeton's CS website, am I on the right track? Because chances are I'm going to discover new levels of stupidity if I continue on this path.
>>
>>54027586
Look at that, you can't even put together a comparable example and instead resort to compiler behavior which, despite being the same version, can generate vasty different code depending on optimization level and other factors.

Meanwhile with the same version of libc, the header of a malloc is well defined and isn't going to change unless you change versions to one that may have changed the header.


Grats on showing off your stupidity once again.
>>
>>54027615
You need to use an FFT definitely. Sounds like the right path so far. Just make note assuming you're using C++ there's an FFT library out there that does a lot of the heavy lifting.
>>
>>54027644
F F T W
F
T
W
>>
>>54027562
It's what I'm doing. Right now C and Java seem to be in the highest demand, but all those jobs are in the financial sector which I do not want to get involved with
>>
File: maximum over lel.jpg (379 KB, 1111x597) Image search: [Google]
maximum over lel.jpg
379 KB, 1111x597
Why are C programmers so autistic?
>>
>tfw have to format data into JSON with no heap, 400B of stack, and no knowledge of how much data there is in total
Just shoot me senpai. This is some ugly-ass code.
>>
>>54027622
Undefined behaviour is all the same. If your program has it, it's automatically shit. It's even worse that you're doing it knowingly.
Just because you can "predict" the outcome, it doesn't make it any less undefined or any less retarded. The implementation has absolutely no obligation to keep the same behaviour, even on the same version. You're making your code stupidly non-portable and flat out incorrect.
Now disregarding the standard is the most fucking retarded thing you can do. You're writing in the C programming language, not "I do whatever I want because everything I do is valid".
>>
>>54027661
They have you scraping web data on microcontrollers or something?

What the fuck dude.
>>
>>54027660
they're autistic only to people too slow and dense to grasp it lel
>>
>>54027680
>The implementation has absolutely no obligation to keep the same behaviour

once again you have no clue what you're talking about.

The act of *(x-1) is well defined in the C language. It will generate proper code to do such an operation.

The undefiness of it is the value at *(x-1), not the operation you idiot.

The value of *(x-1) is well defined given the libc version which doesn't magically change at will without you knowing.


Congratulations on once again showing off your ignorance for how programs and compilers actually work.

Go ahead and reformat your post and send the same ignorant comment back so i can keep resending you how ignorant you are of how programs work.
>>
>>54027644
I don't suppose using Java (the language I'm most familiar with) would be a good idea...
>>
>>54027683
Close. The client wants something that can read data in from some sensors then transfer it by USB.
This would be fine, but he wants the USB device to be a HID keyboard so he doesn't have to install any extra software. So that means doing all the formatting in the controller and printing out everything character by character.

I don't understand it either.
>>
>>54027714
What happens when you do update your libc and have to change all your code?
>>
>>54027661
>400B stack
>no heap

wot
>>
>>54027714
>The undefiness of it is the value at *(x-1),
Oh, look at that.
You just proved my point.
>>
>>54027739
you read the new libc source code, find out where in the header the information you need to get the size is and you update your SIZE macro in your void.h. Then you just recompile all your stuff.


>>54027753
Oh look, you don't even know what the standard says.
>>
Writing an OS.
>>
>>54027723
Well, it's good for the GUI. Really all a bar visualizer is, is a FFT that sections off ranges of frequencies. For Java there's a really good sublanguage called Processing that might suit your fancy.
>>
>>54027765
http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf
>§6.5.6
>Page 83
>8
>If both the pointer operand and the result point to elements of the same array object, or one past the last element of the array object, the evaluation shall not produce an overflow; otherwise, the behavior is undefined
>>
>>54027841
>>54027765
BTFO
>>
>>54027841
>>54027851

Try again kid, that's not even the proper part of the standard and if you learn to read you would see:
>The value of *(x-1) is well defined given the libc version which doesn't magically change at will without you knowing.

It's okay to admit you're wrong because you don't know how programs work anon.
>>
File: bird.png (31 KB, 581x556) Image search: [Google]
bird.png
31 KB, 581x556
Why is /dpt/ ruined every time by C autists?
>>
File: arguements won.png (15 KB, 528x434) Image search: [Google]
arguements won.png
15 KB, 528x434
>>54027859
Ok, you're just trying to play it off as bait, just because you realised that you're fucking wrong.
>>
>>54027660
Because it's the base requirement to unironically use C.
>>
>>54027878
>Frogposter
>Acting like they're not everything that is wrong with this website
>>
>>54027878

People have to know that they're using an ancient language to make things harder on themselves.

Pretty sure it's a form of masochism.
>>
>>54026777
what does this anime girl have to do with progamming?
>>
>>54027859
>that's not even the proper part of the standard

GOLD STANDARD DAMAGE CONTROL
>>
>>54027880
Except i'm not and the behavior is well defined as stated in >>54027714

Maybe you should learn to read your own standard. The operation is well defined, the result is not which is then well defined given libc malloc implementation that defines what's before the malloc of any bytes allocated. This is now that 5th+ time this has been repeated because you can't seem to read nor understand how programs work.

Good
Day
Sir
>>
>>54027901
see >>54026865
>>
>>54027878
Because they're the most ignorant and incompetent group of programmers in the world.
>>
>>54027897
>frog

I may have bad eyesight but even I can tell the difference between a bird and a frog.
>>
>>54027911
You're beyond saving. Even after given irrefutable evidence, you still try to assert your retardation.
Kill yourself. There is no hope left for you.
>>
>>54027929
Since you still can't read i'll keep repeating:

Maybe you should learn to read your own standard. The operation is well defined, the result is not which is then well defined given libc malloc implementation that defines what's before the malloc of any bytes allocated. This is now that 5th+ time this has been repeated because you can't seem to read nor understand how programs work.

Your ignorance is not a valid reason for you being stupid online.
>>
I'm trying to autovectorize the Integral Imagen problem to make use of the Ymmx vectors of the Xeon processor of the server in which we are working. But it looks like I'll have to make it manually, gcc does not vectorize it :/
>>
>>54027941
I never fucking said that ptr[-1] is undefined. I know that it fucking is.
I've been talking about indexing outside of valid memory you fucking retard.
>>
>>54027948
-march=native retard
>>
>>54027941
he literally showed the standard that says otherwise

How do you even breathe on your own?
>>
>>54027954
Keep reading anon, you've almost made it a quarter of the way through


Maybe you should learn to read your own standard. The operation is well defined, the result is not which is then well defined given libc malloc implementation that defines what's before the malloc of any bytes allocated. This is now that 5th+ time this has been repeated because you can't seem to read nor understand how programs work.
>>
>>54027773
Alrighty... I think I could do Processing, but nothing wrong with learning C++, right?
>>
File: Xmonad Timer 02.png (233 KB, 1360x768) Image search: [Google]
Xmonad Timer 02.png
233 KB, 1360x768
>>54026777
Someone explain me how to do this?
>>
>>54027967
Nope, I would suggest it to anyone willing to get better at programming.
>>
>>54028004
Do what, make a timer?

Are you fucking retarded?
>>
>>54028004
>CSS tricks

>>/wdg/
>>
>>54028004
wew that theme you must be an edgy h4X0R
>>
>>54028004
what site is this?
>>
How do I stop myself from over-engineering things? I always come up with the most complicated solutions for the most simple problems.
>>
>>54028111
average two ints in C
>>
>>54028149
int a = (1+1)/2;
>>
>>54028111
Explain your solution to a duck.
>>
>have almost 3000 different multi-word strings
>some of them might as well be sentences
>consider getting fancy and using an algorithm to search said ~3000 "sentences"[

or I could just do

var haystack = '3000names.json';
var results = haystack.filter(x => x.indexOf('needle') != -1);
>>
>>54028164
What if I don't want to average 1+1?
>>
>>54028111
Agile methods are pretty much designed to answer this question.
>>
>>54028241

Here it is in C#:

var results = "3000names.json".ReadAllLines().Select(x => x.Contains("needle"));


what do I win?
>>
>>54028274
>agile methods are pretty much designed to answer this question
>agile methods
>agile

no
>>
>>54028311
we're not using scripting languages.
>>
>>54028322
Yes.
>>
>>54028265
int a;
int b = (a+a)/2;
>>
>>54028342

wew
>>
>>54028311
The point i was trying to make is that I could do the task with a simple call to a function like grep / filter, however, it's going to be slower than if I use an actual algorithm
>>
>>54028353
What if I want to average two different numbers?
What If a+a overflows?
>>
File: ctards will defend this.png (2 MB, 1920x1080) Image search: [Google]
ctards will defend this.png
2 MB, 1920x1080
C programs and their respective Haskell versions
>inb4 buttmad
>>
>>54028377
int a;
int b = a/2 + a/2
>>
>>54028367

Probably not too much slower. Depends how string searching is done. KMP is pretty slick.
>>
>>54028401
>trying to compare languages when you're shit at writing both

pls leave
>>
>>54028401
Your haskell programs are doing all that C shit underneath.
>>
>>54028401
Is there a worse group of people on /g/ than ricers? They're really annoying.
>>
>>54028401
>abstracting functions in haskell
>HURR DURR THAT MAKES IT BETTER
>what are libraries

fuck off autist
>>
>>54028403
What if I want to average two different numbers?
>>
File: lel.gif (422 KB, 212x213) Image search: [Google]
lel.gif
422 KB, 212x213
>>54028401

fib 0 = 0
fib 1 = 1
fib n = fib (n-1) + fib (n-2)


T1{_2$+}A*]`


Haskell programs and their respective CJam versions
>inb4 buttmad
>>
>1 millisecond to search 3000 strings each for a substring
this is retarded please someone tell me im doing my test wrong
the performance of .filter can't be this good
i need more complex strings, maybe a longer "needle" string too
>>
>>54028401
>unnecessarily reimplements strlen and strcpy
>uses library functions in the haskell version
>includes a main function in the C program
>doesn't even call the haskell function
>thinks the complaint is going to be 'muh speed'
he's so dumb, I don't think he realises just how dumb he really is
>>
File: 1456881048131.gif (2 MB, 189x392) Image search: [Google]
1456881048131.gif
2 MB, 189x392
>>54028443
tell me a better way to implement all the Haskell versions, fag
>>54028452
copy pasting some fags rice is ricing?
Kys
>>54028467
>being productive is not better
good post t.bh. f.am
>>54028505
>>>/unreadable/
nobody's ever heard of that shitty lang m8
>>
>>54028401
why is Haskell so perfect?
>>
>>54028539
>being productive is not better
>WHAT ARE LIBRARIES HURR DURR

You are retarded
>>
>>54028529
he knows haskell and just started learning C and isn't enjoying it
>>
>>54028539
+/!∘⌽⍨⍳⍵


>haskell programs and their APL versions

Who's functional now, bitch? Productivity all day long
>>
>>54027767

What architecture? What language? Monolithic, Hybrid, or Micro kernel?
>>
>>54028582
>>>/unreadable/
>>
>>54028524
why do you think its supposed to be slower? there is a metric fuckton of work put into ionmonkey. (try it with a newish v8 for even better results) (or with typed arrays in ionmonkey)

also a 3000 string sample size is a trivial amount of work. a better benchmark would let you test ops per microseconds (you'd need a much larger sample size and calculate an average.)
>>
File: 1460598916863.webm (3 MB, 1280x720) Image search: [Google]
1460598916863.webm
3 MB, 1280x720
which prog language does this best represent?
>>
>>54028572
probably because he's a gigantic fucking retard and is more invested in 'proving' haskell is better than C than actually using C properly
>>
>>54028604
>2 second video
>2.65MB
>It doesn't even look that good
>>
>>54028604
ahaha why the hell is he doing that
>>
>>54028524
3000 strings is literally nothing for a computer. That guy's tripcode generator can get to 300k gens per second and that has to go through a crypt.
>>
>>54028401

Any reason you're switching brace styles between programs?
>>
>>54028627
working out his fellatio game
>>
>>54028529
Even if u take out the getsize() and copy()
, it's ten times longer u fag
>>
>>54028604
C
putting in twice the effort but going mad fast
>>
>>54028604
PHP
>>
/* 
; int __stdcall sub_59CA80(char *, int)
sub_59CA80 proc near

var_10= dword ptr -10h
var_C= dword ptr -0Ch
var_8= byte ptr -8
var_2= byte ptr -2
arg_0= dword ptr 4
arg_4= dword ptr 8
*/
int sub_59CA80(char *fn, int x)
{
//sub esp, 10h
//mov eax, [esp+10h+arg_4]
//push ebp
//push esi
//push edi
//mov edi, [esp+1Ch+arg_0]
//push 180h
//mov esi, ecx
//push 8000h ; int
//push edi ; char *
//mov [esi+8], eax
//call __open
int fd = open(fn, 0x8000);
//mov ebp, eax
//add esp, 0Ch
//cmp ebp, 0FFFFFFFFh
//mov [esp+1Ch+var_10], ebp
//jz short loc_59CB08
if(fd == -1) {
goto loc_59CB08;
}


//No idea
//mov ecx, esi
//call sub_59C430
//mov eax, edi
//lea edx, [eax+1]
//lea ecx, [ecx+0]


loc_59CAC0:
//No idea
//mov cl, [eax]
//inc eax
//test cl, cl
//jnz short loc_59CAC0

//No idea
//sub eax, edx
//add eax, edi
//push eax ; int
//push edi ; void *
//lea ecx, [esi+1Ch]
//call sub_418530

//push 6 ; unsigned int
//lea ecx, [esp+20h+var_8]
//push ecx ; void *
//push ebp ; int
//call __read
char sig[6];
read(fd, sig, 6);

//push 6 ; unsigned int
//lea edx, [esp+2Ch+var_8]
//push offset aFgf300 ; "FGF300"
//push edx ; void *
//mov [esp+34h+var_2], 0
//call __memicmp
//add esp, 18h
//test eax, eax
//jz short loc_59CB13
if(strncmp(sig, "FGF300", 6) == 0)
goto loc_59CB13;

//sig did not match
close(fd);
goto loc_59CB08;


loc_59CB13:
//...

loc_59CB08:
//pop edi
//pop esi
//xor al, al
//pop ebp
//add esp, 10h
//retn 8
return 8;
}


I'm not even far into this and i'm already have trouble
>>
>>54028632
>>54028602
jayzus, looks like changing it from an array of strings, to an array of objects and then searching a member of the object, didn't change the performance at all


the reason i assumed the performance would be ass was because my web application was lagging to shit when using some 3rd party widget thing. i guess the answer is... don't try to append 3000 nested divs to the DOM in HTML. Lol..
>>
File: 1456291922444.gif (1 MB, 223x155) Image search: [Google]
1456291922444.gif
1 MB, 223x155
>>54026777
Are there any good audiobooks on programming?
>>
>>54028694
>audiobook

why would you even...
>>
>>54028694
This would be on my top ten list of things I would never recommend
>>
File: AAAAAAAAAAA.jpg (9 KB, 342x342) Image search: [Google]
AAAAAAAAAAA.jpg
9 KB, 342x342
>>54028694
>how to implement a for loop
>for left parantheses int i equals zero semicolon i less than sign uppercase max semicolon i plus plus right parantheses press enter left bracket
>>
>>54028691
repainting and reflowing the dom is completely different than iterating through an array, though.

(using something like deferred painting, or a shadow dom would fix your problem)
>>
>>54028596
fibs = let f a = sum a : f (a >>= ([[0,1], [0]] !!)) in f [0]


>"readable"
>>
>>54028539
>copy pasting some fags rice is ricing?
Yes?

On top of that they're always so desperate to fit in. It's kind of sad really.
>>
>>54028731
>[..] plus plus i right parentheses left bracket enter

ftfy
>>
>>54028640
At twice the effort, your C program will be slower than the equivalent python program. If you want to write a fast C program, you have to look at, in the lower end, ten times the effort.
>>
>>54028763
(You)
>>
>>54028763
only if you're an absolute mong
>>
>>54028757
>hay guys C is stupid and haskell is cool i know you guys like haskell I do too am I cool yet guys pls i want to be accepted pls help why do you hate me
>>
>>54028763
C is so fast you can afford to be wasteful as fuck unless you're writing microcontroller code
>>
>>54028763
this is just plain wrong. to get C speed in python you need to use calls to libraries written in C with python wrappers.
the average C program is 10-100x faster than python.
>>
>>54028763
autist...
>>
>>54028753
>writing it complexly on purpose
kys

what I wrote works perfectly and is readable
>>
>>54028694
Learn to read you fucking faggot.
>>
>>54028738
I was thinking about using a web worker (I've never used web workers before) to take care of the dom manipulation
>>
Sorry if this should go in SQT.

I need to make a program in Java that ask the user to make a "strong" password. We're suppose to use methods, but I'm kind of stupid when it comes to them. So I've been trying to test what I can do and make a method on the character length, which needs to be 8. This is what I have.

 while (PassLength(password) == false) {
do {
System.out.print("Enter: ");
password = keyb.next();
System.out.print("Enter again to confirm: ");
rePass = keyb.next();
} while (!(password.equals(rePass)));
}

System.out.println(password.length());
}

public static boolean PassLength(String password) {
if (password.length() <= 8)
return true;
else
return false;
}


I want to do it where the loop continues until the user puts in a password with at least 8 characters. Once the method returns true, it will stop the loop. Is this possible? Or am I asking too much and should just kill myself?
>>
File: dhdfh.jpg (36 KB, 503x378) Image search: [Google]
dhdfh.jpg
36 KB, 503x378
I'm working on a simple program to take user input of a string and tell them if its a palindrome or not.

I know the loop to check the digits for a palindrome but I have no idea why I can't get it to pass by reference in the first place to get to that point.

Is it actually super simple and I'm just a retard? pic related is before I do anything to pass by reference
>>
>>54028784
why r u guys so mad, I was only pretending to be retarded and wanted to troll
can't have fun now?
>>
>>54028838
>using namespace std;
>char array as a string

what the hell
>>
>>54028808
Haskell shills everywhere.

What can haskell do that Lisp can't do for me, and how does haskell even fucking compare to Lisp's symmetry.
>>
>>54028850
T H I S
>>
>>54028850
lisp is also perfect but I prefer Haskell because I like static typing
>>
>>54028850
I write automation code in common lisp at work. AMA.
>>
>>54028838
char buffer[1000];
fscanf(stdin, "%s", buffer);
char reverse[1000];
strcpy(reverse, buffer);
strrev(reverse);
if (!strcmp(buffer, reverse))
fprintf(stdout, "YOU DID IT PUPPER");
abort();
>>
>>54028850
>oy vey, don't call me out for doing something retarded
>here, I'll just call you a shill, because that discredits you
>oy vey, what does Haskell do compared to random lang
>haha, I guess ur beaten
I'll give you something, Haskell doesn't require u to write 300 parentheses
>>
>>54028883
>using namespace std;
He's using C++ dude, use string.
>>
>>54028850
>>54028860
samefag
>>
>>54028808

Were you the fag that write the O(2^n) implementation?
>>
>>54028916
>C++
you mean babby's first C?
>>
>>54028848
I was told to deposit all the characters of the string into an array to analyze it for the palindrome, but I dont understand how that is supposed to carry over into main from the scope of the function.

I assume it has something to do with passing by reference but like you noticed when I do that it mentions that it's not a string.
>>
>>54028936
You don't even know what a pointer is, do you?
holy shit
>>
>>54028928
No, he's literally using C++, look. If you want to be retarded and try to say C++ is a babby langauge then it's better you leave.
>>
>>54028927
fibs = 0 : 1 : zipWith (+) fibs (tail fibs)

is linear, cuck
>>
>>54028077
lainchan
>>
(>>54028850 '(You)
(this))
>>
>>54028883

Writing programs in C that are not vulnerable to buffer overflow is pretty easy. Somehow you managed to fuck up anyways.
>>
>>54028958
jesus christ what an unbearably unreadable theme
>>
>>54028951
but anon, C++ IS a babby language

imagine being so infantile that you need all the wall sockets and sharp doorknobs in your house covered with foam
that's what using C++ is like
You know it's true when C++ users refer to C pointers as "unsafe raw pointers".
>>
>>54028957

Kay. So you're not this guy: >>54028505
>>
>>54028986
yup, I'm not that cuck
>>
>>54028981
pointers are inherently unsafe, you know that right? If you're just going to spew bullshit please LEAVE.
>>
>>54028980
I think it's a userstyle
>>
>>54028981

Rust refers to them as "unsafe raw pointers". C++ just calls them raw pointers to distinguish them from references and smart pointers.

>>54029002

Good. Writing an exponential implementation of a linear problem is never acceptable.
>>
SPOOKY SCARY BABY MURDERING POINTERS
>>
File: K&R watashi kininarimasu.jpg (475 KB, 852x973) Image search: [Google]
K&R watashi kininarimasu.jpg
475 KB, 852x973
When writing a strrev function, should the function:
>overwrite the original string
>dynamically allocate a new string and return a pointer to the reversed string,
>accept a buffer to write the reversed string to?

99% of C programmers will get this wrong!
>>
>>54029062
I'd choose smart pointers over raw any day. You aren't cool for liking unsafe programming elements.
>>
>>54028972

How's this program?

gets(buf);
>>
>>54029097
3rd option
>accept a buffer to write the reversed string to?

stays true to strcopy, etc.
>>
File: browser.png (986 KB, 1035x929) Image search: [Google]
browser.png
986 KB, 1035x929
who /performant/ here?
>>
>>54029097

The third, but it should also return dest.
>>
>>54029120
yeah. The second creates a dangling pointer. The first is just retarded.
>>
>>54029120
this desu
>>
>>54029103

Deprecated/10.
>>
>>54029097
>dynamically allocate a new string and return a pointer to the reversed string,
This
option A will see corrupted results if another thread tries to modify the memory. Option C is tempting because of its explicitness but it complicates the API to the point of needing wrapper functions anyways.
>>
>>54029214
>memory leaks
>>
>>54029028
>raw pointers
>references
>smart pointers

in your own words, what are these?

anyone may reply
>>
>>54029097
how do I garbage
>>
>>54029214
Now you have to free the memory, regardless of whether you want to or not.
With the 3rd option, you can malloc the new string or put it on the stack, but you're doing it explcitly
>>
>>54029214
char* a = "Hello!";
char* b = reverse(a);

Where is the memory leak?
>>
>>54029193

It just works.
>>
>>54029239

Pro-tip: when writing a library, litter your code with strdup to keep things interesting.
>>
>>54029239
printf("%s", reverse(a));

oops, you just leaked memory
>>
>>54029229
>raw pointer
points to data, the catch is you have to free the data and null the pointer yourself. This all too often creates memory leaks to programmers who aren't too careful.
>references
the & symbol returns a memory address reference either to data or a pointer. Useful when initializing pointers.
>smart pointers
If you want the advantages of pointers without the memory management, you have smart pointers
>>
>>54029249
This.
strdup is magical. It allocates the memory for you and you can forget about it afterwards.
>>
>>54029268
>nonstandard trash

you guys are writing your own strdup, right?
>>
>>54029229
Easiest way to distinguish reference/(raw) pointer is that a reference is always tied to one "thing" (be it object or primitive) and a pointer can change what it points to. References are safer in that they prevent memory leaks, but are also less expressive.

Smart pointers are an "improvement' on (raw) pointers and are an attempt at compromise between pointers and references. They implement some protocols that help prevent memory leaks without losing expressiveness.
>>
>>54029282
I tried to, but every time i would try to sizeof a string, it would say 4 or 8.
I figured at that point memory was magic, so now I use the library strdup.
>>
>>54029296
also basic forms of ownership
>>
>>54029282
>>nonstandard trash

Meh
>>
>>54029101
smart pointers are like wearing a condom. I mean yeah maybe it's more responsible but it's not nearly as fun
>>
>>54029262
oof, you're right.
>>
But seriously folks, use bstrlib.
>>
>>54029310
what's so hard about
char *strdup(const char *s1)
{
size_t len = strlen(s1);
char *s2 = (char *) malloc(sizeof(char) * len + 1);
if (!s2)
return NULL;
else
strncpy(s2, s1, len);
return s2;
}
>>
>>54029310
you dumb nigger it was returning the size of the pointer
>>
>>54029356
i forgot
s2[len] = '\0';
>>
>>54029356
>you wouldn't sizeof a char.jpg
>>
>>54029367
>whats so hard
>fucks it up

its something like that
>>
>>54029336
well... technically...

If you get off on raw pointers, then write for embedded systems m8
>>
>>54029265
>>54029296
ty
>>
>>54029356
>casting the result of malloc
>2017 AD
>>
Anyone here into competitive programming?

Stuff like TopCoder / ACM ICPC / CodeJam / FB Hacker Cup
>>
>>54029229

Raw pointer: A pointer with no special qualities.

Reference: a pointer that must point to a valid object. May have a more restricted set of operations, such as not allowing offsetting/pointer arithmetic.

Smart pointer: An object which encapsulates a raw pointer and deterministically manages its resources over the lifetime of its scope, without needing to be explicitly told to do so by the programmer.
>>
>>54029401
I do ACM. It's fun but I never get any of the dynamic programming questions
>>
I know /sqt/ is probably a more appropriate place for this, but I figured the crowd in this thread would known more.
Is getting A+ certified a good idea if I have no other credentials? Seems easy enough.
>>
>>54029401
kinda fun, but it'll only make you a niche programmer (look ma I can implement this algorithm quickly)
>>
Why don't more people use Cython?

>python syntax
>cross-compiles to C code
>>
>>54029425
That's IT, not programming. IT is basically a business shill.
>>
Also, is this a good strrev implementation?
char *strrev(char *dest, const char *src)
{
size_t len = strlen(src);
strncpy(dest, src, len);
size_t i = len - 1;
size_t j = 0;
register char c;
while (i-- > j++)
{
c = dest[i];
dest[i] = dest[j];
dest[j] = c;
}
dest[len] = '\0';
return dest;
}
>>
>>54029454
>register

Don't call us, we'll call you.
>>
>>54029465
post code, oh chosen one
>>
>>54029454
>register char
Let the compiler do that for you senpai. it isn't 1975
Thread replies: 255
Thread images: 30

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.