[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
/dpt/ - Daily Programming Thread
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 255
Thread images: 38
File: DPT.png (389 KB, 934x1000) Image search: [Google]
DPT.png
389 KB, 934x1000
Old thread: >>54605498

What are you working on /g/?
>>
File: elePHPant.png (133 KB, 960x826) Image search: [Google]
elePHPant.png
133 KB, 960x826
>>54614329
dibs on the logo
>>
File: optimized.png (47 KB, 960x826) Image search: [Google]
optimized.png
47 KB, 960x826
>>54614368
your png is now optimized
>>
Trying to learn peer-to-peer programming

I'm rather confused but I'm working on it.
>>
>>54614329
Cortana APIs
>>
>>54614329
Has anyone here even read SICP? Is it worth all the hype it gets as an introductory CS textbook?
>>
File: 53524850485553485248.png (213 KB, 495x382) Image search: [Google]
53524850485553485248.png
213 KB, 495x382
working on an irc client for a game. should I use libircclient? I'm using C++ of course
>>
>>54614436
No.

No.
>>
>>54614442
No.

No.
>>
>>54614445
Why not? What would you recommend?
>>
>>54614442
God DAMN I love indignant tsunderes.

C++ would be a tsundere.
>>
>>54614459
Depends on the language you're learning.
>>
File: dptphp.jpg (79 KB, 934x1000) Image search: [Google]
dptphp.jpg
79 KB, 934x1000
>>
File: 56525449525156535250.jpg (55 KB, 813x1077) Image search: [Google]
56525449525156535250.jpg
55 KB, 813x1077
>>54614460
p-perv
>>
>>54614368
>>54614520
Stop trying to force your meme, faggot.
>>
File: x.png (7 KB, 193x193) Image search: [Google]
x.png
7 KB, 193x193
>>54614545
>>
>>54614537
x-xD
>>
How am I meant to read a file that has headings for each data I want to get?

StoreName1:

Name: chocolate
demand rate: 50
setup cost: 200
unit cost: 5.2
inventory cost: 2
selling price: 3

Name: cake
demand rate: 50
setup cost: 300
unit cost: 4
inventory cost: 2
selling price: 3.1

StoreName2:

Name: coffee
demand rate: 100
setup cost: 200.5
unit cost: 4
inventory cost: 2.1
selling price: 2


I need to read this into 2 store objects which contain product objects with the data listed below. I have no idea how I'm meant to achieve this as the format is really weird to me. I'm working with Java by the way.

So basically for the first store object, it would load a store object with the name 'StoreName1' and contain the product object with name 'choclate' ,demand rate 50, etc

Any ideas?
>>
>>54614599
That's the contents of the text file, right?
>>
>>54614622
Yeah and I have variable names demand_rate, etc in the product object. So I need to sort past all the useless text to get the number
>>
>>54614599
So all we get is C-heads fighting if a double- or triple-pointer linked list is faster

or

Java-heads who can't even parse a text file.


Post some some god damn lisp.
>>
i need animu wallpapers
>>
>>54614622
>>54614632
just write a basic parser. What's the problem? Check for a ':' every new line and store the number in your array or variabile
>>
>>54614671
Ah, I'm an idiot and didn't see the ':'. I was looking at it for ages too...
>>
File: 1460331297495.gif (140 KB, 379x440) Image search: [Google]
1460331297495.gif
140 KB, 379x440
>>54614666
It's not like we have an entire board for that, satan.

>>54614632
>>54614599
Parsing a text file with that sort of structure is easy.
>>
>>54614686
well..
even if it wasn't there though, you could just take the last 'word' (be it a number or product name) in each line.
>>
>>54614599
Read each char until you find a ':'
then read each char until you find a new line ending '\n'
simple
>>
F# is based, BASED!
>>
File: 1439182703026.png (4 KB, 365x17) Image search: [Google]
1439182703026.png
4 KB, 365x17
In C++, what does it mean for a parameter to have double ampersand?
"reference to reference" doesn't make much sense if we're talking about C++ references, so what does it mean or do?
>>
>>54614834
rvalue reference
>>
>>54614834
In C++11 you can pass the address of an rvalue to a function. This is useful for certain optimizations. At least, I think; I'm still trying to get the hang of move semantics et al.
>>
Does anyone have a program with more than 100 K lines.?

i want to test my grep function
>>
>>54614983
Just go on Github and find a project.
>>
>>54614983
I had one which would match regexes agains legacy code, for finding certain functionality.
>>
>>54614995
yeah i know that but i want more than 100 K lines
>>
>>54614983
I think this is a small project which likely has that.
https://github.com/torvalds/linux
>>
>>54615010
disclaimer: not something serious and professional like Unix
>>
Hey gee, can a C++ reference be null?
>>
>>54615086
it's called a nullptr yes
>>
>>54615086
no
>>
>>54615103
>>54615090
Yes or no?
>>
>>54615086
No never. Some say it's just syntax sugar for a pointer but the magic of C++ makes it so the language magically knows when the reference goes invalid. Thank Odin for that. Because if that wasn't he case C++ applications would crash all the time or be horribly buggy messes.
>>
>>54615131
Are you confusing references with smart pointers?
>>
>>54615154
No I'm being sarcastic about references. References are just syntax sugar for pointers excluding some very rare occurrences where you'd have runtime errors using pointers and compile-time errors using references.

I find references annoying because you lose the context you're working in sometimes.
>>
I like Rust.
>>
>>54615202
>webcuck
>>
>>54615180
>References are just syntax sugar for pointers
no, their semantics are different. syntax sugar is when different syntactic constructions share the same semantics.
>>
>>54615221
Lol, Rust is not even good for webdev.

You sure you're allowed to browse a 18+ site?
>>
>>54615245
Whatever. You get my point I hope.
>>
>>54615257
rust is made for web devs, by web devs
>>
>>54615257
>I tried webdev with rust but it wasn't even good
like I said, webcuck
>>
>>54615245
How are they different?
>>
>>54615274
>Literally made for servo
>a broswer engine

I didn't even try it. I know what my tools are and aren't good at.

You sure you're of age tho?
>>
>>54615291
>confirmed webshit
>>
>>54615321
Yes but, are you even capable of arguing?
>>
>>54615291
>browser
>WEB browser
jackass
>>
>>54615337
>web browser
>a userspace program running on a wm
>definitely NOT a webapplication

Your troll is so weak I don't even know where to start ;)
>>
>>54615366
it's web-related, only relevant for webshit

fuck off to >>>/g/wdg fag
>>
>>54615334
>Yes
:^)
>>
>>54615380
But sempai, what are you writing this shit on? A web application? B-baka!
>>
If I want to get into making games, is there any reason not to use opengl. It feels like you basically end up reimplementing a lot of opengl if you dont.
>>
>>54615245
They have the same semantics.
>>
>>54615380
>C can be used to program an OS
>an OS is needed to browse the web
>therefore, C is a webdev language
kys sperg
>>
>>54615405
use opengl, it's not even hard, you could use a pre-built engine but i can guarantee you the results would not be very good using an engine and it would still take a ton of work with not much benefits
>>
>>54615291
servo is pointless since mozilla have decided to move to webkit
>>
In C++, is there a difference between
T& arg
and
T &arg
?
>>
>>54615407
>mozilla
>anything but webdevs
lad...
>>
>>54615420
>servo is pointless
But that's not the point
>>
>>54614983
Maybe the rust compiler? https://github.com/rust-lang/rust
>>
>>54614436
>Has anyone here even read SICP? Is it worth all the hype it gets as an introductory CS textbook?
I did. It's a great book, but you'd be really lost if you use it as the only introductory course (after all, 6.001 was just one among few computer-related courses). And it has a content which isn't really obvious because it, for the lack of a better phrase, reaches a bit too far.
But when you do get it, when it clicks, even if it happens a few years down the line, and you understand what it's been trying to tell you - you will understand its greatness. It really does change how you think about things - even if you don't notice it yourself.
>>
>>54614599
Is this harder than it looks, or am I fucking stupid?

