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

/DPT/ - Daily Programming Thread

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

Thread replies: 368
Thread images: 25

File: 1441508098092.jpg (33KB, 500x375px) Image search: [Google]
1441508098092.jpg
33KB, 500x375px
What are you working on /g/?
Last thread >>55544625
>>
2D game engine in C++ with SFML and Lua.
>>
>>55554990
>C++
Bad

>SFML
lol

>Lua
Fucking cancer

Kill yourself
>>
>>55555011
off yourself retard
>>
>>55554990

C++ and lua is always painful. Especially if you write the bindings by hand.
>>
Working on my Lisp library in C.
I need a way to deal with memory leaks of the resulting program. I should also probably take a look at a JIT library.
If you have any tips or experiences please tell me.

>>55555036
>Lua user calling others retards
>>
>>55555011
What's wrong with C++?
>>
>>55555072
Nothing.
>>
>>55555072
It is a slow to compile and implement mess that tries to do everything but ends up doing nothing well.
>>
>>55554990
>2D game engine
Sure, another one I guess
>in C++
Nice if done right
>with SFML
Ok? Really? Why would you write an engine then?
>and Lua.
Into the trash.
>>
>>55555109
>>55555054
>>55555011
What's wrong with Lua? Besides things like array indexes starting from 1.
>>
>>55555115
>What's wrong with Lua?
What's the point of lua?
>to be easier to work with
Turns out that there's no real reason to use Lua if you're interacting with anything else.
If you really want stuff like dynamic code reloading or whatever for the engine just do something like this:
https://blog.molecular-matters.com/2014/05/10/using-runtime-compiled-c-code-as-a-scripting-language-under-the-hood/
And now anyone can just generate a suitable DLL and everything works fine.

Lua is pointless for this purpose. Same as any scripting language really.
>>
>>55555115
Absolutely nothing.
>>
>>55555115
It is yet another useless language that serves no purpose. Want plug-ins? dynamic loading. Want scripting? Scheme/bash/whatever.

Anyhow, read this https://github.com/saniv/text/blob/master/criticism/lua.md

>>55555083
>>55555142
tard
>>
/dpt/ get
>>
>>55555115

Global by default.
>>
>>55555235
That's not even close.
>>
>>55555174
God, what kind of idiot wrote that document?
>>
>>55555266
Don't let that moron taint your opinion of anti-useless-scripting-language people.
>>
>>55555011
another "im superior because i have to write features that should be built in myself" retard

kys
>>
>>55555315
lol what?
>>
>>55555555 get needs to say Java is going to be a dead language by next year

fuck java
>>
>>55555323
It needs to be an interjection
>>
dpt, extortion edition.
>>
>>55555323
Java is going to be a dead language by next year
>>
How many of you le epic haxxors have made a script to get octuples today?
>>
>>55555376
post code for le script kiddies
>>
>>55555315
>kys
You might as well kill yourself and fuck off back to YouTube.
>>
Praise kek
>>
>>55555102
KEK

Only if you're a fucking incompetent developer
>>
Java is going to be a dead language by next year
>>
>>55555323

Kek willing
>>
>>55555432
>>55555439
>>55555471
>>55555474
Consider eating a freshly fired bullet.
>>
Java is dead m8
>>
>>55555487
lmao
>>
Drumpf has absolutely no chance.
>>
Fuck java it's a piece of shit language made for poo in loos and it's going to die next year
>>
>>55555487

deal with it autist
>>
For trump
>>
File: line_000.png (2KB, 640x480px) Image search: [Google]
line_000.png
2KB, 640x480px
I implemented Bresenham's line algorithm in 16-bit x86 assembly, in 640x480 black and white mode. It works, but only in first octant. Pixel data is written directly into video segment memory, int 10h isn't used.
Pic related - a triangle drawn using three lines.

Now I should make it work in all octants.
>>
>>55554965
Get for D
>>
>>55554965
Nothing.
Just fucking around on /g/
>>
C is a waste of time.
>>
Fuck java it's a piece of shit language made for poo in loos and it's going to die next year

no lives matter

trump is going to win
>>
>>55555436
nope
>>
>>55555555
>>
File: SLpFiFd.png (5KB, 411x204px) Image search: [Google]
SLpFiFd.png
5KB, 411x204px
>>55555584
:^)
>>
>0 posts about programming anything
>bazillion posts about "muh language is butter than ur language"

How embarrassing.
>>
File: 1427446643759.jpg (374KB, 837x1184px) Image search: [Google]
1427446643759.jpg
374KB, 837x1184px
Why should I learn a scripting language like Python/Ruby/Lua/PHP/Javascript when I can program is something like C/C++/Java/C#? Scripting languages seem so pointless unless you want to make something rough and ready.
>>
>>55555642
You must be new here.
>>
>>55555642
But that's what /g/ is for.
>>
>>55555649
Separate data from implementation.
>>
>>55555649
If you don't see a reason to learn one then don't learn one, simple as that.
>>
>>55555649
>unless you want to make something rough and ready
They don't have much advantage over a compiled language in this regard. It's not like it takes more than a fraction of a second to compile and run.
>>
>>55555682
Are you implying that compiled languages don't do this as well?
>>
>>55554965
Can someone tell me about job references? The one I'm applying to asked me to provide them with a couple after the interview. I have no idea what this involves and how I should handle it.
>>
>>55555707
You call your previous employees and ask them for a reference, that's it.
>>
>>55554990
Sounds pretty cool. I've barely learned about nodes and linked lists in C++, and I have no idea what to do with them.
>>
>>55555649

So you can deal with code that people have written in languages like Python/Ruby/Lua/PHP/Javascript.

You're asking for reasons why you shouldn't learn something as if there's ever a reasonable excuse.
>>
>>55555717
Ask them for a reference? This isn't the same thing as a letter of recommendation, right? I get their contact information then my new potential employer will contact them?

What kind of questions can they ask? A lot of the freelance clients I've had are western Europeans living in the states who speak poor English.
>>
Need some help with Database Design.
So far I have picture related, it's basically a Database to keep track of Inventory and Purchases.
I wanted to also keep track of how many of each item is sold in a Purchase. What should I do to achieve that?
The Quantity field in the Item table is used to keep track of how many of that Item is in the Shop's Inventory. Should I create a Inventory table to register that or it's fine this way? Should I add a Quantity field in my ItemPurchase table to know how many of each item was bought?
>>
>>55555735
Turn them into templates, if you haven't already.
>>
>>55555801
If you have a letter from your previous employer that contains a reference then it's all you need to hand your new employer.
>>
Dear anon >>55554563
Thanks a lot
You saved my day
>>
>>55555555
Mm
>>
>>55555857
Will do, but my problem is that I have no idea about what to do with these data structures. They're kind of hard to grasp, but I still want to do a project with them, if not anything, just so I can understand nodes and the rest better.
>>
>>55555912
Make some simple pool allocator.
>>
>>55555867
I don't. What should that letter contain?

