[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: 319
Thread images: 25

File: 1489656680340.jpg (15KB, 500x319px) Image search: [Google]
1489656680340.jpg
15KB, 500x319px
What are you working on, /g/?

Old thread: >>59549111
>>
I need help with this class assignment

#include <stdio.h>
#include <stdlib.h>
int main()

{
int n, odd=0, even=0, num, cont=0;
printf("What is the sequence size: ");
scanf("%d", &n);

while (cont < n){

printf("Type the %dth number: ",cont+1);
scanf("%d", &num);
if (num%2 == 0) even = even + 1;
else odd = odd + 1;

cont = cont + 1;
}
printf("The sequence contains %d even numbers and %d odd numbers .\n\n",even,odd);
return 0;
}


I need to print the odd and even numbers of the sequence WITHOUT USING ARRAYS OR STRINGS

I think it's impossible and my professor is just fucking with us
>>
>>59556227
>print WITHOUT USING STRINGS
what the fuck?
>>
>>59556227
Learn fucking for loops and fucking format your damn code.
>>
>>59556199
A homebrew webserver
>>
>>59556227
>I need to print the odd and even numbers of the sequence WITHOUT USING ARRAYS OR STRINGS
Just print them?
I don't see what's hard here at all. But you're counting the number of odd and even numbers for some reason. I don't get why.

Can you give the exact problem description?
>>
>>59556296
>blocking request handling

It's shit and your wasting your time.
>>
sepples question
I need to allocate some things in a fixed location in memory (eg, a std::vector<rgb_pixel> allocated directly in video memory)
what's the best way to design this?
>>
>>59556326
Well yeah. It's also iterative. I spend all of maybe an evening working on it so far, it's not supposed to be """"""production-ready"""""" yet.
>>
>>59556227
That problem description sounds very odd, is the original text available?
>>
>>59556115
I know, the OS was just an '''example'''. What I mean is, how can I jump that gap, how can I make myself better at it, not if building an OS is a big thing or not.
Do I use my basic knowledge and try to join a team of experts as an aspiring scrub? Do I keep making shit and hopefully getting better at making shit until I make some good shit? Do I keep reading books and believing I need a solid theory understanding and never doing anything?
>>
>>59556390
>Do I keep making shit and hopefully getting better at making shit until I make some good shit?
for me personally, that's the only way to learn.
>>
File: 1489287649089.jpg (186KB, 752x1063px) Image search: [Google]
1489287649089.jpg
186KB, 752x1063px
Is there some kind of RAD for Java?
>>
>>59556408
Any tips on shit to make? Or just do something I'm interested in and eventually become better?
I'm interested in Machine Learning and games. Any tips on how to follow these paths?
>>
i got to touch some old code for a company. This shit is wrote in flex3
Anyone experienced with this technology ?

I got a UI created dynamically and then I would like to access each element knowing their ID, name or whatever
>>
>>59556040
define "lightweight" and tell us what you're trying to do

>>59555959
>ut it's works only on MS platforms
Both of those are cross-platform.
>>
File: maki 32.jpg (36KB, 611x682px) Image search: [Google]
maki 32.jpg
36KB, 611x682px
Why can't CS graduates program?
https://web.archive.org/web/20160619103848/http://www.nomachetejuggling.com/2014/06/24/the-worst-programming-interview-question/

>Write a function that can detect a cycle in a linked list.
This guy threw up a shitfit because he can't think up the solution in 10 seconds, it's really stupidly easy.
>>
>>59556488
> define "lightweight" and tell us what you're trying to do
Lightweight means abscense of necessity to download heavy Visual Studio
>>
>>59556227
write them on a file and then read the file

Alternatively, create two processes, pipe between them
One read the user input, print the even numbers, and send the odd numbers to the other process on the pipe
Once it is done reading user input (and thus printing all even numbers, the other one start reading on the pipe and print the odd numbers.

I don't know if this kind of solution would work, it's been a while I didn't played with processes and pipes in C.
Is there any C wizard ? I'm actually interested on my solution and the actual solution to its problem
>>
>>59556518
for(auto* n : list)
{
if(n->next != nullptr && n->next->next == n)
// found it
}

would this work?
>>
>>59556518
Would they accept my answer if I just stored all the *next pointers in a flat array and sorted it?

If you have a duplicate of any memory address, that's a cycle, right?
>>
>>59556539
That would work if the duplicate was right after the last iteration.

copy to vector, erase duplicates, if list is different in size you have a cycle.
>>
>>59556488
>Both of those are cross-platform.
I wouldn't use incomplete (and third-party) solutions to be honest.
>>
>>59556576
oh youre right.
btw, what if i didnt want to create a copy, would a for inside a for do it?
>>
>>59556598
>>59556576
>>59556539
>read the article
>>
Just cuck my shit up already
fwrite(&(((uint8_t*)&code[offset][i])[j]), sizeof(uint8_t), 1, fout);
>>
>>59556609
>yes we know what the article says, we're talking about >>59556539

>>59556598
vector + unique is pretty fast, counting duplicates needs a copy, two loops iterating doesn't sound as fast
>>
>tfw your repository type is up to 8 different I*Repository interfaces implemented and 1400 lines of code and you're only about a third of the way through what was supposed to be a 'quick easy project'
>>
Making an email automation desktop program in C#, what's the best way to store email templates while preserving string interpolation? The end goal is that I want a user to either not have to worry about selecting one (pick one at random) or allow them to select a template.
>>
File: shot.png (11KB, 492x232px) Image search: [Google]
shot.png
11KB, 492x232px
Using Rust to make a TUI game.
hbu?
>>
>>59556806
Writing C code like a real man because I'm not a little faggot special snowflake that can't handle anything that as a pointer in it. Your kind should fucking die, you're the reason softwares are so shit nowadays. Pajeet use java but faggot numale code artisan, starbuck sipper like you use Rust. Enjoy your piece of shit language will you can. In 2 days max you'll abandon your shit project and consider suicide. Then after getting fucked in the ass by your girlfriend's feminine penis you'll come back here shitting on C programmers telling us how our language is so shit. Yeah guess what faggot, no one cares about you so how about you take a shovel and go bury yourself in the forest so you actually serve a purpose in your life by helping tree grow. Then MAYBE you'll pay back the debt you owe at humanity for even existing.
>>
File: alloc.png (50KB, 1007x610px) Image search: [Google]
alloc.png
50KB, 1007x610px
>>59556199
doing things with memories
>>
>>59556888
>Anon responds to OP's question
>Someone gets triggered because its Rust
Everytime
>>
Hm... Is there a way to get youtube to stream audio directly?
I remember that a while ago an anon made a youtube audio player, but I don't know he did something like that, or if it was just download+convert...
>>
>>59556806
bad post
>>59556888
good post
>>
>>59556888
#triggered by zero-cost abstractions, move semantics, guaranteed memory safety, threads without data races, trait-based generics, pattern matching, type inference, minimal runtime, and efficient C bindings. Truly Rust is the next step forward in programming.
>>
>>59556274
B-but I didn't write it

>>59556317

"Read a sequence of "n" numbers, count how many of them are odd and how many are even, then display the odd and even numbers that were inputed along with the count"
>>
>>59556532
The issue is doing that without arrays and pointers

All I should use are loops
>>
File: 200percent-smug.png (66KB, 206x369px) Image search: [Google]
200percent-smug.png
66KB, 206x369px
>>59556888
What, you can't handle the borrow checker, can you?
>>
>>59556409
Bumping question
>>
>>59556227
>That style
Kill yourself.
>>
>>59556518
But it's not a list if it has a cycle.
>>
>>59556227
I'm not 100% clear on the problem from the way you phrased your question but I'm guessing you're supposed to either output the number of even and odd integers in a sequence given an arbitrary sequence length, OR output all even integers and all odd integers, separately, given an arbitrary sequence length.
All you gotta do is a little bit of math on the sequence size to know the number of even and odd integers.
Simply counting up towards the sequence size and checking if the current number is even or odd will give you the ability to filter out odd from even when printing them separately.
int seq;
int i;
printf("Enter a sequence size:\n");
scanf_s("%d", &seq);
printf("Quantity of Even Integers in Sequence: %d\n", (seq % 2 == 0) ? (seq / 2) : ((seq - 1) / 2));
printf("Quantity of Odd Integers in Sequence: %d\n", (seq % 2 == 0) ? (seq / 2) : (((seq - 1) / 2) + 1));
printf("Sequence of All Even Integers: ");
for (i = 1; i <= seq; ++i)
{
if (i % 2 == 0) printf("%d ", i);
}
printf("\n");
printf("Sequence of All Odd Integers: ");
for (i = 1; i <= seq; ++i)
{
if (i % 2 != 0) printf("%d ", i);
}
printf("\n");


>>59556532
what?
>>
>>59556924
What editor is this?
>>
>>59557051
visual studio.
>>
>>59557000
Write the entire problem description because I don't see where it says "don't use arrays or strings".
>>
>>59557000
Christ. That is a nasty assignment. He's probably messing with you if this is an introductory course and it's not an introduction to recursive functions.
#include <stdio.h>

void countAndPrint(int odd, int even, int count){
int num;
if(count==0){
printf("There were %d even numbers and %d odd numbers.\nPrinted in reverse order:\n",even,odd);
return;
}
scanf("%d", &num);
if(num%2==0) {
countAndPrint(odd, even+1, count-1);
}
else{
countAndPrint(odd+1, even, count-1);
}
printf("%d ",num);
return;
}

int main()
{
int count;
printf("What is the sequence size: ");
scanf("%d", &count);
countAndPrint(0, 0, count);
return 0;
}

I haven't tested this.

And I'm not sure it even fits the description perfectly.
It's displaying the odd and even numbers but not grouped as odd and or even.
>>
File: Screenshot_2017-03-24_17-37-52.png (535KB, 721x550px) Image search: [Google]
Screenshot_2017-03-24_17-37-52.png
535KB, 721x550px
>>59556199
Working on encoding algorithm
>>
>>59557228
ENCODE MY ANUS!
>>
File: Screenshot_2017-03-24_17-40-11.png (15KB, 444x32px) Image search: [Google]
Screenshot_2017-03-24_17-40-11.png
15KB, 444x32px
>>59557228
data is a text file but it can work with anything
>>
>>59557228
use an index in the header or another file and remove the null bytes

(´・ω・`)
>>
Thanks you, but he thing is that you can input any number
Let's say you chose a 5 number sequence

Then you input
66
7
8
129
6666

The program must tell there are 3 even numbers, 2 odds
and show that the even numbers are 66,8,6666 and the odds are 7 and 129

The problem is how to store those numbers without arrays/strings
I think the word sequence isn't the right one
>>
Daily reminder that Cobol got user-defined functions in 2002.
>>
>>59557284
How would this work tho? Do I save the position of the null bytes in the index?
>>
>>59557049
Read:
>>59557300
>>
>linking Rust to C
The absolute mad-man.
>>
>>59557306
Assuming you're using them as separators between rows or chunks (or a similar concept to separate something) yep.
>>
Does anybody know an PSO r software package by any chance? I don't know the language that well
>>
>>59557327
oops
https://www.youtube.com/watch?v=AWnza5JX7jQ
>>
>>59557332
No they are actually used, they're not separator. I'm using the huffman coding so all I have in the file is a table at the beginning with the number of symbols (a symbol is a byte) and the code given to it then all the encoded symbols.
>>
>>59557343
disgusting. Look at this faggot, typical Rust """programmer"""
>>
void fun(const Foo* const bar const);


How the eff do i remember what the different levels of const does? Every time i need it i've forgotten and have to read up on it again. Every single time!
>>
>>59557359
see if it saves you any size by removing them and implementing that idea anyway, it seems like the table could be replaced with their position
>>
>>59557300
Assuming you're talking about >>59557156
>you can input any number
Check. You can input numbers up until you get a stack buffer overflow.
>then you input ...
Yep that's how it does things.
>The program must tell there are 3 even numbers, 2 odds
Yep
>and show that the even numbers are 66,8,6666 and the odds are 7 and 129
This is where it fails yes.

I can't work around this unless I get to use a bit array. And even then it'd be limited to 64 numbers total. And frankly I'd have an easier time just reading directly out of the stack.

This is also a question I have: >>59557148
Maybe you misunderstood the constraint?

And since you're probably new. This is all pure wank. Nobody will ever realistically ask you to work under these constraints or will give you any problems similar to this.
>>
>>59557379
Looks like a typical nerdy white male programmer to me. He just doesn't look like YOUR idea of a typical programmer which is a stinky Indian.
>>
>>59557387
Yeah but each null byte is one byte, storing the position of a byte would take one or more byte so it would compress. Or am I missing something?
>>
>>59557000
Couldn't you do something where you have four ints, two are counters for odd and even numbers, respectively, then the other two hold the actual numbers and you can just mod them out at the end?

User inputs: 1 3 5 7 2 4
Then you store:
countodd = 4
odds = 1357
counteven = 2
evens = 24

You could probably monkey around with the method to store numbers that are greater than single digits as well maybe by padding with zeros or something to signal the start and stop of a single number
>>
>>59557412
See https://en.wikipedia.org/wiki/Run-length_encoding
>>
>>59557049
That's close
But I need to print the odds and even separately

>>59557392
>Maybe you misunderstood the constraint?

No, I even confirmed that
We can use array/stings since we " haven't learned it" yet
>>
>>59557300
You could always be a cheeky little fuck and malloc a chunk of memory to hold ints instead of directly using array syntax
size_t seq_size; 
int *seq;
int *seq_idx;
size_t i;
int value;
printf("Enter a sequence size:\n");
scanf_s("%d", &seq_size);
seq = (int*)malloc(seq_size * sizeof(int));
seq_idx = seq;
for (i = 0; i < seq_size; ++i)
{
scanf_s("%d", &value);
*seq_idx = value;
seq_idx++;
}
seq_idx = seq;
printf("Values entered: ");
for (i = 0; i < seq_size; ++i)
{
printf("%d ", *seq_idx);
seq_idx++;
}

Don't cast malloc, btw. Only reason I'm doing it is because I'm using a C++ compiler.

>>59557380
const is read from right to left. This is a reason I continually tell people to always put const on the right.
void fun(Foo const * const, Bar const);

fun takes a constant pointer to a constant Foo type and a constant Bar type as parameters.
>>
>>59557430
I see. Thing is, consecutive null bytes, or consecutive bytes of any kind are pretty rare in the encoded file. I not sure it would be worth the trouble.
>>
>>59557466
>We can use array/stings since we " haven't learned it" yet
Ok. So we're even more constrained then. Can't do recursive calls.
What have you learned?
>>
>>59557425
Interesting idea, it wouldn't be a string after all

Let's say I separate the numbers with zeros, how do I clean it up later for print?

i.e. 1077017709 to 1 77 177 9
>>
>>59557490
We just finished while,for and do loops
>>
>>59557483
I suggested the RLE article, but I'm not the one that suggested encoding the null bytes.

Looking back at the earlier posts, I'm not really clear now on what it is you're trying to accomplish.
>>
>>59557481
That'll work, but then again I can't use all those "fancy" things
>>
>>59557522
I'm implementing this https://en.wikipedia.org/wiki/Huffman_coding
>>
>>59557531
this teacher sounds like a moron desu
>>
>>59557380
you rarely need to nest your const levels that deep. in general:

const thing*       // = mutable pointer to const thing.
thing* const* // = const pointer to mutable thing
const thing* const // = const pointer to const thing.
>>
>>59557494
Without actually working through it my intuition is to use a loop and mod through the number accumulating the digits until a 0 comes out then print the number and reset the accumulator
>>
>>59557550
edit: second should be thing* const.
>>
>>59557504
So you're gonna do this using the basic types like int, char & whatever. No conditionals aside from while for and do loops? I'm fairly certain you've misunderstood something or it's just a crappy teacher.

You really have more productive things to spend your time on. Playing videogames, masturbating or shitposting.
>>
>>59557380
The most important thing is to not use the edge case special syntax where you put const before anything else. If you don't, you just read from right to left and you get your answer.
int const * // pointer to constant int
int *const // constant pointer to int
int const *const // constant pointer to constant int
>>
>>59557581
>The most important thing is to not use the edge case special syntax where you put const before anything else.
What does that case mean?
>>
>>59557581
this guy gets it
>>
>>59557581
no, that's the confusing way. think of it as:
[const thing]*          // = mutable pointer to const thing.
thing[* const] // = const pointer to mutable thing.
[const thing][* const] // = const pointer to const thing.
>>
>>59557557
I'll try that
>>59557575
>or it's just a crappy teacher.

Probably
I'm curious to see her fucking resolution
>>
>>59557483
What you want to do is compute the autocorrelation function of your byte sequence and see if the data exhibits any periodicity. If it has some dominant high frequency patterns, you can XOR it with a simple periodic sequence to remove the periodic part. If your data is not random, this will often leave you with a pattern with a lot of repetition where run-length encoding is more applicable.
>>
>>59557617
>I'm curious to see her fucking resolution
I say you shouldn't complain about it (even to classmates). Accept it and move on. That's the wise decision.
>>
>>59557613
just stop your shitposting isnt funny
>>
>>59557586
If you put const before the type it's like putting const just after the type, but it breaks the easy right-to-left rule.

>>59557613
How is it confusing? It's more consistent.
>>
>>59557613
>const
>const *
>*const
>c++
>good language
>>
Almost got it, just need to know what does the % does here:

printf("%d\n", score % 10);
score /= 10;
>>
>>59557682
modulus
>>
>>59557682
% means modulus.
You divide the two numbers and the result is the remainder.
5%4

is 1.
4%5

is 4.
4%4

is 0.
>>
>>59557682
divides by 10 and gives you the remainder
>>
>>59557686
>>59557694
>>59557700

How did I forgot that
Thanks again
>>
>>59557343
Wow. So much effort just to use Rust for what's at most a marginal benefit.
Doesn't seem very realistic to expect people to do this.
>>
Wait a minute.
int const x, y; // both x and y are const
int *x, y; // only x is a pointer

What the fuck were they thinking?
>>
>>59557708
>Rust for what's at most a marginal benefit.
Well, converting a 500k C base to rust does have its benefits. But their situation is going to be very slow for a complete one.

Although I think Rust is overrated, this is one of its prime use cases.
>>
>>59557709

you can't have a variable and a pointer with the same name anyway
>>
>>59557625
Yeah I might do it later, thanks for the ideas
>>
im working on a c++ project,

I have to make a program that will be used to create a PC step-by-step so GPU CPU, etc. I want to hard write the items and their details in but we are supposed to use vectors to store them.

I have written an object for item details, but the template for the vectors are for input only, but you're not going to ask a customer to put in the details of a product right?

So i am not sure how to output the items in selection whilst they have all their values linked.

I was thinking of maybe making an object for each item type so that i can manually write in the items.


Would really just appreciate some senior knowledge. I have dyslexia and normal learning methods aren't that effective with me, I just like to pick at people's brains until i make sense of things in my own way
>>
>>59557739
That makes it even worse that a declaration isn't simply a type and a set of names. For a language that's supposedly simple and obvious this is a big fuck up. Now you have to talk about const being part of the base type and/or part of the indirection, instead of just having a single grammar for types and no funny business.
>>
>>59557778
So just a PCPP clone?
Why are you doing webshit in C++?
>>
>>59557813
yes pretty much, who knows why it was the chosen content.

I guess it utilizes everything we have been taught, but it doesn't come across at all in-depth. I just have a few wholes in my fundemental understand, as i am still a noob.
>>
>>59557840
So does it have to be a feature complete with prices and everything?
Have fun finding a decent networking lib.
>>
>>59557873
This is the assignment introduction. It only mentions storing them to be used later.


You have been employed as ‘Lead Programming Director’ for the object-oriented programming division within a local software house. A major online retailer has requested a system be built that allows customers to order electronic items.
There will need to be four sections to the program: a customers’ details section, item details, ordering system and an invoice section. These systems will need to work together to create a fully functional system.
For example, the items within the company will need to be stored so that they can be ordered later on:the following table could represent how the information would look.
Name Cost Quantity Left
GTX 1080 £500 3
M2 SSD £129.99 10
Logitech G502 £69.99 12

The customers’ details section should also be viewed in a similar way but must contain the following information:
• Name
• Email address
• Phone Number
• Age
• Gender
To make sure that customers are not let down when they put an order through, they must not be able to order a quantity over the amount that is currently left. These values should also be updated in real time based on other customer orders.
Once a customer has completed an order they should be provided with an invoice for the items that have been ordered, eg:
>>
>>59557709
this is fine.
const is a type qualifier, not a type specifier.
int const x, y; // const qualifies the int type. Int specifies the type. Both x and y are of "int" type.
int *x, y; // int * specifies the type. Both x and y are of type "int *".
>>
>>59557919
Why are they even separate things in the first place?
>>
>>59557896
That's pretty vague but it seems to be just a project structuring exercise with threads, and not actually insisting you full-stack a clone.


Id still email your professor though.
>>
>>59557974
yeah i think that's fair, it certainly seems to be more focused around structure, but i have wanted it to be near realistic as possible in terms of it was an actual PCPP(for more marks and learning). Just go to a stand still when i realised i have to get the item details some where without them being inputted to the user.
>>
It's the even odd guy again
How can I join two integers?

Like 12 and 5 to 125?
No strings/arrays, please
>>
>>59557974
>with threads
wut, just handle the request one by one in order and update the quantity after and you're done
I bet the requested are just an input file or user input
>>
>>59557896
>generating an invoice immediately when a sales order is placed instead of after shipping indicates that the order has been pulled and shipped and the revenue realization process is triggered

ISHYGDRDTSS
>>
Wrote a pig latin translator!

Gonna start learning about python dictionaries now.
>>
>>59558029
Hint: 12 * 10 + 5 = 125
I'll leave it to you to generalize this.
>>
>>59558019
Scrape everything from PCPP into a database and read from there.
>>59558040
> they must not be able to order a quantity over the amount that is currently left. These values should also be updated in real time
>>
File: Избор_107.png (42KB, 942x790px) Image search: [Google]
Избор_107.png
42KB, 942x790px
How do i disable that menu on the top?
>electron
>code is from example app
>>
>>59558059
>read user input
>>gibme 2 GTX 1080
>check storage have 4 left
>ok here they are, remove 2 GTX 1080 from storage <<<< real time updating
>read user input again
>>me wanna 10 GTX 1080
>check storage
>nigger I've got only 2 left
>>me sad, me not buying anything
>>
File: blackheart-walkingforward.gif (35KB, 150x170px) Image search: [Google]
blackheart-walkingforward.gif
35KB, 150x170px
How do i start learning to program?
is programming any fun?
which language teaches me how to be efficient?
>>
>>59558056
This was my first ideia, but what if you have 5,12 and 155?

It would be
12 * 10 + 5 = 125
155 * 100 + 125 = 15625 instead of 155125
>>
>>59558091
>>read user input
>>>gibme 2 GTX 1080
>>check storage have 4 left
>>ok here they are, remove 2 GTX 1080 from storage <<<< real time updating
>>read user input again
>>>me wanna 10 GTX 1080
>>check storage
>>nigger I've got only 2 left
>>>me sad, me not buying anything

so in this instance i will be using the vector for the live updating?
>>
>>59558098
> How do i start learning to program?
Don't.
> is programming any fun?
No.
> which language teaches me how to be efficient?
None. You can write shitty code in any language.
>>
>>59558098
>How do i start learning to program?
Watch some indian guy on Youtube
>is programming any fun?
It's like fucking sandpaper, it hurst all the way until you cum
>which language teaches me how to be efficient?

I'll leave that to others
>>
>>59558098
http://www.transum.org/software/Logo/
read the commands
click on "first challenge"
>>
>>59558102
155125 = 155 * 1000 + 125

The meat of the problem is how to determine how much you need to multiply by, which will be some power of 10.
>>
>>59558102
5,12 is not integer.
>>
>>59558098
It can be fun when you make money off it

No language really teaches you how to be efficient, you have to learn that skill yourself, with profilers and then you hate the language because things easiest to write are usually slowest to run.
>>
>>59558091
i mean, sure, one final check before actually shipping, but if hes going the extra mile. Might as well have it nice and threaded.
>>
>>59558124
Read it as 5, 12, 155
>>
>>59558107
Yes you just store your item in a map, the key is the item name and what you store is a structure with price quantity and whatever you want
>>
>>59558123
I was trying to avoid all that shit
Thanks
>>
>>59556360
do you have to implement HTTP/2?

I've been playing with shimmercat and it's pretty cool
>>
File: gee.png (40KB, 414x904px) Image search: [Google]
gee.png
40KB, 414x904px
>>59558084
>How do i disable that menu on the top?
gee I wonder...

>electron
kill yourself btw
>>
>>59558148
>{
>}
>{
>}
>{
>}
>>
>>59558141
I understand everything you said other than map, what do you mean by this?
>>
>>59558119
>>is programming any fun?
>It's like fucking sandpaper, it hurst all the way until you cum

Shit nigger, what an underrated remark.
>>
>>59558148
this is only webview, gimme ezer way to create it
>>
>>59558098
Pick a language
find its book and docs
find an IDE if available
start learning.

Many languages even have web boxes to play in before committing to anything.
>>
>>59558162
Well a map is another container but you said you need to use a vector so you'll need to store the item name in your structure and loop through your vector to find the requested item everytime.
>>
>>59558145
I'll get to it eventually but it shouldn't be too hard (from a design perspective) because the server just presents an opaque interface to the application code.
>>
>>59558131
>because things easiest to write are usually slowest to run
And then you have cunts who implement their own form of a standard library call that is much slower than if they just used the built-in function that's already optimized to hell and back.
>>
>>59558102
First, you are combining three numbers...
>>How can I join two integers?

However, assuming that there are 2 or more values to be joined and they are in, say, a list, you could iterate through the number of elements in the list and use the iterator as a power in order to achieve the correct placement.

//example in python bc i dont know what language your using
finalVal = 0
for a in range(len(list)):
finalVal = finalVal + (list[a] ^ (a + 1))
>>
>>59558174
what the fuck are you even on about you fucking mongrel?
you asked how to get rid of the menu from the example electron app, so I went to the example app and pointed out the menu which I assume you want to nuke the fuck out of the file because apparently you could not figure that out even though you had the files open more than likely which have that giant list labelled MENU
>>
>>59557380
A const pointer is pretty much always useless because when you use pointers you want to increment/decrement them and reassign them.
I don't think I've ever used one.
>>
File: dpt.jpg (164KB, 800x1000px) Image search: [Google]
dpt.jpg
164KB, 800x1000px
>>
>>59558203
I once had to work on a game where they did just that.

Everywhere.

And they thought they had to destroy all of their classes on shutdown or they would create a memory leak.
>>
File: 1489773692258.jpg (448KB, 1280x885px) Image search: [Google]
1489773692258.jpg
448KB, 1280x885px
I want to make a cross-platform GUI application. What's my choice?
I am thinking about Java and Swing, because, it seems, it's the only choice to make it once and run everywhere.
>>
>>59558212
>electron
>kill yourself btw
i was replying to this, creating webview with electron is fastest way and ezest
>>
>>59558228
QtQuick/QML
>>
>>59558228
hey is that uin the pic wanna be my gf
>>
>>59558204
made a mistake it would be
finalVal = finalVal + (list[a] * (10 ^ (a + 1)))
>>
>>59558233
and why would you want the entire chrome runtime to display 2 combo boxes, file chooser and a button?
>>
>>59558243
I'm using C, but that helped
Thanks
>>
>>59558228
Use Qt
>>
>>59558219
>C++ method
>C++
>method
Excuse you.
>>
>>59558219
/dpt/ right again
>>
http://www.sciencealert.com/pay-what-you-want-for-the-2017-complete-learn-to-code-bundle?utm_source=Facebook&utm_medium=Facebook_Ads&utm_campaign=Prospecting_SA_BoostedEditorial_PWYWLearnToCode_2.6.17


is something like this worth it?
>>
>>59558118
>>59558119
>>59558120
>>59558131

sounds like i won't do shit, but i'll do the logo exercises because they look fun, idk how is that related to programming like in coding.
>>
>>59558263
You're making a fool of yourself.
>>
>>59558312
not at all
also >falling for facebook adverts
>>
>>59558312
No, buy a proper book that focuses on a single programming language.
>>
>>59558312
>$22.39
>"Pay what you want"

Nope.
>>
>>59558253
it is compressing, converting and playing videos
>>
>>59558326
wasn't falling for anything, just wanted to see what some experts have to say about it ;^)

>>59558332
>>59558335
thanks ^^
>>
>>59558312
top kek you only get a fucking javascript book if you don't pay more than the average
and of course some faggot actually paid 144$ just to be on the top
>>
File: 1451427410862.png (745KB, 598x892px) Image search: [Google]
1451427410862.png
745KB, 598x892px
>>59558237
>>59558262
Java lets me to distribute .jar file and don't care about recompiling for other platforms.
I excepted to see some advices about right GUI library or maybe about analogs of Java (I am not aware of them), though.
>>
>>59556296
Cool
>>
>>59558369
Fucking pajeet, just take the fucking time to do it properly instead of being lazy
>>
>>59558369
At the end of the day, the only cross-platform desktop GUI that's going to look decent is going to be something v8-based like Electron.
>>
>>59558369
>to distribute .jar file
Which no self-respecting person will download and run.
>>
>>59558355
How to Design Programs is a good book.
If you want to be more practical, read K&R.
>>
>>59558323
C++ doesn't have methods though. It just doesn't.

C++ has member functions. Member functions serve the same ROLE as methods, but they are NOT METHODS. For the following reasons:

>1)
>a method is a kind of message that can be sent to a receiver object
>a member function is literally just a function, except it's declared with a specialized calling convention that passes a hidden "this" parameter

>2)
>a method's implementation is an inseparable internal part of its receiver, just like you shouldn't take someone's intestines out
>member functions can be separated from their "receivers," passed around as pointers, and invoked with a completely different "this" parameter in a completely different evaluation context
>>
recursive functions are just a glorified way of writing a for loop
>>
File: 1468168125283.jpg (5KB, 200x200px) Image search: [Google]
1468168125283.jpg
5KB, 200x200px
>>59558428
>>
>>59558228
God damn that's a cutie.

What do you mean by "make once and run everywhere"?

Desktop-only? Mobile and desktop? Mobile, desktop, and consoles? Mobile, desktop, console, and embedded devices?
>>
>>59558441
Desktop-only.
>>
>>59558440
posting silly images doesnt prove me wrong
>>
>>59557679
>durrrr i'm too retarded to remember simple distinctions hurrrrrrrrr
>>
>>59558454
Well, congratulations!

There's no such thing as a great cross-platform desktop GUI in any language, assuming you want to avoid Javascript.
>>
>>59558428
only when you only use tail-end recursion

you CAN use an iterative language to simulate more complicated forms of recursion, but in order to do that, a for loop isn't enough. you need to perform a depth-first traversal of a procedurally generated graph
>>
>>59558454
javafx has deprecated swing, you can also build it into mobile app with javafxports.
>>
>>59558466
You're not wrong. Your post was also bait.
>>
>>59558428
For loops are a glorified way of writing tail recursive functions.
>>
File: 1453653416673.png (408KB, 680x560px) Image search: [Google]
1453653416673.png
408KB, 680x560px
>>59558466
what if they're smug anime girls
>>
>>59558507
then theyre automatically right.
>>
>>59558472
>There's no such thing as a great cross-platform desktop GUI in any language
That's bad.
>great cross-platform desktop
Do great cross-platform non-desktop GUI exist?

>>59558476
OK, I'll look into it.

>>59558397
>that's going to look decent
?
>>
>>59558574
>Do great cross-platform non-desktop GUI exist?
UWP is unironically a great cross-plat GUI, but it's "cross-platform" in the sense of being able to run on various device families: W10, WP, Windows tablets, and XBone.

Xamarin and some mobile GUI frameworks built on Angular are great for C# and Java respectively, but Xamarin for example will only go to macOS for desktop; not Windows or Linux.
>>
Kind of looking for some advice.
It's been some time since I have programmed anything because I never know what to do with it. I enjoy it a lot but I can never come up with any projects and thus the skill sits there decaying as I do fuck all.

Know any sites or exercises that are good for at least improving or maintaining my skills until I find an actual project to work on?
>>
The only ways to make cross platform(desktop, mobile)
qt
javafxports(limited to only android / ios, no blackberry?)
lazarus(pascal)
custom opengl based solution: kivy(python), lambdanative(scheme), ...?
web shit
(gtk?) has been compiled on android but not fully supported.
>>
If I have a collection of important user-supplied settings, is it better practice to pass them down through scopes through function arguments or to put them in a global-scope object and query that from various nested functions?
>>
File: 1481175135200.gif (87KB, 192x197px) Image search: [Google]
1481175135200.gif
87KB, 192x197px
is Assembly as hard as it looks?
>>
>>59558836
No.
>>
>>59558836
Easier than js with meme framework of the week because documented better and it's really just simple instructions.
Of course if you have to do some kind of syncronazion with some external periphel then it goes pretty fucking really fast.
>>
>>59558836
No, because you consider much smaller pieces of code when you read assembly normally.
If you're doing large projects in assembly then yeah it's very hard.
>>
Dear anyone who thinks C is a good language: This is C's most straightforward way to read all the lines from a stream without setting length limits. (The function getline doesn't count because it's POSIX-only)

[/code]
#include <stdio.h>
#include <stdlib.h>
/** read_lines: Given a stream, consumes all of the text in the stream and
* returns a null-terminated array of null-terminated lines. The return value
* must later be passed to dispose_lines. */
char** read_lines(FILE* stream) {
static int const capacity = 256;
int line_count = 0, line_capacity = capacity,
char_count = 0, char_capacity = capacity;
char** retval = malloc(line_capacity*sizeof(char*));
retval[0] = malloc(char_capacity*sizeof(char));
{ char c; while ((c = fgetc(stream)) != EOF) {
if (c == '\n') {
retval[line_count] = realloc(retval[line_count], (char_count + 1)*sizeof(char));
retval[line_count][char_count] = 0;
char_count = 0;
char_capacity = capacity;
line_count++;
if (line_count >= line_capacity) {
line_capacity *= 2;
retval = realloc(retval, line_capacity*sizeof(char*));
}
retval[line_count] = malloc(char_capacity*sizeof(char));
} else {
retval[line_count][char_count] = c;
char_count++;
if (char_count >= char_capacity) {
char_capacity *= 2;
retval[line_count] = realloc(retval[line_count], char_capacity*sizeof(char));
}
}
}}
retval[line_count] = realloc(retval[line_count], (char_count + 1)*sizeof(char));
retval[line_count][char_count] = 0;
char_count = 0;
char_capacity = capacity;
line_count++;
retval = realloc(retval, (line_count + 1)*sizeof(char*));
retval[line_count] = 0;
return retval;
}
/** dispose_lines: Cleans up after read_lines. */
void dispose_lines(char** lines) {
{ int i; for (i = 0; lines[i]; i++) free(lines[i]); }
free(lines);
}
[/code]
>>
>>59558923
Nice code tags, dumbshit.
>>
>>59558923
FML I fucked up the [/code] shit.
#include <stdio.h>
#include <stdlib.h>
/** read_lines: Given a stream, consumes all of the text in the stream and
* returns it split into lines, as a null-terminated array of null-terminated
* character arrays. The return value must later be passed to dispose_lines. */
char** read_lines(FILE* stream) {
static int const capacity = 256;
int line_count = 0, line_capacity = capacity,
char_count = 0, char_capacity = capacity;
char** retval = malloc(line_capacity*sizeof(char*));
retval[0] = malloc(char_capacity*sizeof(char));
{ char c; while ((c = fgetc(stream)) != EOF) {
if (c == '\n') {
retval[line_count] = realloc(retval[line_count], (char_count + 1)*sizeof(char));
retval[line_count][char_count] = 0;
char_count = 0;
char_capacity = capacity;
line_count++;
if (line_count >= line_capacity) {
line_capacity *= 2;
retval = realloc(retval, line_capacity*sizeof(char*));
}
retval[line_count] = malloc(char_capacity*sizeof(char));
} else {
retval[line_count][char_count] = c;
char_count++;
if (char_count >= char_capacity) {
char_capacity *= 2;
retval[line_count] = realloc(retval[line_count], char_capacity*sizeof(char));
}
}
}}
retval[line_count] = realloc(retval[line_count], (char_count + 1)*sizeof(char));
retval[line_count][char_count] = 0;
char_count = 0;
char_capacity = capacity;
line_count++;
retval = realloc(retval, (line_count + 1)*sizeof(char*));
retval[line_count] = 0;
return retval;
}
/** dispose_lines: Cleans up after read_lines. */
void dispose_lines(char** lines) {
{ int i; for (i = 0; lines[i]; i++) free(lines[i]); }
free(lines);
}
>>
File: beautiful_code.png (348KB, 570x738px) Image search: [Google]
beautiful_code.png
348KB, 570x738px
>>59558936
>>
>>59558923
How are we supposed to trust someones opinion on programming if they don't even understand BBcode?

But yeah. If all your program is doing is reading files on multiple platforms maybe stay away from C? It's not meant for that.
>>
>>59558958
I do understand it, I just fucked it up. Besides, even if it were a matter of understanding, my understanding of C is clearly far superior to my understanding of BBcode, considering the code I posted above compiles, runs, does what it's supposed to, and does it efficiently.
>>
>>59558936
Looks much better now....
NOT
>>
>>59558985
>my understanding of C is clearly far superior

>allocating memory instead of filling user inputted buffer
You are shit C programmer and you can't even fucking BBcode.
>>
>>59558985
>and does it efficiently.
Depends on what you mean.
It's not efficient in terms of memory because your amortized growth structure is exponetial and not suited to the use case in any way.
It's not efficient in programmer time because you've written an amortized growth structure inline for apparently no reason.
You're using malloc for anything but upfront memory allocation, which is also not particularly ideal.

The one thing I couldn't really complain about without digging in is the execution time if we ignore the datastructure handling. You've made your code hard to analyse.

I would say you're good enough that you know C as a language but you don't know how to use it well.

Regardless all of this it's not the best case for C anyone cares about.
>>
File: 2.png (24KB, 142x132px) Image search: [Google]
2.png
24KB, 142x132px
>>59558955
thanks breh but C sucks desu
>>
>>59559042
>Regardless all of this it's not the best case for C anyone cares about.
I meant:
>It's not a case for C anyone cares about.
>>
>>59559048
You just suck at C senpai. Your style is terrible too.
>>
where do i find someone who will be willing to share their knowledge in c++ over a call and become bros too
>>
>>59559065
india
>>
>>59559035
>allocating memory instead of filling user inputted buffer
The whole point of the function is so that the user can read a file without knowing beforehand what size buffer they need.

>It's not efficient in terms of memory because your amortized growth structure is exponetial and not suited to the use case in any way.
On the contrary it's necessary because there are four alternatives and none of them are good:
>call realloc every two seconds
>require that the caller already know what size buffer they need
>use a linked list
>use rewind() (not possible for stdin)

>It's not efficient in programmer time because you've written an amortized growth structure inline for apparently no reason.
see above

>You're using malloc for anything but upfront memory allocation, which is also not particularly ideal.
see above

>You've made your code hard to analyse.
thx it's my speciality

>Regardless all of this it's not the best case for C anyone cares about.
It's an important use case for saving other programmers time when they have to read lines
>>
>>59558836
Assembly is just tedious because theres next to no abstractions.
>>
>>59558936
>multiple assignments on the same line
>fucking blocks without a newline
>assignment comma function call
>no separating empty lines
>inline for loop
Has to be bait.
>>
In Java, I'm tasked with creating

>a Subwindow which has one JLabel and two buttons (Hide and Exit)

I'm not using JSwing, but JavaFX. I have no clue how to use JSwing. What I want to do is contain JSwing elements inside of a JavaFX window. How do I do that? I am using SceneBuilder by the way.
>>
>>59559129
>four alternatives
There's far more than 4 alternatives. And I don't believe that you think there's only 4 alternatives.
>the whole point
Then it's not efficient. You could have a user facing api where you allow them an optional estimate of their line size. You could let them pass their own memory. You could do a million things to make this a little bit decent. As it stands it's the first draft of a generally fast read of a text file.
>see above
There's no reason listed for why you're inlining your datastructure that doesn't have an intimate relationship with your code.

I'm not gonna partake if you're just gonna pretend to be stupid though.
>>
Still working my way through HtDP.
>>
>>59559373
kann a shit
>>
In C, can the contents of one string be copied into another using pointers?
There's something I'm not understanding because I keep getting a segmentation fault.
  char *a = "abe";
char *b = "uaflajdfa";
while (*a != '\0')
{
*b = *a;
++b;
++a;
}
printf("%s\n", b);
>>
Hey, anyone in here find an anime girl?
>>
Need some advice for a CS class project.

I have a database file (with indexing via two data structures) and I want to parse a long command file that can contain any number of 5 different commands.

How should I design classes for the commands? Methinks I should create a:

1. abstract Command interface with an "execute" method
2. 5 specific Command type classes that implement this
3. a factory class that returns, given a line from the command file, a reference to a newly created command of the correct type

Is this good design or is there a better way?
>>
>Mfw my professor is the only human being on planet Earth who teaches Ada
>Google for help about Ada syntax
>Get his website.

Is he a world renown expert on Ada..? Or does nobody use it?
>>
>>59559468
In C, all string literals are immutable. It's because, when you declare char* a = "abe";, your char* a isn't just pointing to *some* string that reads "abe", it's pointing to *the* string *in your compiled program* that reads "abe" -- the *specific* string instance you *actually wrote on that line* -- and if you could modify *that* string, you'd have self-modifying code.

The easiest way to copy byte-for-byte the contents of a block of memory into a larger or equally-sized block of memory is to use memcpy(). By the way, though, if you want mutable strings, you have to memcpy() from the string literal into the variable, you can't just assign directly.
>>
>>59559498
Free (Coyoneda YourGADT) a
>>
>>59559542
>>Google for help about Ada syntax
just read THE FUCKING STANDARD
>>
>>59559468

strcpy.

And

>>59559558
>>
>>59559558
Damn. I'm doing a textbook problem where I'm supposed to write the function del_substr without any library functions. I'm going to have to rethink my approach.
>>
>>59559567
the FUCKING STANDARD is esoteric and hard to grok
>>
>>59559593
well then you should STOP BEING FUCKING RETARD
>>
>>59556227
c dosent support class assignment, maybe use python
>>
>>59559558
>you'd have self-modifying code
Why is it a problem exactly. The code segment isn't read only on Linux. The C standard say that it's forbidden (or an undefined behavior)?
>>
>>59559635
It's undefined.
>>
>>59559542
Who's your professor?
>>
>>59559583
You should be fine, if you declare your function with a char* parameter and not a char const* parameter then you can pretty much guarantee no one can (correctly) pass in a string literal. Compilers allow non-const references to hold string literals, but they shouldn't, because string literals are always const even when the code says otherwise -- and your professor should know this -- so if your function takes a char*, not a char const*, he should know not to directly pass in a string literal, and it's his problem if he does.
>>
>>59559498
>>59559565
e.g.

data File = File { name :: String, age :: Float, phone :: String }

data Com a where
Insert :: String -> File -> Com (Maybe Int)
Lookup :: String -> Com (Maybe Int)
Update :: (File -> Maybe File) -> Int -> Com Bool
List :: Com [Int]

type Command a = Free (Coyoneda Com) a

insert s f = (liftF . liftCoyoneda) (Insert s f)
lookup s = (liftF . liftCoyoneda) (Lookup s )
update f i = (liftF . liftCoyoneda) (update f i)
list = (liftF . liftCoyoneda) list
>>
>>59559718
This guy.

http://www.radford.edu/~nokie/classes/320/
>>
 int temp=123456678910 

while (temp0!= 0)
{
cpares = cpares * 10;
cpares = cpares + temp0%10;
temp0 = temp0/10;
}



I getting "[Warning] large integer implicitly truncated to unsigned type [-Woverflow]"

Is that a hardware,data type or software limitation?

If I use smaller numbers it weks
>>
>>59559741
I've never seen this website. What syntax confusion do you have?
>>
File: nocs.png (1005KB, 816x1328px) Image search: [Google]
nocs.png
1005KB, 816x1328px
>>59558228
https://github.com/ocornut/imgui
>>
>>59559723
>Compilers allow non-const references to hold string literals, but they shouldn't, because string literals are always const even when the code says otherwise
You have the right mindset here, but the way you frame it is not quite correct. Compilers allow non-const references to hold string literals because the standard allows it. String literals are NOT always const, but they ARE always IMMUTABLE. C only says you can't modify a string literal, it doesn't say you can't incorrectly mark it as modifiable.
>>
>>59559779
I figured everything out, just curious what the deal with Ada is.
>>
>>59559755
>123456678910
Your int data type is probably 32bit on your system so it can't store 123456678910 in it because it is too big.
>>
>>59559811
The 80s chose C++ for some silly reason.
>>
File: kek.png (429KB, 1363x606px) Image search: [Google]
kek.png
429KB, 1363x606px
>>59556199
I'm making a cool new website for my friend Shia https://github.com/kirkins/HWNDU-4CHAN
>>
>>59559755
2,147,483,647 is probably the max value of your integers.
>>
>>59559851
Doing Gods work.
>>
>>59559810
>C only says you can't modify a string literal
not really.
>>
>>59559739
whoops those last two should be Update and List
>>
>>59559851

Need any help?
>>
Once you learn how to deal with the 3 most difficult things in programming, you can do anything.
>>
Question about the following code:

#include <iostream>
using namespace std;
void func(long long int *fptr){
*fptr++; //fptr now points to ptr's address (at least on linux)
*fptr=*fptr-8;
}
int main ()
{
long long int *ptr;
long long int x = 5;
long long int y = 6;
ptr = &x;
cout << ptr<< '\n';
func(ptr);
cout <<*ptr << '\n' << &y;
return 0;
}


It seems like fptr is changing from a pointer to an integer to a pointer to a pointer to an integer, how is this type changing happening by just changing the address at which it is pointing?
>>
>>59557617
>I'm curious to see her fucking resolution
>>59557617
>>59557617
>>59557617
me too, when we'll you have it ?
>>
>>59559937
Sure not sure what to do next, I was thinking about making it crazy with lots going on all at once, laid overtop of the original with the removed flag.

Maybe we should make it more timed.

Like it start exactly like the normal site then have the kek flag replace HWNDU. Then have the video pop up and play, then have clippy pop up. then something else?
>>
>>59558936
Rate mine senpai.

int readlines(FILE *fp, char ***lines, size_t *len)
{
size_t alloc = 0;
ssize_t nbytes;

*lines = NULL;
*len = 0;

while (!feof(fp)) {
if (*len + 1 >= alloc) {
alloc += 16;
*lines = realloc(*lines, alloc * sizeof(char *));
if (!*lines)
return -1;
}

(*lines)[*len] = NULL;
nbytes = getline(&(*lines)[*len], &(size_t){0}, fp);

if (nbytes < 0)
break;

(*lines)[*len][nbytes-1] = '\0';
(*len)++;
}

return 0;
}
>>
>>59559937
Or maybe make an array of random things clippy can say.

Right now he just says kek every 7 seconds. We could make it a random from an array for strings.
>>
>>59558936
You know why C programmers never go past 5 character variables?

Your shit is impossible to read.
>>
>>59559815
>>59559859
Ok
I used long long now, but I still need a bigger number
>>
>>59560094
mpz_t
>>
>tfw you waste half the day tracking down a numeric precision issue reported by uses across multiple host databases and systems before you realize that it is simply a front-end issue where they are formatting it at only 2 digits of precision
>>
>run program
>page fault
>run program in debugger
>triple fault
hhhhnnnnngg
>>
Long time Visual studio c++ baby here.
i just switched to linux, any good books/tutorials on doing c/c++ dev on linux?
I know nothing about linux atm so it's all kind of confusing
>>
>>59560224
if you actually knew C++, you wouldn't be asking how to write C++ code without visual studio
>>
>>59560224
https://www.gnu.org/software/libc/manual/
>>
>>59556888
>THIS mad
Why are C toddlers so much insecure?
>>
>>59560248
They're as secure as their language
>>
>>59560266
kek
>>
>>59560224
Dietel C++
>>
what the fuck is wrong with javascript
>>
>>59560325
everything
>>
>>59560239
If you actually knew the most basic social skills, you wouldn't be criticizing someone for pretension they didn't actually demonstrate in any way when on the contrary they're damn well aware they don't "actually know C++" and only ever wanted some advice on remedying that problem.
>>
>>59559964
pls?
>>
>>59560325
>Designed and implemented in 10 days
>>
>>59560341
If anyone here actually knew the most basic social skills, they wouldn't be here.
>>
>>59560351
(*fptr)++;
(*fptr)-8
>>
File: 1422598944270.jpg (15KB, 200x287px) Image search: [Google]
1422598944270.jpg
15KB, 200x287px
Why are iterating for loops slower than incremental while loops in Python?
>>
>>59560351
go away sepples shitter.
>>
>>59560019
>while (!feof(
stopped reading
>>
import std.stdio;

void main(string[] args)
{
if (args.length != 3)
{
stderr.writeln("Sorry, This program only processes two strings. Exiting.");
return;
}
else
{
write("Matched common substrings are: ");
writefln("%(\t%s,%)", find_match(args[1], args[2]));
}
}

//find common substrings
string[] find_match(in string a, in string b)
{
string[] matches;
for (int i = 0; i < a.length; i++)
{
for (int j = 0; j < b.length; j++)
{
if (a[i] == b[j])
{
string current_match = "" ~ a[i];
int k = 1;
while (i + k < a.length && j + k < b.length && (a[i + k] == b[j + k]))
{
current_match ~= a[i + k];
k++;
}
matches ~= current_match;
}
}
}
cleanup(matches);
sort_by_descending_length(matches);
return matches;
}

//re creating the array without duplicate values
void cleanup(ref string[] elements)
{
for (int i = 0; i < elements.length; i++)
{
for (int j = 1; j < elements.length - 1; j++)
{
if (elements[i] == elements[j])
{
elements = elements[0 .. j] ~ elements[j + 1 .. $];
}
}
}
}

void sort_by_descending_length(ref string[] elements)
{
for (int i = 0; i + 1 < elements.length; i++)
{
if (elements[i].length < elements[i + 1].length)
{
string temp = elements[i];
elements[i] = elements[i + 1];
elements[i + 1] = temp;
}
}
}
Matched common substrings are: "ax", "oe", "xb", "x", "b"

>>59560224
I learnt C from dietel, it introduces you to C++ as well. I suggest that you should look at this
http://www.deitel.com/Books/C/CHowtoProgram10e/tabid/3678/Default.aspx
>>
>>59560367
The behavior is intended, I'm asking how is it possible that you can just change a variable type like that through abritrary pointer arithmetic? Is that intended?
>>
>>59560372
I use rust and haskell too, off with you one-language goblin
>>
>>59560408
>rust and haskell
I use Java, C, php, python, common lisp and bash...
Come back when you stop using meme languages.
>>
>>59560443
>MIPS
>C
>C++
>Java
>PHP
>Python
>Ruby
>LISP
>Scheme
>Racket
>JavaScript
>Lua
>Haskell
>Prolog
>BASh
>DOS
get on my fucking level
>>
>>59560443
better to use meme languages than trash languages
>>
>>59560443
You are like a little baby
>>
>>59560482
dos is not a language
>>
>>59560504
neither is bash, but in regard to putting THAT on a programming language list, you started it . .. . . .. . . ..
>>
>>59560386
What do you mean? You're not changing any types, you're just moving the pointer somewhere else on the stack frame.

>Is that intended?
Not at all, this is undefined behavior.
>>
>>59560482
>robotics
no u
>>
>>59559959
I will bite, what are the 3 most difficult things?
>>
>>59560538
Ok so initially changing *fptr changes the value of x, which is an integer. Then, after doing *fptr++, changing *fptr changes the address where ptr points to.

Initially fptr is a pointer to an int. After doing *fptr++ fptr is acting like a pointer to a pointer to an int, since changing it no longer changes x, but rather changes where ptr points to.
>>
>>59560616
1.) Get a job
2.) Delude yourself
3.) Be Happy
>>
>>59560616
telling ur mum ur gey
>>
>>59560382
Stop using D like C.
Use foreach
parallelism your ranges.
use slices
>>
>>59556199
Anyone know how to read data off an I2C bus? I get the concept about masters and slaves and registers, acknowledge bits etc, but I'm confused by the addressing....

The device I have lists "fields" and values e.g. 0x001E. Is this value my register or what? How am I supposed to know how many bits need to be sent?

Device used if anyone gives a shit, page 8-12 for data reads:
>http://ww1.microchip.com/downloads/en/DeviceDoc/00001888B.pdf
>>
>>59560726
Sorry, that's my babyduck syndrome. D is very comfy
import std.stdio;

void main(string[] args)
{
ulong total_words = args.length -1 ;
uint total_chars = 0;
foreach(arg; args[1..$])
{
total_chars += char_count(arg);
}

writeln("Total number of words: ", total_words);
writeln("Total number of chars: ", total_chars);
}

ulong char_count(string str)
{
return str.length;
}
Total number of words: 6
Total number of chars: 40
>>
https://youtu.be/HolVVAGPr_w

I've been working on this app. Tell me what you think guy says :)
>>
>>59560804

Think guys* don't know why it did that
>>
>>59560804
Is that a trap fuck finder?
>>
>>59560616
naming variables, and off-by-one errors.
>>
>>59560617
Yeah pretty much, I traced the UB in C because I like printf a lot better.

#include <stdio.h>

void func(long long int *fptr)
{
fptr++;
printf("fptr: %p, *fptr: 0x%llx\n", fptr, *fptr);
*fptr -= 8;
printf("fptr: %p, *fptr: 0x%llx\n", fptr, *fptr);
}

int main()
{
long long int *ptr;
long long int x = 5;
long long int y = 6;

printf("x: %lld, &x: %p\n", x, &x);
printf("y: %lld, &y: %p\n", y, &y);
printf("&ptr: %p\n", &ptr);

ptr = &x;
printf("ptr: %p, *ptr: %llu\n", ptr, *ptr);

func(ptr);

printf("*ptr: %llu, ptr: %p\n", *ptr, ptr);

return 0;
}


x: 5, &x: 0x7ffd15f360d0
y: 6, &y: 0x7ffd15f360c8
&ptr: 0x7ffd15f360d8
ptr: 0x7ffd15f360d0, *ptr: 5
fptr: 0x7ffd15f360d8, *fptr: 0x7ffd15f360d0
fptr: 0x7ffd15f360d8, *fptr: 0x7ffd15f360c8
*ptr: 6, ptr: 0x7ffd15f360c8


fptr++ moves to ptr's location in the stack frame, you then dereference fptr and change the value of ptr.
>>
>>59560832

No lol, it's party spelled backwards. Basically you create a trap, and your friends can add pictures to it if they're there
>>
>>59560840
>his language doesn't have a good bounds checker
>>
>>59560863
So you sign up as a trap and your friends can add pictures of them fucking you?
>>
>>59560875
Basically bro. It's pretty sweet
>>
>>59560800
Also local import all your things.
And get in the habit of only importing what you need.

>>59560800
module hello;
ulong char_count(string str)
{
return str.length;
}

void main(string[] args)
{
import std.stdio: writeln;
ulong total_words = args.length -1 ;
uint total_chars = 0;
foreach(arg; args[1..$])
{
total_chars += char_count(arg);
}

writeln("Total number of words: ", total_words);
writeln("Total number of chars: ", total_chars);
}


http://ddili.org/ders/d.en/Programming_in_D.pdf
>>
>>59560904
>get in the habit of only importing what you need.
Doesn't the compiler already do that?
>>
>>59560792
have you read "HID Over I2C Protocol Specification: Device Side"?
check section 7
>>
Anyone here use JavaFX? I have a problem and I can't find the answer. I'm using the Main, Controller, and .fxml method of making my program. I have two windows, the primary window contains a button that is supposed to show the secondary window.

What I want to do is create a method that shows the window and assign that to the button using the controller class. Like so:

 public void showSubWindow () {
anotherStage.show();
}


However the anotherStage doesn't exist in the Controller class, and I have no idea how to get it over to controller. Does anyone know how? Thanks.
>>
>>59560927
its for explicit readability and if you ever get into a name clash.
>>
>>59560325
dynamic typingsz
>>
Are all mature C codebases unreadable messes with ten layers of preprocessor macros separating each bit of readable code like the GNU stuff is?
>>
Why is X11 so shit.
Even though I ask for no extensions, I still get fucking SHAPE extension events when my windows in minimized. Complete violation of the spec (shouldn't send any events if I don't ask for them, outside a very small number of core ones), but marked as WONTFIX by the ubuntu devs for compatibility reasons.

Fuck X, fuck ubuntu. Why the fuck is this shit still around? We should have dropped X last millennium.
>>
>>59561036
yes
this is why c++ exists
>>
New thread:

>>59561050
>>59561050
>>59561050
>>
>>59558029

idk if even odd anon still around but I got a small toy example working that does only single digit numbers

http://pastebin.com/WafSV9Ji
>>
>>59561036
>all mature C codebases unreadable messes
Yes, more news at 9
>>
>>59561036
GNU is certainly far worse than most, but that doesn't make C good. Most projects have 3-4 lines of preprocessor per line of code instead of 10. (Still 3 too many!)
>>
>>59560369
Because C is always right. And if C say no to for loop it's because for lop are slow and C always choose the faster way. (for loop in C are masqueraded while loop)
>>
>>59561565
But quick search shows questions in the opposite, that for loops are faster. Could it be version specific in Python? I use 3.5.2
>>
>>59561808
Stop python and do only C and OCaml. You'll thank me.
Thread posts: 319
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.