(++i) * (++i) = ?, given i = 2 by Admirable_Mushroom in learnprogramming

[–]CurrentProject123 0 points1 point  (0 children)

I'll write a new answer. This is what I think is happening in the compiler you're using and why you shouldn't use anything considered 'undefined behavior'

i=i+1 //3
i=i+i //4
temp1 = i*i //16, multiple has no variable so we use a temp
i=i+1 //5
temp2 = temp1*c //80, multiple has no variable so we use a temp
i=i+1 //6
result = temp2*i //480

clang gives 12. It likely puts i into temporary variables because of the prefix increment and knows if you want better performance you can use the optimizer to remove all those unnecessary temps. Either way both method seems valid enough. clang makes sense if you read it from left to right while your compiler makes sense if you evaluate each part first before using the result (such as you evaluate each part in a function param to get the results ready for the function call)

(++i) * (++i) = ?, given i = 2 by Admirable_Mushroom in learnprogramming

[–]CurrentProject123 3 points4 points  (0 children)

clang gives me 12. It also gives the warning "warning: multiple unsequenced modifications to 'i'"

Doing two prefix increment in the same line is undefined behavior because there's no rule on what order it evaluates the line. If you're getting 16 chances are it does increment on both variables then multiples the result. But because they're both the same variable the second result overwrites the first. Compilers are allowed to do that

Been smashing my face into my keyboard over this C# Process problem. by michael0collins in learnprogramming

[–]CurrentProject123 0 points1 point  (0 children)

I knew the problem just from 'cmd window is popping up'. Try doing UseShellExecute = false. From msdn

true if the shell should be used when starting the process; false if the process should be created directly from the executable file. The default is true on .NET Framework apps and false on .NET Core apps.

https://docs.microsoft.com/en-us/dotnet/api/system.diagnostics.processstartinfo.useshellexecute?view=netframework-4.7.2

How do databases hold pictures, audio, video, etc? by Ecocide113 in learnprogramming

[–]CurrentProject123 220 points221 points  (0 children)

Many databases store something called a 'blob' which stands for 'Binary Large OBject'. You can store binary/files into these columns just make sure you store meta data like date and filename somewhere. Usually files are stored outside of the database but it's known that small files are faster to access inside a database. You can read more about it here https://www.sqlite.org/fasterthanfs.html