I've never had an actual employer. Up till now I've only done freelance work and am finally trying to make the switch. I think I have a decent chance at this job but need the references.
>>
Picked up the project of building a network stack in Python again.
It's something I've been wanting to do for a very long time.
I can now receive and decode Ethernet II and ARP frames

<EthernetIIFrame dst=ff:ff:ff:ff:ff:ff src=00:14:5c:XX:XX:XX ethertype=ARP>
<ARPPacket op=Request sha=00:14:5c:XX:XX:XX spa=10.3.1.156 tha=00:00:00:00:00:00 tpa=10.3.1.89>


Now I have to send replies, but first I have to make an IO loop.
I'll probably use the Tornado one.
>>
File: 1442529695090.jpg (19KB, 305x222px) Image search: [Google]
1442529695090.jpg
19KB, 305x222px
>>55555926
Not sure what it is, but I'll give it a go. Thanks anon.
>>
>>55555981
https://en.wikipedia.org/wiki/Object_pool_pattern
>>
Is there anyway something could remove itself from a container in C++?

I want each enemy in my game to have a vector of every other enemy to test for collisions, but I can't think how this vector could discard the enemy holding the vector.
>>
File: 1468370790503.gif (17KB, 297x420px) Image search: [Google]
1468370790503.gif
17KB, 297x420px
I'm new to programming without much experience. I'm a couple weeks into learning python and I would like to add C to my study plan.

In the /sqt/ I asked for a book that would help me learn C and not assume any prior programming knowldege. I only got one serious reply and they suggested I buy a rasberry pi and install riscos to learn BASIC. Is that reasonable advice? Is there a better way or a book that fits my criteria?
>>
>>55556086
I'd go with either "C Programming: A Modern Approach", or "Pointers on C". Although, I believe the second one assumes a tad bit of programming knowledge.
>>
>>55554990
plz senpai
I want one like that but I'm too much of a lazy shit to write it myself
>>
>>55555840
>>55555840
>Should I add a Quantity field in my ItemPurchase table to know how many of each item was bought?
Yep, that's the easiest way to do it.

Just a recommendation: don't give all of your tables the same primary key name.

Instead of 'id' everywhere, use ItemID, PurchaseID, etc.

It's easier to write queries later.
>>
>>55556120
I'll contact you in a year, or two when it's done. :3
>>
yesterday someone posted a "challenge" to calculate the sum of the multiples of 3 and 5 up to 1000 (exclusive)

let's make it harder:
find the sum of the multiples of an arbitrary amount of numbers up to an arbitrary bound (exlusive)

you may disregard overflows
>>
>>55555840
In that case, yes, you'd just want to add another field to ItemPurchase.

I'm assuming you're doing an incredibly simplified web-store app?
>>
>>55556136
here's my own solution, in Ocaml

no peeking
let removeDupes list =
List.fold_right (fun e acc -> if List.mem e acc then acc else e::acc) list []
;;

let rec power list =
match list with
| [] -> [[]]
| car::cdr -> (List.map (fun l -> car::l) (power cdr))@(power cdr)
;;

(*not me*)
let rec gcd a b =
if b = 0 then a else gcd b (a mod b);;
(*not me*)

let lcm a b =
(a * b)/(gcd a b)
;;

let leastCommonMultiple list =
List.fold_right (fun e acc -> lcm e acc) list 1
;;

let sumOfMultiplesUpTo list bound =
let lcm = leastCommonMultiple list in
let actualBound =
let a = float_of_int (bound - 1) in
let b = float_of_int lcm in
let quot = int_of_float (floor (a /. b)) in
quot in
let naturalsSumTo n = (n*(n+1))/2 in
lcm * (naturalsSumTo actualBound)
;;

let sumOfMultiples list bound =
if List.length list = 0 then invalid_arg "There's nothing to be summed" else
let powerset = power (removeDupes list) in
let ordered =
let len = List.length in
let cmp l1 l2 = if len l1 > len l2
then 1
else if len l1 < len l2
then -1
else 0 in
List.sort cmp powerset in
let final = List.tl ordered in
List.fold_left
(fun acc e ->
if (List.length e) mod 2 = 0
then acc - (sumOfMultiplesUpTo e bound)
else acc + (sumOfMultiplesUpTo e bound)) 0 final
;;
>>
>>55556129
qq

I'm kind of working on one myself, got as far as window-scaling (everything drawn to an internal texture that is then displayed on a specific internal sprite)
but I never understood masking (need it for interfaces)
>>
>>55556136
>an arbitrary amount of numbers up to an arbitrary bound
Can you repeat the question?

Also, stop putting text in code tags, faggot. It's for code, not reddit emphasis.
>>
>>55554965
A Turing machine screensaver. Just because I want one.
>>
whats the best book for learning Go?
other tips for a new gotard appreciated too
>>
>>55556136
template <typename ... ArgList>
int sum(int max, ArgList ... args)
{
auto total = 0;

for (int i = 0; i < max; ++i) {
for (auto j : {args...}) {
if (i % j == 0) {
total += i;
break;
}
}
}

return total;
}