Anyone have a working example?
>>
>>54615444
the point is to use servo as Firefox's engine, but firefox is moving to Webkit anyway
thus pointless and will soon stop getting mozilla funding
>>
>>54615428
no, spaces and newlines never matter

I usually write the latter.
>>
>>54615428
No.

You could also write
T & arg
>>
>>54615482
>pointless and will soon stop getting mozilla funding
RUSTFAGS BTFO
>>
>>54615475
see >>54614599

you can then put things like a leading newline means a new store object or whatever
>>
>>54615428
No. Just like T* var and T *var. I use the former style in C++, because I think more in terms of types, and with C++11 semantics you really can do that. In C, however, I prefer the latter.
>>
>>54615482
>>54615501
Nice source :^)
>>
>>54615482
>firefox is moving to Webkit anyway
Wait what
I've been living under a rock. When did they get away from Servo and Gecko?
>>
>>54615482
But sempai, the argument was weather Rust is a webdev or systems language, not if servo is good or relevant or anything else.
>>
why aren't you using brave
https://www.brave.com/
the browser from the anti-SJW ex-mozilla CEO who got outed despite his efforts
>>
>>54615541
https://www.rust-lang.org/conduct.html

obviously a web fag lang

>Adapted from the Node.js Policy on Trolling

but seriously, rust is pretty shit, it's pointless, it's not better than C++ in any way
>>
>>54615535
They didn't. You're being rused.
>>
>>54615568
>literally zero memory safety bugs