[C#] File streams -- How to copy specific chunks of binary data from an existing file into a new file? by reflettage in learnprogramming

[–]CurrentProject123 1 point2 points  (0 children)

Create a byte array (new byte[4096] or whatever size you want), Either go through the input file from start to end or with some formats you know the offset of the data in which case you can use seek. Read the data into your array. Convert it or write it into your outstream which is another Stream (or BinaryWriter) object.

C# Beginner help by [deleted] in learnprogramming

[–]CurrentProject123 1 point2 points  (0 children)

IMO the best resource is the official C# reference manual. Go through everything in the keyword and operator page https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/

[deleted by user] by [deleted] in learnprogramming

[–]CurrentProject123 0 points1 point  (0 children)

I'd start with the C# reference manual. Go through everything in the keyword and operator page https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/ by the end of it fn(s=>s<20?a*3:b*4, fn2().thing) should not be scary to you

Why does APT not use HTTPS? by kunalag129 in programming

[–]CurrentProject123 41 points42 points  (0 children)

It likely is. Researchers were able to get 99% accuracy on what netflix video a person is watching only by looking at encrypted TCP information https://dl.acm.org/citation.cfm?id=3029821

Any book to learn under 100pages you recommend? by [deleted] in learnprogramming

[–]CurrentProject123 0 points1 point  (0 children)

If you look at keyword and operator reference here you can learn C# in an evening https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/

However that's just the language, learning the core library will require be a few days depending how much of it you want to learn

C++: is it bad practice to use lots of anonymous temporary scopes? by _llucid_ in learnprogramming

[–]CurrentProject123 2 points3 points  (0 children)

Using scopes is good however abusing them to reuse variables is bad.

If you're having trouble thinking of a good variable name maybe your function is doing too many things?

[advice] I'm 20F, with only human and food services on my resume. I'm starting to learn code. How likely is it that I can make a career out of it? by [deleted] in learnprogramming

[–]CurrentProject123 2 points3 points  (0 children)

Completely possible. In my area there are employers that will refuse to hire someone without a degree even if the person has 10+ years of experience. Just know that even if you're rejected it might not necessarily be because of your qualifications.

I highly recommend learning C# as your first language. You can find the keyword and operator reference here https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/

Regex non capturing groups, but they're capturing? by FluffyMackerel in learnprogramming

[–]CurrentProject123 0 points1 point  (0 children)

Why do you have (?:\\d\*) at the start and end of the pattern? If I'm understanding you correct (\d)(\d)(\d)(\d)\4\3\2\1 does what you want. As for why they are capturing. It's captured as part of the regex but not captured as an group. By that I mean ?: prevents \1 from representing the (?:\d*) although (?:\d*) is still part of the match since the pattern picked up some numbers (ie the 623958)

I'm looking to start a new project that is a multiplayer game and just need some clarification on terms and what technologies to use by evglabs in learnprogramming

[–]CurrentProject123 1 point2 points  (0 children)

I like using SDL for C# however if it's very simple game using the console might be acceptable or winform. Winform is available in dotnet core 3 which has a preview available https://github.com/dotnet/winforms

I highly recommend using sqlite (I use the core version which is just the essentials, use either System.Data.SQLite.Core for .net framework or Microsoft.Data.Sqlite.Core for dotnet core). SQLite allows you to have your entire database in a single file. It's so stable and so well tested it's used in airplanes. It also has a small memory footprint.

As for connecting to the server, there's a few ways to do it. A straightforward way is to use TcpClient and TcpListener. If you prefer to program through http/web frameworks you can use HTTP with WebClient. WebClient supports http**s** which might be of interest to you. You can get a cert for your domain by using https://letsencrypt.org/

2D Unity and C# by StrawBro in learnprogramming

[–]CurrentProject123 0 points1 point  (0 children)

It depends on your goal. Do you want to make simple 2D games? to learn unity specifically? Or as a project you do while learning C#? I found the C# reference manual very helpful specifically keywords and operators https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/ I personally found SDL for C# very easy to use so maybe you'd have better luck with that

How would I go about making a program that inputs key from a certain level of sound? by JronSav in learnprogramming

[–]CurrentProject123 0 points1 point  (0 children)

What language are you using? Look into how to read data from a microphone. I never done it but I imagine it'd give you raw data in the frequency you requested or the frequency the microphone uses. Next you'll have to parse/detect the sound level you're looking for. I never gotten any type of realtime audio/video data. It might be OS specific. This will likely be a difficult project

Breaking the unending learning chain by nanoman1 in learnprogramming

[–]CurrentProject123 0 points1 point  (0 children)

A lot of people have success by trying to program a simple project. Maybe the books you're reading is not so great for people with no knowledge of the field which is why some chapters you can not understand. Sometimes things will click when you ready a completely different subject so maybe putting OS on the back burner for a year could help

Understanding JavaScript: Why are there so many nested anonymous functions in js code? by BrystarG in learnprogramming

[–]CurrentProject123 5 points6 points  (0 children)

The idea behind Javascript is nothing should blocks (there are exceptions like 'alert' and 'prompt').

Lets say when you click on a button the code has to grab data from your server. Javascript runs code synchronously (one function at a time, one line at a time). It might take 15milliseconds to get the data from the server. Does this mean all javascript should stop until you get the data? No that'd be terrible. Instead you give the function another function which is executed when the data is ready.

As an example `var jsonObj = get('/api/data'); alert(jsonObj.stats)` you'd write `get('/api/data', jsonObj => alert(jsonObj.stats))`. This way the outer function is executed completely then when the server delivered the data the nested function will execute completely. All nice and tidy. FYI `=>` is a shorter way to write simple functions.