Probably could've been done better.
>>
>>55556187
I think he means that the function calculating the sum should accept two arguments, one being a list of divisors, the other being the upper bound of the operation, so like like for the example the function would be called like so:
calc({3, 5}, 1000)
>>
>>55556136
Is that supposed to be multiples of BOTH numbers or EITHER?
>>
>>55556276
Either.
>>
>>55556124
Thanks for the reply, I was stuck in this for at least 2 days trying to find the right answer.
I wanted to make a stupid question and I wouldn't mind at all if bash me.
How are the fields in the ItemPurchase table will be filled? I know the Quantity field will the filled by me, but are the ItemId and PurchaseId field be filled by themselves or do I need to add the ids by myself?
>>
>>55556187
It means the function should be able to accept any amount of numbers (2,3,4,5,6,7 as an example) and sum multiples of each of those numbers under some specified constant (1000, for example, would mean that you'd consider 2, 4, ..., 998 for the multiples of 2).

>>55556276
Multiples of either of the numbers. Remember to remove dupes (ex: sum of multiples of 3 and 5 up to 16 should only count 15 once).
>>
>>55556154
>I'm assuming you're doing an incredibly simplified web-store app
Exactly. If you can, please read >>55556328
>>
File: IFDYgph.png (22KB, 951x258px) Image search: [Google]
IFDYgph.png
22KB, 951x258px
>>55556136
>>55556250
>>55556374
I'm not sure how high we're supposed to allow the number to go. What's the data restrictions?

Here's a stab:

static long SumOfMultiplesOfAnArbitraryAmountOfDivisorsBelowAnArbitraryUpperBound(int upperBound, params int[] divisors)
{
return Range(1, upperBound - 1).Where(x => divisors.Where(y => x % y == 0).Any()).Sum();
}
>>
>>55556282
>>55556374

Thanks senpaitachi.

My entry:
function calc(divs, bound)
local sum = 0
for i = 1, (bound - 1) do
for _, div in pairs(divs) do
if i % div == 0 then
sum = sum + i
break
end
end
end

return sum
end

assert(calc({3, 5}, 1000) == 233168, 'Something happened.')
>>
quick question

max = 5
for i in range(0, max):
max = 10



this means the loop will run 10 times now, right?
>>
>>55556400
No, the range evaluates with the 5 as param and returns the iterable object.
>>
>>55556400
No
>>
>>55556389
>
Range(1, upperBound - 1).Where(x => divisors.Where(y => x % y == 0).Any()).Sum();

I just popped a LINQ boner.
>>
>>55556435
>>55556427
How do I update the max range within the loop then?
>>
>>55556136
my two solutions from yesterday
foo = lambda ms, n: sum({i for r in (range(m, n, m) for m in ms) for i in r})
foo = lambda ms, n: sum(i for i in range(0, n) if any(not i % m for m in ms))
>>
>>55556450
You don't use an already iterated object for a loop. Use a traditional loop.
>>
>>55556400
fyi, what you're asking is whether max is passed by value or by reference (useful if you wanr to google it)
>>
>>55556389
Whoever invented six-character limits for identifiers had the right idea.
>>
>>55556450
Switch to a while loop or recursive solution.
>>
>>55556466
>>55556479
>>55556491
thanks
>>
>>55556483
I purchases a 3440x1440 ultrawide to facilitate my naming convention.

In the future, I will require my employees to use similar monitors, as they will be required to name everything as descriptive as possible.

Comments are for losers and women.
>>
I'm learning C from The C Programming Language 2nd edition. This is pretty cool and the language is pretty simple.
>>
>>55556453
am I a python wizard now?
>>
(for the people answering >>55556136)

Take what I say with a grain of salt, I'm obviously not paying much attention to all of your code/am only getting the gist of some of the answers since I'm not familiarised with all your languages, but

I'm pretty sure most of your answers count some numbers twice. Taking 3 and 5, under 20, as an example:

[3, 6, 9, 12, 15, 18]
[5, 10, 15]

wouldn't your answers count the 15 twice?
>>
>>55556510
>Comments are for losers and women.
Enjoy coming back to it later and having no idea what your code is supposed to be doing.
>>
>>55556520
You should give Lisp a go. It's even simplier and it's the most powerful language on the planet.
>>
>>55556520
I'm reading up on it as well. Currently on the fifth chapter on pointers and arrays. I wouldn't really recommend it for first timers, they outright say that it isn't an introduction to programming or computer science, it's an introduction to the language.
>>
>>55556573
Lisp is not a language. Lisp is a family of languages.
>>
>>55556552
Nope.

I'm >>55556389

If the modulus of any of the given divisors is 0, then the number will be included in the sum.

If the number is divisible by two divisors, it only adds it once.

>>55556557
A jest, friend. I only do those insane identifiers because it triggers /dpt/.

I'd shoot an employee if they submitted that shit to me for review.
>>
>>55556573
>>55556575
>>55556581
Which lisp dialect should I go with? GNU lisp? SICP? Racket?
>>
>>55556552
I can't talk about the others but at least the C++ and Lua solutions will not since they do not generate lists of numbers for each divisor them sum them up, instead they loop through all the numbers in the range, and check every divisor until it passes, then they break immedietely for that number and continue with the next.
>>
>>55556552
no, >>55556453 doesn't either.
the second solution is pretty obvious.
the first solution doesn't because all sum ranges are added to a set, which eliminates the duplicates.
>>
>>55556601
>>55556552
The Python and C# solutions are using set comprehension with lambdas, so they avoid that issue as well.
>>
>>55556595
try multiple dialects and see which one suits you best

personally, I find all lisp dialects lacking in equally important things. I'll only be comfortable using lisp when I get around to writing my own dialect
>>
>>55556601
>>55556608
>>55556614
oops, I'm just retarded, I was still looking at things through my solution's perspective
>>
>>55556634
I guess I'll try SICP.
>>
>>55554965
First for rebol>>55554965
>>
>>55556595
None. Lisp will make your projects fail.

There's a blog called LoperOS. All he does is whine about why everything sucks. In the time it took him to whine, people wrote GUI operating systems in assembly.

See >>55556109
>>
Is python the best language for a beginner?
>>
>>55556726
SICP is a book for high school kids.

Everything it says about compilers and interpreters is dumbed down toy crap.
>>
>>55556510
>as they will be required to name everything as descriptive as possible.
It's pain to type it all, moron.
>>
A virtual assistant that doesn't require Internet connection and is bassed in neural networks. Adapts to the user instead of being the same for every user as common assistants are (Cortana, Siri ,etc.)
>>
>>55556634
>personally, I find all Java dialects lacking in equally important things. I'll only be comfortable using Java when I get around to writing my own dialect
The next time someone on /g/ complains about Java, I'll say Java is a perfect language because if you don't like it, you can "write your own dialect."
>>
How can i use the integrated visual studio code to compile the file that i have open?

I suppose that's how you use the integrated terminal right?
>>
>>55555011
>>C++
>Bad
kys

>>55555011
>>SFML
>lol
>>Lua
>Fucking cancer
>Kill yourself
these
>>
>>55555555
>>
I have a C program that uses win32's PlaySound function. Is there a way to add the .wav file into the executable?
>>
File: 2016-07-13_11-30-35.webm (258KB, 1000x148px) Image search: [Google]
2016-07-13_11-30-35.webm
258KB, 1000x148px
>>55556818
It was a joke, you silly goose.

Also,
>not having intellisense
>>
>>55556955
yes
>>
>>55556978
And what is it?
>>
>>55556874
1 - I never said any dialect of Lisp was perfect
2 - Writing your own lisp is much more simple than an Algol-like (just think about lisp's syntax vs all the weird cases in C or C++)
>>
I just installed python 3, Is IDLE that comes with it good enough for python?
>>
Question, /g/. When I pass the pointer with the constant string, it's pointing at the start of it. Thing is that when I pass it to the function, it doesn't point elsewhere after the execution.
Is it because of the same reason when passing normal variables to functions and not its addresses, i.e. passing a copy of the content? Would I need to pass the address of a pointer to modify it?

#include <stdio.h>
#include "../mylib.h"

void move_pointer(char *st, int n);

int main(int argc, char *argv[]){
char *p = "Filler string";

if(argc != 2)
return 1;

int times = atoi(argv[1]);
move_pointer(p, times);

printf("%s\n", p);

return 0;
}

void move_pointer(char *st, int n){
for(int i = 0; i < n && st; i++){
st++;
printf("%s\n", st);
}

return;
}

>>
>>55556983
You can either use a resource file or a static char array.
>>
>>55557028
You need a pointer to a pointer to modify the pointer itself, senpai. Otherwise you can only modify the object pointed to.
>>
>>55557061
That's what I was thinking. Thanks senpai.
>>
>>55557028
* is literally just a meta tag.
int a is an integer
int* a is a pointer to an integer
int **a
is a pointer to a pointer to an integer

There is no practical limit to pointer depth. Let's get meta.
>>
in C, what is the behaviour of

int ***a = &(*a)


99% of people will get this wrong
>>
>>55557237
undefined behaviour
>>
>>55557237
UB bby
>>
>>55557260
bzzzzt, wrong
>>
>>55557274
nope
>>
>>55557282
yep, I'm 100% sure it's not undefined behaviour
>>
>>55557237
Well,
(*a) can be considered a int**
&(int**) can be considered int***

You're setting a to itself. However, I'm not sure you can do that in the line that declares a.
>>
>>55557237
You will have a pointer of type (typeof(a))** stored in a variable of type int***. The typechecker may yell but could be circumvented by a static cast
>>
>>55557309
I think it only works if the a on the rhs is being shadowed (e.g. it is a global variable)
>>
>>55557237
It means the same as
int ***a = a
, which accesses an uninitialized variable, which is undefined behavior.
>>
>>55557328
correction: the rhs is of type (typeof(a)), as &(*a) == a. My C is rusty
>>
>>55555649
>when I can program is something like
doesn't sound like you can
>>
File: 20160713170702557.png (102KB, 1018x578px) Image search: [Google]
20160713170702557.png
102KB, 1018x578px
How many points can you score?
http://q.viva64.com
>>
>>55557445
s/is/in
https://en.wikipedia.org/wiki/Principle_of_charity
>>
>>55557290
I'm 100% sure you don't have a clue what you're talking about
>>
>>55557455
This test is just bad
>>
>>55557363
>which accesses an uninitialized variable, which is undefined behavior.
Wrong
>>
>>55557455
What is this cancer
>>
>>55557456
wasn't talking about the typo; if you'd actually be able to program C/C++/Java/C#, ie. actually know them, you'd be knowledgeable enough already not to ask that retarded question; which suggests you can't actually program C/C++/Java/C#; anything else?
>>
>>55557495
>reading uninitialized variables is not undefined behavior
anon, do you even C?
>>
>>55557515
Basically they ran their static analysis tool through tons of popular OSS projects to detect bugs in the code, then made a quiz that lets you try to find those bugs to show that static analysis tools are necessary because those bugs live in projects used every day and programmers do not notice these typos and other mistakes.
>>
>>55557532
Yes, I do.
Do you even know what UB is? Because I doubt that.
>>
>>55555592
Don't kid yourself. C++ is shit if you're retarded but otherwise nah
>>
>>55557600
C++ does not need a retard to be shit.
>>
>>55555649
Short answer is they're easier, more abstract, and hold your hand more than the deeper languages. If you're up for the challenge definitely take Java and the C family of languages over scripting languages first. They'll teach you more and you'll actually understand programming rather than just hacking shitty libraries together and hoping they work.
>>
>>55557561
>Yes, I do.
please, you're retarded
>>
>>55554965

Any of you memers use spacemacs? Decided to learn common lisp along with spacemacs, but I'm feeling a little lost. In vim my workflow involves a lot of :tabe and I have tabnext and tabprev bound, in spacemacs however I dont really know how work with multiple files.
>>
>>55557651
Feel free to prove it then, where does the standard say that this is UB?
kill yourself
>>
>>55557678
spacemacs is just an emacs addon
>>
>>55557455

!qIsFinite(w) || !qIsFinite(w))

>Select the left w
>Wrong, it was the right w

Seems like their analyzer didnt quite catch that :^)
>>
Answer to this >>55557237:

The behaviour is none, as it is not a valid C program.
>>
>>55557758
how?
>>
>>55557774
Missing semicolon.
>>
>>55557780
^

Thank you all for playing. As always, you're all shit at C.
>>
>>55557455
bool QConfFileSettingsPrivate::readIniLine(....)
{
int dataLen = data.length();
....
if (i == lineStart + 1) {
char ch;
while (i < dataLen &&
((ch = data.at(i) != '\n') && ch != '\r'))
++i;
lineStart = i;
} else if (!inQuotes) {
....
}

>click on int (should have been size_t)
>wrong
>>
>>55557780
>>55557800
You both are homosexuals
>>
>>55555555
>>
>>55557758
>not a valid C program
aka undefined behavior
>>
>>55557821
So? Homosexuality is objectively superior to heterosexuality, just like the functional paradigm trumps all others.
>>
File: 1465740412771.jpg (175KB, 1920x1541px) Image search: [Google]
1465740412771.jpg
175KB, 1920x1541px
>>55557698

That's a very astute observation anon, have a (you)
>>
File: 1468361783578.png (463KB, 785x678px) Image search: [Google]
1468361783578.png
463KB, 785x678px
>>55555072
>>
File: functional programming.jpg (64KB, 440x389px) Image search: [Google]
functional programming.jpg
64KB, 440x389px
>>55557837
f a l s e
f a g

gays are not allowed to program at all, let alone functionally
>>
>>55557862
please be a boy
>>
File: 1354309914592.png (183KB, 493x536px) Image search: [Google]
1354309914592.png
183KB, 493x536px
>>55555649
Depending on the language, they can be much faster to develop with, and often have a much tighter feedback loop than compiled languages.

>Lisps epitomise this by letting you change anything, whenever you want during execution
>JavaScript is also really nice for it with hotswapping, and amazing debugger support
>Ruby has Pry, probably the best REPL for any language ever

Also, often scripting languages are put inside of a program to allow you to extend them without digging into their codebase. (This is usually what Lua is used for)

And sometimes, they are the only option for some platforms, like JavaScript on the web.
>>
>>55557780
You never said that was a complete "C program" just "in C".

(int) and
(int *)
aren't complete C programs but they occur in C and it's meaningful to ask about them.
>>
File: 1468431474923.png (630KB, 785x678px) Image search: [Google]
1468431474923.png
630KB, 785x678px
>>55557862
Wow great argument fag.
>>
>>55555840
Lol at the Purchase table.
Why you need 2 purchase table?
Stop utting total price in a table,that you can get with a query ,Make an Item Table with a primary key and some other detail column and a Sales table where you reference an Item and add some extra detail columns.
>>
>>55557618
Yeah, just some fag that only writes Ruby while sitting at Starbucks. Almost the same thing
>>
>>55557894
>C++ is light
>C is bloated
lol?
>>
File: 1467677762738.png (1MB, 1200x1800px) Image search: [Google]
1467677762738.png
1MB, 1200x1800px
>>55557894
>>
>>55557921
C++ is shit by itself.
>>
>>55557880
In C#, I can just drag the execution pointer to whatever line I want to start at, and modify the subsequent lines, thus being able to modify a program midway through execution, while also retaining type safety.
>>
>>55557869
The homosexual brain has the best traits from the heterosexual brains of each sex. This, combined with the social structure provided by homosexuality (more female friends, since they don't feel threatened by a homosexual man, to keep them updated on all the latest occurences + close male lovers who will not be afraid of pouring their bodies and minds into making you feel good, contributing to your well-being and clarity of mind, as well as being amazing for pair programming if you're in a relationship), makes the homosexual male the best kind of programmer, on average.

It may be true that in the future machines will programing themselves, but before that we'll yet witness the overtaking of the field of computer science by homosexuals, and it will be glorious. Homosexuality > Heterosexuality just as Functional Paradigm > Any other Paradigm.

Know your place, heterocucks.
>>
File: 1462399412449.jpg (410KB, 876x2350px) Image search: [Google]
1462399412449.jpg
410KB, 876x2350px
>>55557931
C++ code is light
C code is bloated
>>
What is a good book to learn Unix programming in C for beginners?
>>
>>55557931
C++ is nice, C is unpleasant.
>>
>>55557975
>casting from/to void is nice
>>
>>55557943
>tfw C# isn't a loli anymore at the ripe old age of 16

Someone should update the image.
>>
>>55557989
Well you do that in C. In C++ you don't have to.
>>
>>55557989
never happens
>>
>>55558008
I think you confuse C and C++.

>>55558010
Wrong
>>
>>55558008
>you do that in C
nope, why do you need to post if you don't know anything about the topic?
>>
>>55557989
???
>>
>>55558021
>I don't know C++
just say so rajesh
>>
>>55558029
>>55558008
How would you implement a general data structure in C without casting from and to void*? In C++ you can just use a template.
>>
I'm not sure I understand Lambdas in C++.
I'm not particularly interested in learning them either. I don't think I am anyway. I'm very interested in learning them if they're a construct that lets me move code out to functions without actually having a function call.

Anyway, does anyone know good resources to learn?
>>
File: Cube.webm (2MB, 1920x1052px) Image search: [Google]
Cube.webm
2MB, 1920x1052px
>>55557952
I mean like this though.

Even if you don't like the language, you gotta admit the ability to do that is pretty slick.

Java has hotswapping too, but it isn't a sure thing, and you can't build an entire program by running it and incrementally adding things while it's running.
>>
>>55558061
yes, it creates an external anonymous class with an operator() containing the code
>>
>>55558029
Not him, but I think you're deluding yourself. Write a generic hash table in C without using void* or a preprocessor hack.
>>
>>55558061
Lambdas are essentially syntax sugar for structs that catch some state as members and define an operator()()
>>
>>55558044
I start to seriously doubt that you know what you are talking about.

>>55558054
>without casting from and to void*?
Ehh... by not casting from and to void *, it's that simple.
You can also do it with macros.

>In C++ you can just use a template.
Enjoy your slow compile times.
Also, this is another badly implemented feature of C++. Just use a language with parametric polymorphism.

>>55558074
What does this has to do with the topic?
>>
>>55558054
>How would you implement a general data structure in C without casting from and to void*?
Well I'd probably find a good metaprogramming library/preprocessor that'd allow me to do that in a much nicer way than C++ templates. Even if they were nice, if they have the same compile times and debugging issues they do right now then they're not worth it. Copy paste.
>>
>>55558082
>>55558074
I'm really sad capture by move wasn't in C++11. Such a wart.
>>
>>55558073
>>55558082
Ok thanks that's helpful.
>>55558102
What is this though?
>>
>>55558062
Yeah, I know, and that's cool and all, but it would be trivial to create an actual user input at that point that is validated and type safe. That would make it so that an error typing real-time in your code doesn't crash the program or cause some other sort of destructive tomfoolery.
>>
On the list of things you never knew you needed:

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
#Warn ; Recommended for catching common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.

#f::
Send, feels good{Enter}
return


feels good
>>
>>55557973
Community college
>>
>>55558102
Was meant for
>>55558082
>>55558073

>>55558114
Like the other anons said, lambdas in C++ construct an anonymous class with state "captured" from the environment you create the lambda in. You can capture by ref, and capture by value, but there's no built-in syntax to copy by move. So, for example, moving a uniqueptr or vector into a closure is more annoying than it needs to be.
>>
>>55558062
Just compile your code as a DLL and load it while you check for changes regularly.
It works well in any situation where I can imagine it makes sense to have hotswappable code.
>>
>>55558093
C++ templates aren't the proper implementation, but they're better than the C answer of "just write it once for each type".

There is no arguing that C++ allows you to offer abstractions that C does not, or that these abstractions are useful. When you don't need them, C is great, when you do, C is the wrong language.
>>
>>55558093

>Do it with macros

I think C++ is an awful language and I vastly prefer C, but implementing generics with preprocessor macros is about as appealing as putting my hand in boiling water...
>>
>>55558125
>Yeah, I know, and that's cool and all, but it would be trivial to create an actual user input at that point that is validated and type safe.
Though, you don't have to create this... This is built right into the environment and is battle tested.

>That would make it so that an error typing real-time in your code doesn't crash the program or cause some other sort of destructive tomfoolery.
Yeah, that kinda sucks when that happens, but that just signals a condition which lets you retry the last thing you screwed up. After you fix it, you are back in business.

>>55558159
Oh? That sounds pretty cumbersome and error prone, but I don't actually know about swapping anything in and out realtime while developing.
>>
>>55558054
>In C++ you can just use a template
in C, you just don't need to cast
>>55558074
>generic hash table in C without using void*
why not use void*? you can use it at will without needing a cast; do you know anything about C?
>>
>>55558236
I don't disagree, but even when you do need them, C++ is again the wrong answer.
>>
>>55555011
>>55555011
Show us what you're working on, faglord
>>
>>55558062

the NEETCUBE
>>
>>55558259
Did it already.
>>
>>55558093
>doubt that you know what you are talking about
I know more than you tho
>>
>>55558266
Yeah. It was from back when we used to have Lisp generals.

I didn't have any compelling webms to show off hotswapping besides that one, so I just used it.
>>
>>55554965
Working on a badass swiss-army reverse engineering tool called PINCE

https://github.com/korcankaraokcu/PINCE

I know I posted this project to here before but I just wanted to share the updates. PINCE now has a disassemble screen with a few cool functionality on it, a GDB Console, complete docstrings(except PINCE.py), initial code injection, settings screen aaand a wiki page

Only 1 year remaining on my schedule. Am I going to make it /g/?
>>
>>55558251
>in C, you just don't need to cast
So you're complaining that type-casting to/from void* isn't done implicitly in C++?
>>
>>55558285
Your posts clearly show that you do not.
>>
>>55558301
There is no implicit typecast.
>>
>>55558249
>pretty cumbersome and error prone
Not all that cumbersome. Depends on how your dll-side code interacts with the outside code.
Was linked earlier in thread too: >>55555141
And that's for code that's intended to interact heavily with the non-dll codebase.
If you have a platform layer of some sort and load all the code you may want to swap as a DLL there's practically no difficulty in this. You pretty much only need two OS features, loading the DLL and getting the/a function pointer(s) from the DLL so you can call it.

Watch out for global variables though. You can fix that but it's harder.
>>
>>55558300
Looks neat mate, keep up the good work
How much fuckery can you commit with PINCE as it stands right now?
>>
File: 6456421.jpg (63KB, 512x384px) Image search: [Google]
6456421.jpg
63KB, 512x384px
>>55558342
That's...really cool actually. I'll have to give it a shot the next time I am working with C.
>>
>>55558301
>So you're complaining
I'm not complaining about anything, do you know how this subreddit works?
>>
File: line_001.png (2KB, 640x480px) Image search: [Google]
line_001.png
2KB, 640x480px
>>55555547
Looks like it works.
>>
is it possible to get a low-level programming job with very basic programming ability?
>>
>>55558302
I clearly showed you don't know C++
>>
>>55558396
You should be specific.
>>
>>55558371
That really has nothing to do with C. It was another thing that Unix took decades to copy from Multics.
>>
>>55558396
...you did not?
>>
>>55558392
Not really. You might be able to bullshit your way in, but you'll be out before long.

Why not practice a bit on a side project or two? (Or contribute to an OSS codebase to see what you are getting yourself into.)

>>55558412
Well, I mean if I were to do it, I would basically treat it like an LD_PRELOAD that only becomes effective during runtime, and I usually write my system libraries using C.
>>
>>55558430
sure did
>>
>>55558442
>Why not practice a bit on a side project or two? (Or contribute to an OSS codebase to see what you are getting yourself into.)
Good point. How much actual experience in terms of hours would a NEET like me need in order to get some shitty entry-level position?
>>
>>55558451
Wrong
>>
>>55558462
No one knows/thinks about it in terms of hours. If you have strong portfolio and relevant domain knowledge, you can let your skills speak for themselves.

What kind of "low level" programming do you want to do?
>>
How much data is being wasted if you make unnecessary line breaks?

 one = 1


two = 2


three = 3



vs

 one = 1
two = 2
three = 3


If I did shit like that all the time.
>>
>>55558499
the only thing being wasted is a few irrelevant fractions of a second for the lexer to discard the whitespace
>>
>>55558499
1-2 bytes per line break, depending on break style, or ~ 0 with compression. No change in compiled code.
>>
>>55558499
One byte per new line, I wouldn't worry about it.
>>
>>55558442
>usually write my system libraries using C
stop lying, you don't even know C
>>
>>55555102
>tries to do everything but ends up doing nothing well

You clearly haven't looked at C++ since the 90s then you fucking retard. Stop regurgitating shit.

C++11/14/17 is amazing and basically reinvented the language.
>>
File: avgint.png (3MB, 882x782px) Image search: [Google]
avgint.png
3MB, 882x782px
PLC program for averaging three 8-bit integers
>>
>>55558499

Depends on the text format. Storage wise it's general only a couple of bytes, compilation time wise it's beyond negligible.
>>
>>55558499
Assuming that white space is just a newline character, one byte per newline.
>>
>>55558531
>reinvented the language
has it reinvented acceptable compile times yet?
>>
>>55558531
Well it's still shit.
One example where C++ tries to do everything but ends up doing it in the shittiest way possible is using templates instead of parametric polymorphism.
>>
>>55558492
I didn't mean "low level" in terms of something like actual low-level hardware programming, I just meant something basic that doesn't pay a whole lot--something to get my foot in the door.
>>
>>55558531
I agree that other anon is being an idiot, but don't oversell it. Compatibility will forever be C++'s ball and chain.
>>
>>55558462
It's not really an "hours" thing... It is entirely dependant on how much you want to learn the subtleties and how things work.

Basically, when you feel like you have a good understanding of the topic. You will probably do really well if you land a job with it.

Also, if you gained that knowledge by contributing to Open Source or with your own projects, you instantly have leverage to get work. Because, as someone who hired people, OSS is impressive.

>>55558529
I didn't want to say "libraries" because that applies to any language.
I write libraries in every language I know. (Granted some are shittier than others)
>>
>>55558544
Compilation times really don't matter as much as you think they do.
>>
>>55558534
Can you do it in STL tough?
>>
>>55558555
Ah, I misunderstood. I have a BS in CS, so I can't exactly speak from experience, but I'd be surprised if a good portfolio didn't get you in along with a solid interview.

You'll need one of {portfolio, degree} though. (Or luck / charisma) Otherwise all they have to judge you on is your possibly-memorized answers to shitty interview questions.
>>
>>55558555
Oh! In that case yeah, basic programming ability is enough for most junior positions. If you are working under a wizard, you can learn a TON from them.
>>
>>55558547
>templates instead of parametric polymorphism
you don't know what the fuck you're talking about
>>
File: dosbox_000.webm (69KB, 640x480px) Image search: [Google]
dosbox_000.webm
69KB, 640x480px
>>55558385
Now I should try rotating a cube.
>>
>>55558607
>muh fizzbuzz compiles fast enough
please
>>
>>55558499
>all these people saying that a newline = 1 byte

What is \r\n? What is a character encoding?
>>
>>55558564
>Also, if you gained that knowledge by contributing to Open Source or with your own projects, you instantly have leverage to get work. Because, as someone who hired people, OSS is impressive.
thanks for the tip!
>>
>>55558627
They are big words that mean something pretty simple that they hope you don't understand so you give up and think they are out of your league.
>>
People who hate C++ are 90% of the time just autistic C programmers who haven't looked at anything since K&R and once read Linus post something negative about C++ (which he has since retracted)
>>
>>55558627
I think he means to prefix it with "a principled implementation of", or he's just shitposting.
>>
>>55558361
Briefly, you can read/modify memory, inject any .so file you want, disassemble addresses and interrupt/continue the process for now. It's still in development. Also it has a GDB console, so even if PINCE's features are limited, you can use gdb along with the PINCE.

Oh, I recently separated all auxiliary libraries from the main script. So you can use GDB_Engine, SysUtils etc. in your own projects. I'm also planning to create a scripting engine just like Cheat Engine's auto assembly language. But completely based on python instead.
>>
>>55557989
>>55558021
kill yourself delusional idiot, casting to/from void is something commonly done in C, not C++
>>
>>55558656
>which he has since retracted
link please
>>
>>55558607
>what are templates
>>
>>55558688
>casting to/from void is something commonly done in C
you shouldn't try to speak about things you don't know, anon
>>
>>55558688
I'd go further and say "void pointers are a code smell in C++". I haven't had to use them once in the last two years of coding in C++ for work.
>>
>>55558720
k tard
>>
>>55558623
>Oh! In that case yeah, basic programming ability is enough for most junior positions. If you are working under a wizard, you can learn a TON from them.
I can do your basic fizzbuzz and muh knapsack problems and I kinda understand complexity classes/big O and such, and I think I know most of the basics... is that enough for a junior-level position?

Obviously I have a lot of work to do still but I also don't want to starve to death (almost out of ramen)
>>
>>55558534
Why the fuck is your image almost 3MB

Fucking hell.
>>
>>55558656
>tfw part of the 10%
>>
>>55558747
it would help if you learned more before you start applying for jobs so that you don't ruin your chances with certain employers when they see how much of a newfag you are, but you could feasibly land a junior position with what you know now
>>
>>55558797
>it would help if you learned more before you start applying for jobs so that you don't ruin your chances with certain employers when they see how much of a newfag you are, but you could feasibly land a junior position with what you know now
Thanks. Do you have any tips on where to look? I'm in the US and I'm definitely gonna relocate if I can. I'm probably looking at small startups, right?
>>
>>55558656
>once read Linus post something negative about C++ (which he has since retracted)
No, he hasn't, C++ continues to be shit.
>>
DataClean / Olap Cubed
>>
>>55558832
Have you even used C++14?
>>
>>55558747
That's passable if you really need work.

One thing you could do to improve your chances is to write a program for your interview. Basically a little demo program to show that you can do something with the language they use.

Basically, interviews are two-way streets, so after a prospective employer stops asking you questions, you can ask them things too...or demo what you made.

It actually leaves quite an impression. I do it, and it gives me a ridiculously high success rate for getting work at places I get interviews for.
>>
>>55558867
I'll remember that, thanks
>>
File: output.webm (82KB, 1169x508px) Image search: [Google]
output.webm
82KB, 1169x508px
Still working on the input forms for my raw 3D modelling interface.

Should I just leave it so that you can select and enter values into more than one form simultaneously or should I make it so that when you select a new form the previous is deselected?
>>
>>55558858
Ask Linus.
>>
>>55558916
I did and he said you're a faggot

H8 2 be u right now
>>
Could someone explain to me why this is a segfault?

  for(i = 0, k = len-1; i < len; i++, k--){
reverseString[i] = string[k];
}
>>
>>55559007
Post a complete program.

There's also no real need for two loop counters.
>>
>>55559005
>I did
At least we established your credibility in this discussion involving C++. Don't bother replying anymore, your opinions are irrelevant.
>>
>>55559007
Need more info. How big are your arrays? What value is len?
>>
why don't you golang yet /dpt/? too powerful concepts for you to understand?
>>
>>55559007
Assuming they are both the same size, change len and len-1 to sizeof(string)/sizeof(type)
>>
>>55559121
>too powerful concepts for you to understand?
lol
>>
>>55559129
Wat. Chances are both are pointers.
>>
>>55559121
I looked at it, but didn't really see anything that caught my interest.
>>
>>55559129
>Assuming
>C
>len and len-1 to sizeof(string)/sizeof(type)
>replace 2 distinct values with this one
>sizeof(pointer)/sizeof(type)
ask me how I know you're a "html programmer"
>>
>>55559147
It's pretty rudimentary anon. Whether they are pointers or not makes very little different.
>>
>>55559007
The only thing i can think of is that reverseString is too small.
>>
>>55559175
>I don't know C tho
obviously
>>
>>55559170
>reverseString
Are you fully retarded anon-kun?
>>
>>55559121
low quality bait, Go is a step backwards and a disgrace to the programmers
>>
>>55559189
He is quite blatantly just trying to reverse a string. Are you professionally simple?
>>
>>55559175
"Sizeof" returns the size of a type, or the size of the type of a variable. Sizeof(foo) == sizeof(char*) if foo is a char*.
>>
>>55559164
first class coroutines and channels, statically typed, natively compiled, self contained binary, cross compiling built in are not interesting enough?
>>
>>55559236
It returns the size of an array if it is an array which is blatantly is which divided by the size of the type would produce the correct number of cycles.
>>
>>55559257
>>55559257
new thread here
>>
>>55559256
>which is blatantly is
how do you know without seeing the declaration? are you just "assuming"?
>>
>>55559193
>yes, I'm a webshit
we know
>>
>>55559278
I know because he is trying to reverse a string. Holy shit anon. It says right there.
>>
>>55559256
>which it blatantly is
Anon, there are no types in that snippet. Most strings are heap-allocated rather than fixed size arrays. Indexing operator works on both array and pointer types and always indexes using multiples of the element or pointed-to type.

Are you the same guy who was making bad C over C++ arguments?
>>
>>55559297
>I don't know what a string is
>I don't know what an array is
>I don't know what pointers are
>I don't know C
fuck off
>>
>>55559307
>There are no types in that argument
Right, so everything was declared already. What is your point?
>>
>>55559297
>It says right there
Does it say he's trying to reverse an array? Protip: arrays and strings are not the same thing.
>>
>>55559325
My point is that assuming sizeof(string), in the context of the snippet, returns something other than the number of bytes in a pointer is stupid, and you're an idiot for defending your post for this long.
>>
>>55559325
>was declared already
How?
>>
>>55559325
Are you
>>55558251
>>55558093
>>
>>55559320
>IF I KEEP SHIT POSTING HARD ENOUGH, MAYBE HE WILL GO AWAY

>>55559334
No it says he is trying to reverse a string which is causing a seqfault which could be easily fixed by setting the number of cycles to the size of the strings which are assumed to be the same.

Jesus fucking Christ /dpt/. Why are you all so fucking shit at this?

>>55559352
The fact you are assuming this is a pointer so hard is utterly embarrassing and the fact this guy hasn't responded yet leads me to believe he fixed the baby problem on his own by making sure i and k didn't end up out of bounds as they were clearly ending up.
>>
>>55559251
For me, Coroutines are the coolest thing in that list and are amazingly useful...
But Clojure's core.async implements channels like that too. (And actually, that is why I know they are amazingly useful.)

The rest of the list is either not really consequential to me (Particularly static typing), or Clojure already does it.
I'm not saying Go is bad, it might be nice for others--but for me, there wasn't any "ZOMG! I NEED TO WRITE IN THIS!" when I saw reasons to use it.
>>
>>55559393
>setting the number of cycles to the size of the strings
sizeof doesn't give you the size of a string
>The fact you are assuming this is a pointer so hard is utterly embarrassing
what's embarrassing is that you have zero knowledge about C yet you keep talking about it
>>
>>55559437
>sizeof doesn't give you the size of a string
Yes it does, debate over.
>>
>>55559450
>I don't know C
we already acknowledged that
>>
>>55559467
>We
Fuck off man baby. Learn C before you shit post.
>>
>>55559042
>>55559083
>>55559129
>>55559188


Here's the whole thing:

#include <stdio.h>
#include <string.h>

int main(int argc, char **argv)
{
size_t i = 0, k = 0;
size_t len = strlen(argv[1]);
char *string = argv[1];
char *reverseString;

for(i = 0, k = len-1; i < len; i++, k--){
reverseString[i] = string[k];
}
printf("%s\n", reverseString);

return 0;
}


(I know there are probably shitloads of better ways to do this )
>>
>>55559478
>mad for getting told
happens every time
>>
>>55559256
>it is an array which is blatantly is
>>55559511
BTFO
T
F
O
>>
>>55559393
Okay, let me be completely clear.

In C, a string is a sequence of non-null bytes in contiguous memory, terminated by a null byte. The address of the string is understood to be the address of the first byte in the string.

There are two (really three, but I'll discuss two) places you commonly find this type of string in C. The first and most common is in a chunk of heap-allocated memory, such as returned by malloc/calloc. The second, and less common situation is a string in a fixed size buffer on the stack.

Given only the address of a string, finding the string's length requires iterating over the string until you hit a null byte. In many cases it is better to separately track the length of a string to avoid this overhead.

In neither case will sizeof return the length of the string. In the case of a heap allocated string, pointed too by a char* type, sizeof will return the size of a pointer in bytes. In the case of a fixed size array on the stack, sizeof will return the size of the array in bytes. Importantly, the string may be shorter than this.

In fact, sizeof will /never/ return the correct length of a string, since a string without a null byte at the end is malformed in C. Thus, if the string exactly fit in the fixed size array on the stack, sizeof would return the length + 1 (counting the null byte too).

Tldr: your shitposting succeeded in making me put in disproportionate effort to respond to you.
>>
>>55559511
uh senpai you don't declare any space for reverseString, either on the stack or on the heap. That pointer is currently uninitialized and could be pointing to anything
Use malloc or declare a fixed-size array on the stack
>>
>>55559393
>The fact you are assuming this is a pointer so hard is utterly embarrassing
>utterly embarrassing
come on, shitstain, backpedal this one: >>55559511
>>
>>55559393
>>55559511
FUCKING DESTROYED
>>
>>55559511
reverseString points to arbitrary memory, you need to allocate space for the string.

You also don't copy the null plug in the loop, so you should make sure the allocated memory is zeroed, or that you put a null at the end.
>>
>>55559631
how about sizeof(string)?
>>
>>55559649
>>55559555
>>
>>55559667
>>55559129
>>
>>55559478
come on, webshit! get in here so we can properly fill your mouth! why are you hiding?
>>
>>55559567
>>55559631

Okay I just realized I don't know shit.
Thanks Anons
>>
>>55558627
how so?
>>
>>55558688
But this is wrong you fucking idiot.

>>55559385
>>55558093 here, he is not me.
>>
>>55560050
what the fucking fuck are you on about, casting to/from void is by far more common in C than in C++, and i don't give a fuck who you are, you're still a retarded worthless piece of shit
>>
>>55560081
In C you do not need to cast from/to void * and thus almost nobody does this.
In C++ you HAVE to cast from/to void, this is why everybody does it.
What don't you understand?
>>
>>55560097
KILL YOURSELF FUCKING DELUSIONAL RETARD
>>
>>55560081
int *x = malloc (sizeof *x); /* valid C, invalid C++ code */
int *y = (int *)malloc (sizeof *y); /* valid C and C++ code
/* ^ this is a cast */

Do you get it now?

>>55560107
The hell are you on about?
>>
>>55560126
you're a fucking retard
>>
>>55560139
Nice argument
>>
>>55560126
holy shit anon
I haven't seen these levels of stupid in a long time
if you're trolling, excellent job, 10/10
>>
>>55560152
Buttmad that I actually have arguments?
>>
>>55560146
>>55560164

see >>55560168

FUCKING JACKASS STUPID ASS SPERG

TYPICAL C TARD KILL YOURSELF
>>
>>55560164
I'm not even mad I'm impressed
>>
>>55560182
Me too
>>
>>55560126
When people say "cast" they don't just mean "explicit cast". For instance, many people would call implicit widening a "cast". This may or may not be the correct terminology, or the terminology you agree with, but what people are saying it that converting to/from void pointers is by far more common in C than C++.
>>
>>55560193
There is no implicit and explicit cast. A cast is a cast and this is the terminology that both I and the standard use. Moreover it was clear from the start what I meant.
>>
>>55560211
autism
>>
>>55560223
Autistic are the people who intentionally misinterpret what I said, explained multiple times and was clear about from the start.
>>
>>55560247
autist in denial because he's so autistic that he's unable to recognize his own autism
>>
>>55560247
Others are saying that it is common to use void pointers in C because C does not support compile-time generic programming. In C++, where you'd use *T, in C you must use void* and lose the benefits of type safety.

You are saying that you don't need to cast the return value of malloc in C.
>>
>>55560356
>You are saying that you don't need to cast the return value of malloc in C.
No, I am saying that I do not need to cast ANY value from or to void *. Not only from malloc.

>In C++, where you'd use *T,
Which is bad, see >>55558547

>C does not support compile-time generic programming
There are also macros.

>Others are saying that it is common to use void pointers in C
Maybe they do, but sadly 1: This is completely offtopic, 2: nobody disagrees with that, 3: next time they should be clear about it and use the correct terms and 4: they should not reply with unrelated stuff to posts that say that you do not need to cast from/to void * in C.
>>
>>55560411
>This is completely offtopic
shut the fuck up fucking retard, you don't decide the topic for the entire thread, delusional fuck
>nobody disagrees with that
sure seemed like that when you said things like "But this is wrong you fucking idiot."
>next time they should be clear about it
ahahahahahahahahaha
>they should not reply with unrelated stuff to posts that say that you do not need to cast from/to void * in C.
you or someone on your side of the argument brought it up out of the blue fucking retard
>>
>>55560447
>you don't decide the topic for the entire thread
I am not implying that I do, duh.

>sure seemed like that when you said things like "But this is wrong you fucking idiot."
Not on anything that claimed that.

>you or someone on your side of the argument brought it up out of the blue fucking retard
This was the topic from the start man. See >>55557989 (me)
>>
>>55560488
>>>55557989
was what i replied to, and it's fucking unclear so you are not in a position to complain, you are talking about the trivial syntax requirement of having to explicitly cast to/from void*, i'm talking about ACTIVELY USING void* as a "design pattern" which is BY FAR more common in C than in C++
>>
>>55560520
It's very clear. The term casting is very well defined both in general and in the standard.

>etc
we talked about it in the other thread. Can we continue on the new thread please?
Thread posts: 368
Thread images: 25


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

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


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