You really sure?
>>
>>54615596
>literally zero
retard confirmed
>>
>>54615568
>it's not better than C++ in any way

Nice meme
>>
>>54615568
have you given it a try or are you just talking out of your ass?
>>
File: haskelel2.jpg (745 KB, 1920x1080) Image search: [Google]
haskelel2.jpg
745 KB, 1920x1080
>>54615596
>le "the compiler can fix all my bugs" retarded shit meme
>>
File: 1443207826687.png (16 KB, 998x106) Image search: [Google]
1443207826687.png
16 KB, 998x106
>>54615560
It's shit.
>>
>>54615615
Do you actually know *anything* about the thing you're talking about, sempai~ ?
>>
>>54615647
it's seriously written in javascript?
>>
>>54615652
>literally
>>
File: 1442194705035.png (35 KB, 912x526) Image search: [Google]
1442194705035.png
35 KB, 912x526
>>54615655
Yes.
>>
>>54615655
it uses V8, so just chrome anyway
>>
>>54615672
>build failing
lel
>>
>>54615568
>but seriously, rust is pretty shit, it's pointless, it's not better than C++ in any way
from the home page

"""
guaranteed memory safety
threads without data races
trait-based generics
pattern matching
type inference
minimal runtime
"""
>>
>>54615672
it's the scripting language, like how you have lua to script on top of C++

this one is javascript over C++
>>
>>54615672
>>54615677
can't we get a non-shit browser in C/C++ or hell even java would be better than fucking cancerous js
>>
>>54615683
https://travis-ci.org/brave/browser-laptop/builds

The build history looks quite bad.
>>
>>54615704
V8 is C++
>>
>>54615689
>threads without data races
babby bloat
>>
>>54615704
But how would you hot-patch it, if it wasn't run in an interpreted language?
>>
>>54615689
Is it proper type inference anyway

Kotlin has shit type inference where you need to specify types for example

proper as in you don't need to write the type of function parameters, it can do it for you by looking at the function code
>>
>>54615721
why would you have to hot-patch it, browsers have to restart after updating anyway
>>
>>54615716
avoiding data races is the main concern of concurrency programming for years now, explain how it's bloat.
>>
>>54615737
You'd you sacrifice maintainability for a gimmick (in a systems language, at least)
>>
>>54615768
it's bloat compared to C/C++ if it has a bunch of safeguards built in, the programmer can use mutexes and memory barriers etc, it's fucking easy, only fucking webshits need to be coddled with that stuff
>>
>>54615737
>proper as in you don't need to write the type of function parameters
you have generics for that
>>
>>54615418
well I could just use sdl. But I feel like I would still have to implement a lot of the basics.
>>
Does Node.js server work go here?
Please I don't want to visit webdev general. They smell like designated streets.
>>
>>54615790
that's what does rust but contrary to c++, you actually have guaranties provided by the superior type system and semantics of the programming language.
Concurrency in c++ is tedious, error-prone, and hazard-prone (by both the hardware and the compiler).
>>
>>54615966
sdl is really bare-bones so you would still do a lot of work, and sdl 1.0 uses deprecated opengl and software rasterization

especially if you're just drawing plain rectangles it's really easy to do with opengl, and with opengl you can expand upon your knowledge to do more advanced 3d graphics programming
>>
>>54615704
Write one you turbocuck
>>
>>54616007
yeah, don't listen to "hurr webshits" fags, they're just an insecure bunch with nothing better to do.

What's your question?
>>
>>54616007
it goes in >>>/g/wdg, you're much more likely to find people with node.js experience there than in here
>>
File: wpGX713.png (61 KB, 1089x794) Image search: [Google]
wpGX713.png
61 KB, 1089x794
>>54614599
Are you sure you're ready for this?

Enjoy:
static void PajeetParse()
{
var stores = new List<Store>();

var ayy = ReadAllLines(@"C:\temp\stores.txt")
.ToList()
.Where(x => !string.IsNullOrWhiteSpace(x)).ToList();

var lmao = ayy.ChunkOn(x => x.EndsWith(":"));

foreach(var store in lmao)
{
var tempStore = new Store();
tempStore.items = new List<Item>();

var poo = store.ChunkOn(x => x.Contains("Name: "));
tempStore.StoreName = poo.First().First().TrimEnd(':');

foreach(var loo in poo.Skip(1))
{
tempStore.items.Add(new Item()
{
Name = loo[0].Split(':').Last().Trim(),
DemandRate = loo[1].Split(':').Last().Trim(),
SetupCost = loo[2].Split(':').Last().Trim(),
UnitCost = loo[3].Split(':').Last().Trim(),
InventoryCost = loo[4].Split(':').Last().Trim(),
SellingPrice = loo[5].Split(':').Last().Trim()
});
}

stores.Add(tempStore);
}
WriteLine($"There are {stores.Count} stores.");
foreach (var paj in stores)
{
WriteLine($"In the {paj.StoreName} store, there are {paj.items.Count} items: ");
foreach(var eet in paj.items)
{
WriteLine($" --- {eet.Name} sells for {eet.SellingPrice} and costs us {eet.InventoryCost} to stock.");
}
}
WriteLine($"");
}


public class Store
{
public string StoreName;
public List<Item> items;
public Store()
{

}
}

public class Item
{
public string Name;
public string DemandRate;
public string SetupCost;
public string UnitCost;
public string InventoryCost;
public string SellingPrice;
}
>>
File: for-loop help.png (12 KB, 785x115) Image search: [Google]
for-loop help.png
12 KB, 785x115
>>54614329

New to programming, learning and practicing for-loops.

Everything was going fine until it wouldn't return the correct values.

It outputs the first one, as expected, but then everything else is zero. Just 1,0,0,0,0...etc.

Unsure as to why, would anyone be able to help me?
>>
>>54616868
(l/i) is doing integer division, isn't it?
>>
>>54616868
The division is performed as integer division and then the truncated result is stored in the float.
>>
ITT: C/Java/Lisp programmers know nothing about type systems and simply assume that the Rust developers must be lying when they say it can achieve almost total memory/concurrency safety guarantees without any overhead.
>>
>>54616920
>without any overhead
funny because it's several times slower than C/C++
>>
>>54616953
Source?
>>
>>54616953
in a single benchmark. for everything else the difference is tiny (like 1.61 s vs 1.57 s)
>>
File: meh.png (85 KB, 855x704) Image search: [Google]
meh.png
85 KB, 855x704
Linux has no games, etc, etc, etc.
>>
>>54615772
Where are you getting "type inference sacrifices maintainability" from?
>>
How do I turn my C project from a bunch of files and includes into something that other people can download and run?
>>
>>54617133
With a compiler?
>>
>>54617133
a makefile
>>
Are linked lists the best way to implement stacks/queues in C?
>>
>>54617133
just provide binaries for dumb windows users and a makefile for everyone else
>>
>>54617188
>best
As always, it depends.

I prefer to use an array-based DS when I can, because it's not usually the case that I need to worry about either having the size growing all the time or about wasting memory left over after the size goes down again.
>>
>>54617188
They're straightforward but they're definitely not the most performant solution.

An array stack is piss easy to setup and doesn't require a costly malloc on every push.
>>
>>54617257
>>54617236

What about queues?
>>
>>54617289
Same thing.
>>
>>54617289
Queues are best implemented as fixed sized circular arrays.
>>
>>54616920

I don't think anybody is suggesting that Rust's safety isn't zero-cost. Everybody just thinks it's fucking annoying.
>>
>>54614834
Its move semanrics. Used in copy ctors and assingment operators. Something like a regular object creation but instead of allocating new memory (ptr to new) and copying there resources, you're leaving them in original place of memory and just change the owner of it
>>
>>54617289
>>54617340
Not necessarily fixed-size, though. You can also have them grow dynamically like C++ vectors.
>>
>>54617343
Maybe if you don't take the time to understand it. I never ran into any issues.
>>
>>54616777
is that c#? looks kinda sexy
>>
>>54616868
1.0 / i
>>
>>54617410
Yeah.
>>
What are some good books for algorithms and data structures?
>>
>>54617439
wikipedia
>>
>>54617439
https://en.wikipedia.org/wiki/Algorithms_%2B_Data_Structures_%3D_Programs
>>
>>54617439
your mom
>>
>>54617426
recommend any good books?
>>
>>54617503
extremely rude
>>
Hey /dpt/, ag, ack, or pt?
>>
>>54617533
cp
>>
>>54617439
Purely Functional Data Structures
>>
>>54617520
I haven't been in school in a while.

I learned on Murach's, but I'm thinking there are more modernized books out there.
>>
>>54617555
data structures != functions
>>
>>54617562
good enough for you, good enough for me. *goes to ebay*
>>
>>54617424
>>54616905
>>54616897

Beautiful it works now and I understand. Thank you so much, guys
>>
>>54617390
>Maybe if you don't take the time to understand it.

I'm sure you understand it perfectly and never have compilation errors related to Rust's safety systems.
>>
File: rust.png (11 KB, 512x512) Image search: [Google]
rust.png
11 KB, 512x512
To all of you who lost the joy of programming, learn Rust and it will come again. Trust me.
>>
>>54618101
Every time I program, I maintain a rock-hard erection.

I have no need for Rust's lies.
>>
>>54618063
If I do, I know what I'm doing wrong and I accept why Rust thinks it shouldn't let me do that.
>>
>>54618118
>Rust's lies
Which ones ?
>>
>>54618152
That it can give me any more joy than I am already experiencing.
>>
tell me why rust isn't just yet another flavor of the month /dpt/ meme lang
>>
>>54618174
That's exactly what it is.

C is eternal.
>>
>>54618174
But it is.
>>
>>54618174
It's actually an improvement upon existing languages in its "field" and not just yet another rehash of things we've seen a million times before with slightly different syntax.
>>
>>54618236
>not just yet another rehash
>We do not employ any particularly cutting-edge technologies. Old, established techniques are better.
>>
>>54618174
It's what C should have been if dennis were not plt illiterate.
>>
File: car_desktop.png (640 KB, 1366x768) Image search: [Google]
car_desktop.png
640 KB, 1366x768
Made a tool that prints images to the console (up to 256 colors if your terminal supports that many).

Isn't this car cute! Unfortunately the "pixels" I print are huge so I can only do low resolution images like this
>>
>>54618265
Old and established in academia, yes. They're known to work, it's just Rust is one of the first to use them in a practical language instead of yet another research language (referring to its type system here).
>>
>>54618063
compilation errors are a good thing gtp
>>
File: whypeopleseemtohavefreetime2.png (183 KB, 1178x975) Image search: [Google]
whypeopleseemtohavefreetime2.png
183 KB, 1178x975
The best thing about working with SFTPs is that everything on them is damn slow, so I get to work 10 minutes and browse reddit for 5 hours.
>>
I want to try and develop android on Qt i already have installed Qt for windows with msvc

I already had the android sdk and just downloaded the ndk

Now how do i install Qt for android? I downloaded the offline installation of android from here

>https://www.qt.io/download-open-source/#section-2

But when i want to install it it wants to reinstall a lot of the things i already have, and i can't disable the installation of Qt Creator so how do i add it?
>>
>>54619554
Leave, and please do not come back.
>>
>>54619554
keep underachieving, fag
>>
>>54619749
Head's up qt doesn't support java
>>
>>54619888
I just want to try and port my Qt program
But i can't figure out how to add "Qt for Android" without having to install completely another Qt because i already have one installed
>>
im writing a youtube view generator in python
I just need to put an ip scrambler in it

Any modules/ideas for writing an ip scrambler in python?
>>
>>54620017
I heard killing yourself is pretty helpful
>>
>>54620017
ip_addr = ".".join(str(__import__("random").randint(0,255)) for _ in range(4))
>>
>>54618314
Looks cool. How do u supply input data? A nirmal image being read and redrawn?
>>
>>54620017
surely they can see the actual ip address you're using and not just the one you're claiming to use
>>
>>54618314
post it pl0x
i wanna try it out
>>
>>54620373
im looking to change my external ip every X seconds
>>
>>54618126

Sure, but becoming good enough that the errors rarely occur is a considerable amount of work. The learning curve is steep.
>>
>>54620067
tried, still didnt work
>>
>>54620472
Same for being able to write correct, non-toy C programs. The difference is that Rust is able to tell you what you're doing wrong, in detail, at compile-time, whereas C gives you a segfault which you have to tediously debug.
>>
>>54620547

Errors in Rust aren't necessarily seg faults in C.
>>
>>54620651
Or data races, or getting garbage through an invalidated pointer, or whatever. Both of those are even more difficult to debug.
>>
>>54620670

Right, possibly, but unsafe memory handling by Rust standards doesn't necessarily guarantee an error will occur in a similar C program.

In any case, we're off on a tangent. Rust is hard. That's all I meant to say.
>>
Continuing my programming self-teaching with Java, question says to use the "Zeller's Congruence" formula to "Write a program that prompts the user to enter a year, month, and day of the month, and displays the name of the day of the week." I've got what I think is right all set, but when I have the "user" input the values from the test run in the book (2012, 1, 25), I don't get any output.

import java.util.Scanner;
public class Chapter3_PE_3_21 {

public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.print("Enter the year: ");
int year = input.nextInt();
System.out.print("Enter the month (numerically): ");
int month = input.nextInt();
System.out.print("Enter the day of the month (1-31): ");
int date = input.nextInt();

if (month == 1) {
month = 13;
year = year - 1;
} else if (month == 2) {
month = 14;
year = year - 1;
}

int weekday = (date + ( (26 * (month + 1)) / 10) + (year % 100) + ((year % 100) / 4) + ((year / 100) / 4) + (5 * (year / 100)) % 7);

switch (weekday) {
case 0:
System.out.println("Day of the week is Saturday");
break;
case 1:
System.out.println("Day of the week is Sunday");
break;
case 2:
System.out.println("Day of the week is Monday");
break;
case 3:
System.out.println("Day of the week is Tuesday");
break;
case 4:
System.out.println("Day of the week is Wednesday");
break;
case 5:
System.out.println("Day of the week is Thursday");
break;
case 6:
System.out.println("Day of the week is Friday");
break;
}
}
}


Where did my retarded ass go wrong?
>>
File: IKDjdf8sh89fas.jpg (57 KB, 600x400) Image search: [Google]
IKDjdf8sh89fas.jpg
57 KB, 600x400
Quick Question:

What's the proper way to show lines of code on a professional report?
>>
        try {
startActivity(new Intent(this, Class.forName(target)));
} catch(ClassNotFoundException e) {
....
}

'target' is a compounded string of the package FQN and curiously, an acquired string from androids string.xml resource, which contains the name of the activity class that I want to start (ie. "My Activity", resulting in "com.example.MyActivity" after formatting).

Can anyone off the top of their head observe any nasty problems with this, besides that it would shit itself if I changed the string value in the xml to match a translation?
>>
>>54621153
Work? Might be complicated, but just for uni stuff i always pasted white background images from IDE with highlighting.

Doesnt work if u want to put hundrets of code thou...
>>
>>54620358
Yeah, just specify any image and it works.

>>54620452
Bleh, it's too messy. Maybe later.
>>
>>54621153
Most IDE's and text editors support a way to export code to pdf/html and possibly other formats.

Copying from html to word has worked surprisingly well for me in the past.
>>
>>54621153
What format are you using? IEEE?

When writing for most formats, code should never be language specific. Pseudo code only.
>>
>>54621394
I'm writing a report on dc motor control for uni and I'm including the code I used for the arduino. I'm guessing an acceptable way is just to copy and paste.
>>
Why is the girl in op pic upside down?
>>
>>54621153
Notepad++ lets you "copy" a selection as either RTF which pastes nicely into word.
Arduino and other fucboi IDEs might let you export to HTML, which you can then direct copy-paste into word (with chrome at least, some browsers don't play so nicely).

Also, don't even bother with the line numbering option in word, it doesn't differentiate between actual line breaks and wrapped lines.
80 columns gets eaten up quickly in even font size 10 when using a uniform width font like consolas.
>>
>>54621554
Arduino wont directly do what you want, but it's close enough.
Select the section (control+a to select all), then control+alt+c to copy as html formatted text.

Paste that into a blank text file, save as html, open with chrome, then use that to copy/paste into word.

>hurr why are you suggesting a particular browser
Because I know it works with chrome, and might not with other browsers.
Definitely doesn't work with Opera or IE.
>>
>>54621554
My professors were always butthurt about pasted code, fir them it was a tricky way to bloat the report when student had no clue what to write.

Short code review, however, were necessary so i simply screecapped chosen, interesting code parts right from ide, cutting the unnecessary edges ofc.
>>
>>54620837
% has higher precedence dummass.
>>
File: asdf.jpg (30 KB, 518x253) Image search: [Google]
asdf.jpg
30 KB, 518x253
>>54622240
Is the % at the end fucked or did I fuck up when I translated the equation?
>>
>>54622240
There are like 1000 moduloes so I guess I'll be extra nice and point the right one out.
Write
int weekday = (date + ( (26 * (month + 1)) / 10)  + (year % 100) + ((year % 100) / 4) + ((year / 100) / 4) + (5 * (year / 100))) % 7;
because your outermist parenthesising was utterly unnecessary and because otherwise the %7 only applies to (5 * year / 100) (yet another unnecessary parenthesising) and the overall value is thus not restricted to [0;6].
>>
text based game in Go. Is this a bad idea?
>>
Hi, I'm trying to make a simple method that will ask the user for a number between 1 and 100. The method is supposed to keep asking until an appropriate number is entered. This is what I got so far.

    public static int enterGrade (){
boolean x = true;
Scanner integ = new Scanner(System.in);
while (x){
System.out.println("Please enter an integer number between 1 and 100");
int num = integ.nextInt();
integ.close();
if (num>0 && num<=100){
x = false;
}
}
return num;
}


Anyone care to help?
>>
>>54618174
Because it's been a /dpt/ meme for more than a month.
That doesn't make it any less meme though.
>>
>>54622342
>outermist parenthesising was utterly unnecessary and because otherwise the %7 only applies to (5 * year / 100)
Thanks. The book I'm using now has been a lot more solid than the other books I tried to use at first but there's still a lot of stuff that I'm still not solid with in terms of practices and there's not a lot of support on that end from the book.

Any kind of guideline I can google search for?
>>
>>54622502
for operator precedence there's this

https://docs.oracle.com/javase/tutorial/java/nutsandbolts/operators.html
>>
>>54622427
put integ.close() after the loop
>>
>>54614329
>'myVSOpenTKApplication.vshost.exe' (CLR v4.0.30319: myVSOpenTKApplication.vshost.exe): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_32\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll'. Cannot find or open the PDB file.
>elements not being displayed on my home system that show up fine on the lab computers
what exactly is going on and how do i fix it? i have .net v4 installed of course
>>
>>54622427
>Java
May as kill yourself now rather than later.
>>
>>54622533
Much appreciated.
>>
>>54614329
who else is C++ here ?
What should I refer to c++11 or c++14 ?

I am trying to use it with OpenCV and tracking big boobs from public CCTV cams
>>
>>54622427
This is how I did it.

import java.util.Scanner;

public class NumberGuess {
public static void main(String[] args){
Scanner in = new Scanner(System.in);
int randnum = (int)(Math.random()*100+1);
int guess;

System.out.println("Which number do you think it is?");
System.out.println(randnum);
guess = in.nextInt();
for(int i=0; i<=99; i++){
if(guess>randnum){
System.out.println("Your number is too high!");
guess = in.nextInt();
}
else if(guess<randnum){
System.out.println("Your number is too low!");
guess = in.nextInt();
}
else if(guess==randnum){
i=99;
System.out.println("You have correctly guessed the number.");
}
}
}
}
>>
>>54622598
>I am trying to use it with OpenCV and tracking big boobs from public CCTV cams
top kek

well that's creative
>>
Dubs decides the trivial program I write
>>
>>54622568
>>54622609
Thanks for input
>>
>>54622656
something related to anime
>>
>>54622656
NSA Spyware, written in HTML.
>>
>>54622700
Fuck off
>>
>>54622704
no
>>
>>54622615
no, it was a joke, im trying to do some work but cant configure it right with my BUBUNTU ;^) linux/gnu machine
>>
>>54622656

Write a program to check dubs.
>>
>>54622844
checked
>>
File: 1449012910083.gif (273 KB, 320x240) Image search: [Google]
1449012910083.gif
273 KB, 320x240
>>54622844
>>
>>54622844
 
#include <stdio.h>
#define POST_BASE 10

int main()
{
int dubs, units, tens;

printf("Please input your post number : ");
scanf("%d", &dubs);
units = dubs % POST_BASE;//extract post numbers
dubs = dubs / POST_BASE;
tens = dubs % POST_BASE;

if(tens == units)
{
printf("DUBS!!!\n");
}
else
{
printf("No dubs\n");
}
return 0;
}
>>
>>54622888
TRIPS
>>
>>54622844
if postnumber(-1) == postnumber(-2)
print "dubs"
else
print "no dubs"
>>
>>54622844
int check_dubs ( const long post_number )
{
return !( ( post_number % 100 ) % 11 );
}

Returns 1 my friend
>>
File: dsp_chip.jpg (147 KB, 500x337) Image search: [Google]
dsp_chip.jpg
147 KB, 500x337
Im trying to better understand pointers, and even more mind boggling, structs, in C of course. Im going to be using some embedded hardware later on and I need to fully understand these concepts in order to utilize them better. Can someone give me some good books or coding challenges that involve using these?

pic sort of related, I intend to do some DSP work.
>>
>>54623324
There's really not much to understand about either.
>>
>>54623324
Oh I forgot to mention, I have a very good grasp on a few different assembly instruction sets. But when I go higher into upper level programming, I get lost.

>>54623334
I dont understand what a struct is at all tho.
>>
File: programming powerlevels.jpg (473 KB, 1400x1341) Image search: [Google]
programming powerlevels.jpg
473 KB, 1400x1341
what's a good scheme ide?
>>
>>54623357
>I dont understand what a struct is at all tho.
It's just a composite type.

Lets say you want to represent a coordinate in 2D space. That requires an x coordinate and an y coordinate, right?

A struct allow you to group together variables that logically belong together, so you could do something like this:
struct point {
int x;
int y;
};


Now you can pass a struct point around instead of having to pass x and y separately.
>>
>>54623357
It's just putting different bits of data together. There's no analogue in assembly, you just read and write at offsets - structs take care of this for you.
>>
File: 1463512028569.gif (588 KB, 360x480) Image search: [Google]
1463512028569.gif
588 KB, 360x480
give me you thoughts on JavaFX
>>
>>54623357
>I have a very good grasp on a few different assembly instruction sets.
Pointer dereferencing is basically LEA instructions (load effective address)
>>
>>54623413
your*
>>
>>54623403
>>54623412
Ok, but I need some example programs where they use this effectively.

>>54623436
Why isnt this sort of stuff written anywhere on normal programming guides? as an EE, programming always feels like it is missing a lot of documentation. When I spec out a part, I get the spec sheet, I then know everything about that part.
>>
>>54623413
Retarded as fuck.
>>
>>54623476
Just do some C programming. It should be immediately obvious when you need a struct.
>>
File: 1444868083834.png (119 KB, 960x826) Image search: [Google]
1444868083834.png
119 KB, 960x826
>>54614381
no
>>
>>54623476
>I need some example programs where they use this effectively.

Literally everywhere. Most data takes the form of some composite 'object' rather than a single field.
>>
>>54622598
consult the documentation
>>
>>54623476
>Ok, but I need some example programs where they use this effectively.
Most C programs uses structs

>Why isnt this sort of stuff written anywhere on normal programming guides?
Because people generally don't know assembly from before, usually it's the other way around, you tinker with assembly after learning C.
>>
>>54623496
But it isnt. I would just use an array. At least thats what I feel is appropriate.
>>
>>54623533
If you have many of the same type (strictly speaking, size and alignment), sure. Structs are heterogeneous.
>>
>>54623533
Arrays and structs are not the same thing.

Yes, struct members are aligned continously in memory, but you can also have arrays of structs.
>>
>>54623552
But if you don't have all the same type don't you fun into packing issues and you would be better off using arrays?
>>
>>54623562
>>54623552
What about malloc and calloc? I also never understood how to use these. Keep in mind I will be doing embedded work so keeping the memory utilized is a propriety.
>>
>>54623580
What?
>>
File: racket fun.png (5 KB, 348x259) Image search: [Google]
racket fun.png
5 KB, 348x259
they told me i could be anything i wanted

so i became comfy
>>
>>54623591
Heap allocation as opposed to stack allocation. The stack is faster but much more restrictive in what you can do. malloc and calloc are practically the same except calloc initializes the memory to zeroes.
>>
>>54623580
if you have a struct that is a float and a char, doesn't an array of it take up the same space as 2 floats? Wouldn't you be better off using an array of floats and an array of chars?
>>
>>54623621
sorry meant for
>>54623592
Thread replies: 255
Thread images: 38

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

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.