[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: 314
Thread images: 31

File: daily programming thread2.webm (2MB, 600x338px) Image search: [Google]
daily programming thread2.webm
2MB, 600x338px
old thread: >>52566734

What are you working on, /g/?
>>
First for nimfriends
>>
In C, how many levels of indirection is too much?
Note that you will be graded and judged based on your answer, so choose wisely.
>>
>>52572109
You should never even use pointers ideally.
>>
>>52572064
10 posts early, again
great job
>>
File: 1426680121535.png (9KB, 647x53px)
1426680121535.png
9KB, 647x53px
I'm designing the instruction encoding for my VM, it is RISC based with fixed instruction size which also must be word aligned (32 bit).
The problem is that I have 2 bytes wasted, I could fill one of them with a flags byte, but what should I do with the other?

Beware that I'm not a computer scientist, I've never taken any computer architecture class and I'm doing this out of my own interest.

>>52572109
2
>>
>>52572109
i like to abuse structs and treat them like objects complete with vtables, so I can easily reach 6+ levels of indirection.
More if I'm creating arrays of arrays of structs.
>>
>>52572109
Even 0 levels is too much in C because using C is too much and thus only not using C is less than too much.
>>
>>52572125
Add a barrel shifter (to help construct immediates). Bitches love barrel shifters.
>>
>>52572122
Your life must be pretty difficult if you get bothered by things as small as this.
>>
>>52572064
Fuck off earlyposting animefag. You're not welcome here.
>>
>>52572208
No one is welcome here, ideally.
>>
>>52572109
>In C, how many levels of indirection is too much?

8 star or you aren't even using C to its full potential.
>>
>>52572109
there is no such thing as too much indirection
>>
>>52572064
Threadly reminder you don't need anything other than C and Lua.
>>
>>52572275
If your time is worthless*
>>
>>52572275
Threadly reminder you don't need anything other than ocaml. Why break your neck with C, and your soul with Lua, when you could just use ocaml?
>>
>>52572208
>>52572217
That means we'll need to join the Contributor Convenant (http://contributor-covenant.org/) because now I don't feel safe and accepted to post here anymore.
>>
>>52572109

In theory, there is no such thing. Some tasks call for tree data structures, which allow for arbitrary amounts of indirection.

If you're referring to how many stars should be too much for a pointer type, three star is the maximum I've ever needed. This was for a program to output both an array of strings (taken in as a char***) and return a number of arguments. The results of this function would be fed into argvp.
>>
>>52572380
Will this guy ever get over himself?
>>
>>52572365
I feel violated by you even linking that.
>>
so if this was my code in bash
read -p "value: " val1
echo $val1
exit

is whatever I type as val1 stored anywhere? i.e in bash history if so how would I go about stopping this?
>>
File: 1429604510048.png (31KB, 1035x150px) Image search: [Google]
1429604510048.png
31KB, 1035x150px
>>52572125
Okay, how's this?
>>
>>52572275
I endorse this, because I like small things.
<3
>>
>>52572390

Who?
>>
>>52572365
>http://contributor-covenant.org/
ree
>>
Reminder that if you can't print out a diamond, you obviously shouldn't be a programmer.
>>
>>52572414
What if it was
[cond] [opcode] [flags] [reg1] [reg2 / const]?

That way every single instruction can be executed (or not) based on the result of whatever comparison instruction last set the conditional state (eq, ne, gt, lt, gte, lte), instead of just jumps.
>>
What are you guys gonna do today (non programming related things)
>>
>>52572498
Fap to anime
>>
>>52572408
No.
>>
>>52572365

Anon, it is literally not possible to punch someone through the Internet, despite how much many of us wish it was. If you feel unsafe here, you need therapy.

>>52572125

Consider looking at other RISC architectures for how they organize their opcode spaces before designing your own. I recommend looking at MIPS.
>>
>>52572491
Interesting, can you give a situation where that would be useful/convenient/more efficient as opposed to jumps?
>>
>>52572488
i know how I would do it, i'm just too lazy to write it out and debug it.
does that count?
>>
I finished the python course in code academy and I've taken a university course in C++
what kind of program should I make
>>
>>52572498
>
>>
File: small-GnashGnu.png (33KB, 180x188px) Image search: [Google]
small-GnashGnu.png
33KB, 180x188px
>>52572275
You mean C and Scheme.
>>
>>52572531
Print out a diamond.
>>
>>52572522
>Anon, it is literally not possible to punch someone through the Internet

With my invention it will be possible to shoot people over the internet. All you need is an arduino, stepper motor, some string, and a Winchester Model 100 or comparable semi-automatic rifle.
>>
>>52572525
I don't think so, man. I'm going to have to revoke your certification.
>>
>>52572560

May I recommend a SBC that is actually capable of connecting to the internet without an extension? Arduino isn't really for net connected shit.
>>
>>52572523
ARM.
toupper:
@ skip prolog
cmp r0, 'a'
cmpge r0, 'z'
subslt r0, 32 @ 'a'-'A'
>>
>>52572554
I'd like something that at least seems neat.
>>
>>52572609
Cool, will consider it.
>>

using namespace std;

struct Heap {
string name;
Heap *left = nullptr;
Heap *right = nullptr;
};


Heap *heapFromArray(string *input, int length);


Heap *heapFromArray(string *input, int length) {

Heap *dynArray;
dynArray = new Heap[length];

for (int i = 0; i<length; i++){
dynArray[i].name = input[i];

//WHAT THE FUCK GOES HERE??//
dynArray->left= &dynArray; //this is obv wrong
dynArray->right = &dynArray; //this too

}

for (int i = 0; i<length; i++){
cout << dynArray[i].name <<endl;
}

return dynArray;

}

int main() {
// input for testing
string maBands[] = {"Led Zeppelin", "The Beatles", "Pink Floyd", "Queen", "Metallica","ACDC", "Rolling Stones", "Guns N' Roses", "Nirvana", "The Who", "Linkin Park", "Green Day", "Black Sabbath", "RHCP"};
int numBands = 14;

// creat heap
Heap *heapOfBands = heapFromArray(maBands, numBands);


So I'm picking up C++, the code is simple enough to follow. I'm organizing the string in a dynamic array of type struct. How do i go about linking the left and right pointers to correct location in the array?
>>
>>52572602

You can recommend whatever you'd like. I've actually spent less time with Arduino and similar devices than I'd like to admit.

I should probably start doing some experimenting with them.
>>
>>52572658

I've used an Arduino for only one project -- a simple binary counter. I'm unsure if what the fuck to make with it. I don't have much in terms of parts except for the starter kit with an Arduino uno.
>>
>>52572653
I don't understand what you're trying to do.
>>
>>52572707

to be honest, I just like software better. I don't dislike hardware, but.. you know.. I just live and breathe software.

no homo.

>inb4 smug EE majors start shitposting
>>
>>52572762

Kinda same, although I do like writing software that interfaces with hardware. Low level driver code actually seems like a fun job to me.
>>
File: regards sad from.png (12KB, 640x560px) Image search: [Google]
regards sad from.png
12KB, 640x560px
>>52572791

I don't see myself doing that, but I wouldn't mind if it paid the bills. If I got taken in as some hardware wizards protege, I'd probably learn to love it.

>tfw no greybeard to teach me computer magic
>>
that was fun

http://pastebin.com/8J2CdamN
>>
>>52572753
Im sorting the string maBands[] into a heap (binary tree)
dynArray[i].name = input[i]; //saves each string into struct


Now I need to link

Heap *left = nullptr;
Heap *right = nullptr;

Now I want to point these to the correct structure in the array, but I'm stuck there.

Left should point to 2*i+1 and Right should point to 2*i+2. ( i is the current array index, ex. dynArray[i])
>>
File: D_Programming_Language_logo.png (232KB, 1000x758px) Image search: [Google]
D_Programming_Language_logo.png
232KB, 1000x758px
potential new D logo lads
https://i.imgur.com/r9WPvEX.png

current one is the image
>>
>>52572920
Wow, it's fucking nothing.
>>
>>52572879

Looks like your implementation of loops isn't quite right. The only reason it sticks right out at me is because I made the same mistake when I first wrote my BF interpreter. You need to handle nested loops.
>>
>>52572933
>gets rid of all of the weird shitty gloss / shine effects
I like it personally
>>
There should be a name for that pivotal moment when you discover the power of abstraction and code reuse.

It's repeated over and over in beginner textbooks, but you don't really get it until later.
>>
>>52572920
Really liking the bottom left
>>
>>52572884
>Left should point to 2*i+1 and Right should point to 2*i+2.
Well if that's what you need to do then do that. What's your issue?
>>
>>52572509
What anime?
>>
>>52572884
dynArray[i].name = input[i];
dynArray[i].left= &dynArray[2*i+1];
dynArray[i].right = &dynArray[2*i+2];
>>
>>52572625
Print out a diamond made of your name.
>>
>>52572939
what do you mean? Like where if you put in a ] and not an [ having it throw an error rather than breaking? Or just using them in general like

for (char c : input) {
for (int i = 0; i < accepted.length; i++) {
if (c == accepted[i]) {
chars.add(c);
break;
}
}
}
>>
prove to me you aren't a charlatan
>>
>>52573057

It looks like when you hit a [ or ], you start searching to find the matching one, but you aren't keeping track of other ones you pass over..

think of it like this:

[....[..]...]


If you are at the last position there, and you need to loop back to the first, you can't simply search the string backwards until you hit the '[' char, because that will drop you into the loop inside the one you're trying to get to the head of.

Keep a counter where, say, '[' increases it, and ']' decreases it, then break when it's equal to zero. This will place the PC at the appropriate instruction.
>>
>>52573057
He means you aren't handling nested loops. you are expecting only one level of looping. You should be using a stack. If you've done a reverse polish calculator the implementation should be pretty similar.
>>
>>52573135
>You should be using a stack.

A counter has the same effect. When I initially wrote mine, I used a stack, but then I compacted the code and just used a counter.
>>
>>52573150
>he didn't write a recursive decent parser
>backtracking
lol
>>
>>52573214
>all that shit by you
>for fucking brainfuck

no
>>
>>52573227
Shit's probably more compact then one that's not.
>>
File: Walruse.png (27KB, 155x145px) Image search: [Google]
Walruse.png
27KB, 155x145px
>>52572064
I have to create a program that simulates carbon emissions.
>>
>>52573135
>>52573099
oh, yeah that's an easy fix
just number your brackets as you come across them and then go to the most recent one in the code

like

[.....[...].............]
1....2..<2.........<1(or whatever the previous one is)

yeah I caught the skipping the [] when it is zero right after I posted it, I just didn't read the rules all the way through the first time
>>
>>52573275
>oh, yeah that's an easy fix

It is, it's just an easy mistake to make. Like I said, I noticed it right away having made it myself.
>>
File: Window.png (401KB, 742x1001px) Image search: [Google]
Window.png
401KB, 742x1001px
What is the best way to scale an image along with the window in OpenGL without changing the aspect ratio?
For instance, I have a quad that covers the entire screen corner-to-corner, and I have an image drawn to it, so it's kind of like a shitty image viewer.
But when I change the window size the image does not scale right, how can I make this better?
>>
File: Window.png (401KB, 744x1003px) Image search: [Google]
Window.png
401KB, 744x1003px
Did my post get deleted? I don't see it anymore.
Reposting just in case.

What is the best way to scale an image along with the window in OpenGL without changing the aspect ratio?
For instance, I have a quad that covers the entire screen corner-to-corner, and I have an image drawn to it, so it's kind of like a shitty image viewer.
But when I change the window size the image does not scale right, how can I make this better?
>>
>>52573452

scale one direction, then use the ratio of width/height to scale the other.
>>
>>52573297
>>52573452
Whoops.
>>
>tfw getting this error

public Class Foo{
Bar bar = new Bar("dicks");
bar.run();
}

Class Bar{
String str;
public Bar(String str) {
this.str = str;
}
public void run()
{
System.out.println("output: " + str);
}
}

output
Output: null


Obviously I'm not programming something this simple but this is in essence what's happening. What's worse is that when I have a breakpoint at public Bar(String str), it says it's null there too.
How the fuck is that even possible? I haven't changed any of my code and it used to work but now it doesn't.
>>
>>52573460
Should I scale with the shader or the viewPort?
I was thinking of doing bicubic interpolation.
What would this look like in C?
>>
File: dfdisk_view.png (3KB, 640x300px) Image search: [Google]
dfdisk_view.png
3KB, 640x300px
It now properly shows (most) forms of partition on a disk now.
>>
>>52573495

Doesn't openGL already have something to draw scaled images?
>>
>>52573460
hmm not sure I agree with this

I think you can directly scale your shit in opengl, what i would do is a vertical and horizontal check of your window space, get the one your image would collide with first after growing, and find the ratio of that width to the width of your image. Then scale your image up that ratio.

Might be wrong about the scale thing but iirc there was an Image type and you can use image.draw(y,z,5.1f,[scale factor here])
>>
>>52573510
I don't think so.
>>
>>52573297
float scale = wwin < hwin ? wwin / hwin : hwin / wwin;

float wscaled = wimg * scale;
float hscaled = himg * scale;
float x = wwin / 2 - wscaled / 2;
float y = hwin / 2 - hscaled / 2;

/* make quad with x, y, wscaled, hscaled */


Something like this?
>>
>>52573518
ok maybe I was wrong actually

you can do it with slick2d(definitely) and jwjgl (it's more complicated). For jwjgl you draw an image on something as a texture, so you change the dimensions of the polygon you're drawing the image on
>>
File: Screenshot 2016-01-22 22.47.20.png (20KB, 978x172px) Image search: [Google]
Screenshot 2016-01-22 22.47.20.png
20KB, 978x172px
Like actually how the fuck is this possible
The constructor just... isn't getting the value.
>>
>>52573502
Can anybody explain to me why this is return 0??

uint32_t disk_usage = (part_size / disk_sizemb) * 100;


I've tried using ceil as well to no avail..
>>
>>52573660
NodeMaster isn't initialized
>>
>>52573679
What do you mean?
JobHandle jobHandle;
NodeMaster nodeMaster;

public PrimaryClient(NodeMaster nodeMaster, JobHandle jobHandle) {
this.jobHandle = jobHandle;
this.nodeMaster = nodeMaster;
}
>>
>>52573692
  NodeMaster nodeMaster = new nodeMaster(Params)
>>
>>52573696
NodeMaster*
>>
>>52573696
But anon. The constructor is taking an instance of NodeMaster that was properly instantiated (see the top half of the screenshot, it's not null), but when it's passed to the constructor it becomes null.
>>
>>52573710
NodeMaster nodeMaster


This isn't proper initialization. nodeMaster is null here.
>>
>>52573719
Yes. Nodemaster is null there.
But look at where the breakpoint is. The value caught with the constructor is null. It shouldn't be. It should be whatever value was passed to it.
>>
File: life_puffer2s.webm (689KB, 1920x1080px) Image search: [Google]
life_puffer2s.webm
689KB, 1920x1080px
I did Game of Life running in a console, board wraps at top and sides. I wanted to learn bit operations so the board is an array of integers and each bit represents a cell.
>>
>>52573660
Is jobHandle null too?
>>
>>52573746
Yes. I have no idea why.
>>
I want to get started writing a program, not all the way a game but just a program. I want to make a helper program that can run in the background or sit in the system tray and wait for certain key presses to be done while the game is open, then execute some code. Would it be possible to do this and make the program be more than just a command line? Lets say have a user interface with buttons and whatnot? I would like to do it in C++ if possible. Any ideas?

Image is what my idea is what my kinda idea is like (not exactly this, but of the same topic, an offline guide program or macro holder type program with buttons and shit)
>>
>>52572365
>now I don't feel safe and accepted to post here anymore.
https://www.youtube.com/watch?v=L9_jp2Uwqts
>>
>>52572854

>tfw a few of my professors are literal greybeard wizards.
>One of them wrote software that is part of the GNU project.
>The other has memorized network stacks to insane levels of detail.
>At least two or thee professors have worked with the US government in the past. One for the DoD, one for Lawrence Livermore National Laboratory, and one I think mentioned working with the NSA.
>>
>>52573756

>I want to make a helper program that can run in the background or sit in the system tray and wait for certain key presses to be done while the game is open

What OS, Windows?
https://msdn.microsoft.com/en-us/library/windows/desktop/ms646301%28v=vs.85%29.aspx

GetKeyState is used to determine whether or not certain inputs are being used or not. If you want some example code, I've actually used it in a gem for MRuby:
https://github.com/expeditiousRubyist/mruby-autoclick/blob/master/src/mruby-autoclick.c

As for giving it a GUI, that is perfectly possible, although if the purpose of the program is to run in the background, why not make it a CLI program?
>>
>>52573666
Stick to Python, please.
>>
File: tiles.png (651KB, 1148x748px) Image search: [Google]
tiles.png
651KB, 1148x748px
changed how the catalog looks a bit
>>
>>52573865
to add on to this I know you can also automate literally every macro amd mouse movement imaginable using java.awt.robot, I bet c++ would have something similar
>>
>>52573493
>that indentation
McFucking kill yourself
>>
>>52573935
>expecting indentation to be good when it's pseudo-code typed directly into 4chan which has absolutely no formatting tools
?
>>
OOP is pretty comfy desu.
unsigned search_subgrid(grid_t *pattern, grid_t *subpattern, point_t from)
{
unsigned matches = 0;
unsigned k, l;
for (k = 0; k < subpattern->size.x; k++)
{
for (l = 0; l < subpattern->size.y; l++)
{
if (pattern->grid[from.x + k][from.y + l] == subpattern->grid[k][l])
matches++;
}
}
return matches;
}
>>
>>52573777
But were they ever highly respected trip fags?
>>
>>52573879
Is this the one that starts with a 'V'? Got a link to the source?
>>
>>52573777
>One of them wrote software that is part of the GNU project.

Is that supposed to be impressive?
>>
>>52573955
https://github.com/vaccineapp/vaccine
>>
File: 1450568178435.jpg (835KB, 986x1000px) Image search: [Google]
1450568178435.jpg
835KB, 986x1000px
rate my rust program /dpt/
use std::io;

fn main() {
print_info();

let mut choice = String::new();
io::stdin().read_line(&mut choice)
.ok()
.expect("Failed to read line");
let choice: u8 = choice.trim().parse()
.expect("Failed to convert to number");

println!("Enter temperature to be converted:");
let mut temp = String::new();
io::stdin().read_line(&mut temp)
.ok()
.expect("Failed to read line");
let temp: f64 = temp.trim().parse()
.expect("Failed to convert to number");

println!("{:.2}", match choice {
1 /*f->c*/=> (temp - 32.0) * (5.0 / 9.0),
2 /*c->f*/=> temp * (9.0 / 5.0) + 32.0,
3 /*k->f*/=> (temp - 32.0) / 1.8 + 273.15,
4 /*f->k*/=> (temp - 273.15) * 1.8 + 32.0,
5 /*k->c*/=> temp - 273.15,
6 /*c->k*/=> temp + 273.15,
_ => { 0.0}
});
}
>>
>>52573974
10/10

Stop doing shitty K&R exercises though
>>
>>52573993
the k&r exercise didn't have kelvin! :^)
i am doing easy problems because i am both a beginner to programming and rust
>>
>>52573974
Don't fall for the rust meme anon, just be smart and do it in C
>>
>>52574015
>the future of systems programming is a meme
>>
>>52573972
>https://github.com/vaccineapp/vaccine
Thanks
>>
>>52573974
Are there really people who hate C syntax so much they want to be different for different's sake?

There's a reason most languages look like C, the syntax is great and easy for a programmer to understand, even if they don't know C.
>>
>>52573493
>>52573660
Anons, does anyone know what might be causing this?
I just added another constructor, an integer, and it went through just fine.
>>
>>52574036
the syntax is pretty much exactly like c. certain things are different because of weird variable bindings and type inference
>>
>>52574023
Just like and D and C++ were the future right anon?
>>
>>52574073
I'd say C++ cemented itself pretty well, being that it's the choice for all non-embedded performance critical code
>>
Added an open in browser button
>>
>>52573892

There is nothing in the C++ standard library for automating mouse and keyboard. However, depending on the platform, there will be system calls for doing exactly that. On Windows, the function is called SendInput(). On Linux... I would look into how the xdotool program works... or just invoke it directly via a bash script.
>>
>>52573865
I like the idea of a program to be opened up and have settings changed at a glance, not something just I would use, but potentally others. Also wanted to includ some other tools in it. How hard would implementing a GUI be? Any special libraries to reccomend?
>>
File: Can't wake up.png (241KB, 1716x937px) Image search: [Google]
Can't wake up.png
241KB, 1716x937px
>trying to add overflow detection
>signed type addition/subtraction has a carry-out in its addition and subtraction
>can't access it
>have to use retarded hacks unless I want to write the code for adding/subtracting myself
>change my variables to signals so that I could watch them more easily in the simulator
>addition spontaneously stops working

Why can VHDL be so retarded sometimes
>>
>>52572118
>never use pointers
>in C
>>
>>52574145
Sup newbie
>>
>>52572118
>what is performance
>>
>>52574168
Why use C if you're never gonna use pointers?
>>
>>52574182
I forgot that was the only benefit of using C
>>
>>52574135

Qt can be used for GUI stuff on any platform, although it's a bit of a heavyweight. Other options are GTK+, WxWidgets, and FLTK. Or you could just use the OS' native shit if you're a masochist (or need the program to be tiny as shit).
>>
>>52574195
It's one of the bigger ones
>>
>>52574177
If you need to pass a pointer you've already lost out somewhere
>>
I don't know desu senpai
>>
>>52574195

Avoidance of pointers in C is neither idiomatic, nor very performant, and it heavily restricts what one is actually capable of doing, now that all string and array operations are permanently off the table.
>>
>>52574252
arrays aren't pointers so you can use them
idk if passing an array to a function counts because of the implicit pointer conversion
>>
>>52574196
Yea iv been feeling like im not doing much with computer science evne though its my major, and my resume is pretty lacking, so I feel as though i Should stop wasting my time and make stuff that i need or that others would like! Thank you for showing me this. Getting other foreground windows and minimizing to the system tray would all be done seperatly with the windows API correcT?
>>
>>52574252
Valuable C work doesn't contain strings. Don't need pointers to access arrays.
>>
>fixed the weird issue with a weird solution (for some reason the variables couldn't share the same variable name, even though that shouldn't have been a problem
>Now, the constructor is hit but the inside of the constructor is never executed
what the fuck is going on
>>
>>52574301
>PrimaryClient
>new ClientJobManager

Are you sure this isn't the problem?
>>
>>52574224

Anon, any data type bigger than a register should always be passed by pointer to avoid unnecessary copying of data structures. If you don't want your structure to be mutable, make the pointer const.

>>52574264

A function with the signature
void foo(int ary[], size_t len);


Is 100% identical to a function with the signature
void foo(int *ary, size_t len);


Arrays are nothing but syntactic sugar for a block of contiguous memory on the stack. Any function which accepts one as an argument is always passing one by pointer without exception. Furthermore, an array subscript is merely syntactic sugar for a pointer dereference. ary[i] == *(ary + i).

All programs are made of pointers without exception. If your program uses memory, it uses pointers. High level languages tend to abstract this away from the programmer. Consequently, many of these high level languages are written in C. C does not abstract these away from the programmer; it expects the programmer to know and understand what pointers are, what memory is, and how to use it.

>>52574296

Qt may be able to do both of those things. Not sure. But honestly I wouldn't mix Qt and Win32 API GUI stuff. If one's going to dip down that low, why the hell not go all the way?
>>
>>52574301
>Declaring things under the constructor

*vomits*
>>
>>52574318
I just had that breakpointed because for some reason it was getting passed null values, which I figured I had remedied. I don't see why instantiating another class would result in the constructor being skipped entirely.
>>
>>52574320
I don't normally do that, anon. my code structure is really fucked up right now because I'm attempting to figure out what the fuck is going on, the kinds of issues I'm running into here are counterintuitive as all getout.
>>
>>52574300

>Valuable C work doesn't contain strings
All non-dead programs do I/O. Nearly all I/O involves strings. Most valuable C work does involve string manipulation, among other things.

Accessing arrays does not necessarily require explicit usage of pointers, but any function which manipulates them does. Moreover, without the use of pointers, one is limited to static, stack-allocated arrays. These are good for small buffers, but not good for large amounts of memory, or when one needs to resize memory at runtime (i.e. a vector).
>>
>>52574264
>arrays aren't pointers
>idk
these are the people arguing against C? jesus
>>
>>52574301
I'm not sure what the problem here is. The constructor isn't being used so you never hit a breakpoint in it.
>>
>>52574319
Can QT do all of the minimization to the tray and still have hotkeys that can work outside of the program being the current windo?
>>
>>52574319
>>52574384
I'm not sure what >>52572118 classifies as using pointers. Is printf("Hello world"); allowed? Is passing an array to a function allowed, as long as you don't write a * ?
>>
function toTimestamp(value) {
let parts = value.split(':').reverse();
let seconds = parseFloat(parts[0]) || 0;
let minutes = parseFloat(parts[1]) || 0;
let hours = parseFloat(parts[2]) || 0;

return Math.floor(
seconds * 1000 +
minutes * 60000 +
hours * 3600000
);
}

function fromTimestamp(value) {
let hours = Math.floor(value / 3600000);
let minutes = Math.floor(value / 60000) % 60;
let seconds = (value / 1000) % 1000;

console.log(hours, minutes, seconds);
}


> fromTimestamp(toTimestamp('1:23:52.4532653'))
1 23 32.45300000000043


Why am I getting a value of 32 for seconds instead of 52?
>>
>>52574417
>let seconds = (value / 1000) % 1000;
>% 1000

there's only 60 seconds, so modulo 60.
>>
>>52574409
No, you sick fuck.
>>
>>52574409

>Is printf("Hello world"); allowed?

>int printf(const char *format, ...);
>const char* format
>const char*
>*

Not allowed. Even a string literal is a pointer to a block of memory in .rodata or .data
>>
>>52574482
Thanks, I thought I was still working with milliseconds for some reason.
>>
>>52574393
The constructor is being used though.
>>
>>52573666
Integer division?
>>
>>52573666
well what are the values of part_size and disk_sizemb?
>>
Stop replying to the the anti-pointer troll.
>>
>>52573879
Please don't upscale images.
Keep the frame the same size but keep the images at original scale please.
Not like I'm ever going to use this GTK3 shit anyway.
>>
>>52574490
Obviously the topic was writing pointers yourself and not "using code that uses a pointer"
>>
>>52574607
Stop trying to avoid pointers, you dumb shit.
>>
>>52574631
Your code gets worse with each level of indirection.
>>
>>52574607
This is backpedaling. Code that uses a pointer only further shows why pointers are useful in the first place.
>>
>>52573974
A bit rusty.
>>
>>52574640
I'm pretty sure you're just not good enough to understand more than 1 level of indirection, so you actually believe this
>>
>>52574640
You can't implement most data structures without using pointers that go as deep as your input will allow.
>>
>>52574641
It was the original argument. You can be sure that if the code was made better they would have avoided pointers.

>>52574650
http://c2.com/cgi/wiki?ThreeStarProgrammer Found your bio kid
>>
>>52574045
>the syntax is pretty much exactly like c
>
println!("{:.2}", match choice {
1 /*f->c*/=> (temp - 32.0) * (5.0 / 9.0),
2 /*c->f*/=> temp * (9.0 / 5.0) + 32.0,
3 /*k->f*/=> (temp - 32.0) / 1.8 + 273.15,
4 /*f->k*/=> (temp - 273.15) * 1.8 + 32.0,
5 /*k->c*/=> temp - 273.15,
6 /*c->k*/=> temp + 273.15,
_ => { 0.0}
});

Okay m8.
>>
I've seen some shit yesterday.
I was helping a friend of mine reading homeworks of master's degree students in cryptography. The hw was to implement data encryption standard(DES). There were some good implementations, some didn't work, some forgot some stuff etc. But everyone did the s-boxes and permutation tables the same way. They put the values in an array or something then used them in s and p-boxes.
Except this one fuck who wrote all of them by hand. Like (pardon my half assed psdcode)
if v[0] = 0 then v_after_p[0] = 3
if v[0] = 1 then v_after_p[0] = 9
etc.
The usual implementation took ~300 lines. This fuck wrote 4K lines. The sad thing is, it doesn't give the correct encryption. The sadder thing is, we later found out that he was a cs major.
>>
>>52574657
>You can be sure that if the code was made better they would have avoided pointers.
If you avoided pointers, your code would not have the functionality you desire in most cases.
>>
>>52574658
float value;
switch (choice) {
case 1:
value = (temp - 32.0) * (5.0 / 9.0);
break;
...
default:
value = 0.0;
}
printf("%.2f", value);


The biggest difference is that switch isn't an expression in C.
>>
>>52574657

How would you print a string without knowing where the string is in memory?
>>
>>52574688
You already have the location in memory by name without your own *
>>
>>52572118
hay anon
unsigned i, j; /* 3D CUBE */ 
unsigned char ***ptr = malloc(sizeof(unsigned char **) * a);
for (i = 0; i < a; i++)
ptr[i] = malloc(sizeof(unsigned char *) * b);
for (i = 0; i < a; i++)
for (j = 0; j < b; j++)
ptr[i][j] = malloc(sizeof(unsigned char) * c);
>>
>>52574708
>not using a flat array

Enjoy your cache misses faggot.
>>
>>52574712
>wasting time looking for uninterrupted memory blocks
enjoy your performance, faggot
>>
>>52574699
What are you talking about? You HAVE to use * to store a string.
>>
>>52574708
>>52574712
>>52574715
>Not using a contiguous array of well designed structs
Enjoy your cache misses, performance and code clarity.
>>
>>52574720
No you don't. You can just view it as an array.
>>
>>52574699
that's how pointers work you dumbfuck, using * dereferences, so you don't want to write it when using printf

>>52574729
an array IS a pointer
>>
>>52574720
char str[64];
>>
>>52574736
You don't need to use *. Read the fucking thread, dipshit.
>>
>>52574715
>not allocating a large block at startup and using a custom memory manager

Pleb.
>>
>>52574740
I just said you're not even supposed to use * for printf you dumbfuck

Using [] is just syntactic sugar for *, and if you don't know so, you don't know C
>>
>>52574738
Doesn't that have different semantics than char *str? i.e., stack allocation vs heap allocation.
>>
>>52574749
The whole argument is that avoiding * makes your code better, which it does. No one calls an array a level of indirection.
>>
>>52574729
array[4] is literally *(array + 4)
stop being stupid
the only reason this exists is so you don't have to type
*(*(*(arr+a)+b)+c) instead of arr[a][b][c]
>>
>>52574754
>which it does
How so?

>No one calls an array a level of indirection
It's a standard form of storing contiguous information, off course no one's going to avoid using it or shittalk it.
>>
>>52574758
Yes and the point is once you've needed to type * your code is already going downhill. Not to mention ** and ***

>>52574760
Because it makes it harder to understand
>>
>>52574752
>stack allocation vs heap allocation.
That's pretty much the only difference.
When you reference a [] variable, it takes the pointer of it.
>>
>>52574764
>Because it makes it harder to understand
How so?
>>
>>52574764
>Yes and the point is once you've needed to type * your code is already going downhill. Not to mention ** and ***

A non-C programmer is telling C programmers how to write C.
why am i even replying
>>
>>52574770
Because you have to jump through indirection in your brain

>That's easy

Not the point
>>
>pointers are bad because I can't understand it
who let the girl coders in?
>>
>>52574776
Honestly if you can't keep track of 3 levels of indirection, a typical amount, you're a retard.
>>
>>52574776
>Because you have to jump through indirection in your brain
You have to use your brain for many programming-related things, 1-3 levels of indirection is comparatively simple if you understand addresses and memory
>>
>>52574784
Please don't advocate three star programming

See >>52574657
>>
This thread is getting feminine as fuck.
>>
Reminder that pointers are also good for creating data structures such as linked lists and also passing functions to other functions if needed
>>
>>52574766
char *foo = "Hello, world!";
char bar[] = "Hello, world!";

foo[0] = 'a'; /* works fine since foo is a copy */
bar[0] = 'a'; /* runtime error since bar is const */


I would say it's a pretty big semantic difference. You can't just exchange * for [] everywhere.
>>
>>52574792
Forcing yourself to jump hoops in order to avoid pointers where pointers are useful will make your code even messier. Pointers are only "hard to understand" because it's a new concept to you
>>
>>52574801
Shit, I mixed up the comments but you get the idea.
>>
>>52574785

People who don't understand addresses and memory should not do any programming of any sort.

>>52574798

Shhh... babby C programmer doesn't believe indirection is needed for anything. Abstract Syntax Trees for language interpreters? Those aren't real.
>>
>>52574798
But ultimately unnecessary

>>52574805
There are no hoops to be jumped when not using pointers. Pointers are hoops.

>>52574816
>Tripcode

Post discarded
>>
>>52574828
Really? You think implementing a linked list would be easier with an array rather than pointers?
>>
>>52574828
>There are no hoops to be jumped when not using pointers.
Alright then, explain how you would implement the following:
Linked list
Vector
Nodal trees
A game mechanic where you want to move towards the nearest type of entity who has a variable set to a certain value
>>
File: 8d9MxXY.png (646KB, 1200x1200px) Image search: [Google]
8d9MxXY.png
646KB, 1200x1200px
>>52574828
>>
>>52574850
>>52574855
Not doing your homework for you.
>>
>>52574863
You could have tried trolling harder, I'm sure there are some arguments against pointers somewhere, but you presented none
>>
>>52574828
Pointers are also fast (and necessary for systems programming languages to introduce to the programmer in order to all significant control over memory and performance)
However yes I disagree with "3 star programming", pointers should be kept to objects that aren't copied and to out-parameters if you can't just return a tuple.
>>
>>52574863
Good to hear you were baiting this whole time
>>
>>52574876
Calm down Ruby.
>>
>>52574905
I'm chip-8 guy you melt
>>
>>52574910
post the pretty girl pls :3
>>
>>52574910
Who?
>>
File: 1451683583776.gif (2MB, 400x600px)
1451683583776.gif
2MB, 400x600px
>>52574926
let's stop arguing about pointers lads
>>
>>52574938
I want to vomit every time I see a white woman
>>
File: 1437519264846.jpg (115KB, 640x960px) Image search: [Google]
1437519264846.jpg
115KB, 640x960px
>>52574926
>>
>>52574954
tfw no milkcow gf
>>
>>52574949
I want to vomit every time I see a 3D woman.
>>
>>52574949
Why so racist, bruh
>>
>>52574977
>Straight white male calling me a racist

:')
>>
>>52574938
>>52574954
hnnng ty
>>
File: 1451683513443.gif (2MB, 400x225px) Image search: [Google]
1451683513443.gif
2MB, 400x225px
>>52574991
Alright, weekend's here, going to really put effort into how I'm going to make a chip-8 zelda interesting with how restricting the architecture is. I suppose it's a decent enough challenge before moving on
>>
>>52574983
I'm a woman you dolt
>>
File: 1446961914142.jpg (35KB, 479x719px)
1446961914142.jpg
35KB, 479x719px
>>52575007
why dont you just become a respected tripfag?
>>
>>52575028
I haven't achieved nearly enough for my input to mean anything
>>
>>52575053
That's the wrong attitude anon

the idea of tripfagging is to do it even, nay especially, when literally fucking no one cares about your opinions
>>
>>52575022
i'm a a gril too, but only when i'm wearing a skirt :3
>>
>>52575175
boi pussy pls, i can teach you c
>>
File: fuck.png (98KB, 1160x1084px) Image search: [Google]
fuck.png
98KB, 1160x1084px
how do I get over writing shitty code as a beginner and not knowing how to make it less shitty? should I just leave it be and focus on results rather than the quality of code?
>>
>>52575175
>only when i'm wearing a skirt

how often is that?
>>
>>52575238
don't repeat yourself
>>
Just getting into webdevelopment and webservices, how the fuck do you change your home network from public to private in windows 8.1?

This really should not be very complicated yet all the three page tutorials describing how to lack the actual options described as required to this.q
>>
>>52575274
this is the programming thread, not web dev
>>
>>52575274
jesus christ
>>
>>52575238
To a point I think you shouldn't care how pretty your code is on the first go. I rather see something working than bunch of pretty/clever code that doesn't quite do anything useful yet.

In my opinion programming is iterative process, which to me means working over (refactoring) existing code base from time to time. When you are starting a project you will make mistakes, no matter how hard you think. Something will come up that you didn't anticipate and you can't adapt to it before hand, so you make due with what you can. You write your code the best way you know how at the moment fully acknowledging that you made at least couple dozen horrible mistakes and you'll be back some day fixing it either laughing at yourself for silly mistakes or cursing yourself for trying to be overly clever and not documenting the code.
>>
>>52575291

Yeah, but you see I have written an android app and a number of webservices that all hinge on this.
>>
>>52575291
Do you really feel like there's a difference? Like just because someone writes in PHP, Ruby, Python or JavaScript they aren't "programmers"?

I get that part of developing websites isn't necessary programming. Like designing page layouts or fiddling with CSS, but do you really feel like: "unless it's compiled, it ain't programming"?
>>
File: 1419224427969.png (47KB, 600x438px) Image search: [Google]
1419224427969.png
47KB, 600x438px
>>52574039
>>52573660
>tfw finally found out what was causing this
>tfw it was some DLL that had attached itself to my IDE
I thought I was LITERALLY going crazy
jesus christ
>>
>>52575407
>unless it's compiled, it ain't programming

All of the languages you mentioned have compiled implementations.
>>
>>52575438
For web thou?
>>
>>52575407
Nah, they're not programmers, but they're still coders
This is like getting mad that it's not right to call physical engineers chemical engineers, by the way. It doesn't make it any less of a valid job, you just literally aren't a programmer.
>>
File: 1375391643724.jpg (11KB, 251x242px) Image search: [Google]
1375391643724.jpg
11KB, 251x242px
>>52575464
>they're not programmers, but they're still coders
That's the same thing.
>>
>>52575477
Programmers use programming languages
Coders are people who are writing in any language
Scripters are people that use scripting languages
git gud
>>
>>52575455
Yes.

PHP: HHVM
Ruby: JRuby
Python: CPython
JavaScript: V8
>>
>>52575489
>using the word coder unironically
how feminine of you
>>
>>52575489

I speak English, therefore I am a coder

I've been coding since I was 14 months scrub do you even noscope?
>>
>>52575489
Are you the same guy that talks about flicks and kino and cinema on /tv/? That's just as retarded.
>>
>>52575464
So what a programming language is something that compiles into a binary as its primary way of execution? Or how would you describe a programming language?

Like I can admit freely that most days I don't do programming anymore. I work as a tester, so I mainly just write scripts to assist me or to automate things.
>>
>>52575507
OK. I stand corrected (as usual). I never really thought about it, I guess.
>>
>>52575438
There are interpreters for C and C++. Are those scripting languages now?
>>
>>52575438
all languages can be compiled to a certain extent, depending on your definition of compile. in some cases (bash) there's just no reason to do so.
>>
>>52575571
ADDENDUM http://www.linux-magazine.com/Online/Features/SHC-Shell-Compiler
>>
>>52575539
A programming language will typically compile into a binary
but the most important distinction is that scripting languages are typically interpreted, and a large variety of programs can typically be extended through the use of scripting languages (think plugins etc for graphics programs)

>>52575558
They certainly can be!
>>
>>52575558
Languages cannot be interpreted or compiled, only implementations can. Scripting language is not synonymous with being interpreted in any case.
>>
>>52575670
Any language with an eval() function realistically requires an interpreter, even if code is otherwise compiled. Compiling and running each eval()d string is impractical from a performance perspective, and impossible on some platforms due to security mechanisms.
>>
>>52576185
You can still do JIT compilation.
>>
>>52576185
In the case of eval, you have to compile the evaluated code anyways. The difference is going to be between outputting the generated intermediate form, and running it.
>>
>>52575581
>but the most important distinction is that scripting languages are typically interpreted
lel, no.
a scripting language is a programming language being used for scripting a specific application like mircscript with mirc, javascript with internet browsers, c with linux, ... that programming language being interpreted or compiled is irrelevant.
>>
File: 1432917781248.jpg (558KB, 1280x720px) Image search: [Google]
1432917781248.jpg
558KB, 1280x720px
If I'm writing a virtual machine, how can I keep arithmetic semantics consistent across different platforms? like how can i guarantee that integer overflow (signed or unsigned) will have specific defined behaviour on all platforms?
I don't want undefined behaviour on the ISA level.

How do other VM's do it? how does QEMU etc guarantee that behaviour as defined in e.g. MIPS or ARM spec is respected across all platforms including x86?
Please don't tell me i will have to write a custom binary adder in C, that would murder performance.
>>
>>52576271
Isn't it the same behavior in most processors?
>>
>>52576321
>in most processors
Is it really okay to depend on that?
Do people actually do that?
>>
>>52576271
> Please don't tell me i will have to write a custom binary adder in C
All common architectures use two's complement arithmetic and have a power-of-two word size.

Even if you need to support architectures which don't fit that pattern, unsigned arithmetic in C doesn't have undefined behaviour, so the only thing that needs to be handled explicitly is arithmetic involving negative numbers.

The biggest difference between most modern architectures is their memory ordering (i.e. when you need to use memory barriers when dealing with multi-threaded code).
>>
>>52576321
Also, even if most processors do it the same, unsigned integer overflow in C is undefined behaviour, and the optimizer can do whatever the fuck it wants with undefined behaviour, so it still needs to be dealt with in a defined manner.

>>52576390
The biggest difference between most modern architectures is their memory ordering
You mean Indianness? how does QEMU simulate a big endian machine on a little endian machine?
Actually i guess that one's easy right? you just re order the bytes as you read from memory i guess.
>>
>>52576414
endianness*
>>
>>52576424
Pajeet pls
>>
>>52576414
The optimizer doesn't depend on specific behavior of overflow; it just assumes that values will never overflow and uses that to modify control structure.
>>
>>52576364
Nobody writes an emulator using 100% portable code. It's just too slow compared to what you can get by relying upon some amount of implementation-defined behaviour.

Most code is written for handful of specific platforms, often only one (e.g. most Windows programs are still 32-bit because there's not enough payoff to justify the substantial effort of fixing all of the 32-bit-isms).
>>
>>52576456
>32-bit-isms
You mean like being retarded and using processor word sizes to define struct offsets?
>>
can't find a good page on all the differences between ansi c and other c
>>
>>52576453
Exactly, that means anything could happen when an integer actually does overflow right?
If I implemented my arithmetic instructions with a naive implementation like reg1 = reg1 + reg2 and reg1 overflows, that would cause undefined behaviour in the VM, which would be different across hosts.

>>52576456
I guess you're right, but I really want to avoid ugly #ifdefs.
Also the ISA I'm emulating is designed by myself, so I can design it to allow as much portability as I like, without killing performance.
>>
>>52576499
>I guess you're right, but I really want to avoid ugly #ifdefs.
Can't you just use a modular approach and let the build tool select the specific implementation?
>>
>>52576414
> unsigned integer overflow in C is undefined behaviour
Signed integer overflow is UB. Unsigned arithmetic doesn't overflow, it wraps (i.e. it's modulo 2^N).

> You mean Indianness?
No, I mean the order in which load/store operations are actually performed. Modern CPUs don't actually execute instructions in sequence; they effectively execute each instruction as a background task. For the most part, this doesn't matter; an instruction won't execute until its inputs have been computed, and any reads from "memory" will wait until any previous store instructions have completed so they see the updated value. But that's local to a single core; for multi-threaded code, you need memory barriers (look up the term) to ensure that stores actually occur in the correct order.

> how does QEMU simulate a big endian machine on a little endian machine?
Probably with something like
uint32_t read_word(const uint8_t *p)
{
return (p[0]<<24) | (p[1]<<16) | (p[2]<<8) | p[3];
}

Some CPUs have byte-swap instructions or even the ability to run in either big-endian or little-endian modes.
>>
>>52576548
who /little-endian/ here?
>>
>>52576548
>Signed integer overflow is UB. Unsigned arithmetic doesn't overflow, it wraps (i.e. it's modulo 2^N).
Forgive me, i often get those two confused, my point still applies though.

When you say multi threaded code, do you mean in the host or in the guest? I don't plan to have any multi threading in the implementation of the VM (I don't know how to parallelize it), and i don't plan to have multiple virtual CPU's either, and yes I know what memory barriers are and I don't think I will need them. I don't even do instruction re ordering either.
>>
>>52576499
> that would cause undefined behaviour in the VM, which would be different across hosts.
It will be different between different compilers, or between different builds with the same compiler but different flags.

It may also differ between CPUs. E.g. if the compiler doesn't bother clearing the carry flag if it "shouldn't" get set, the consequences of that will depend upon exactly how the carry flag affects certain instructions (e.g. a shift operation might always shift in the carry, or there might be separate shift with/without carry instructions).
>>
>>52576578
Probably at least 99% of people in this thread.
>>
>>52572109
http://c2.com/cgi/wiki?ThreeStarProgrammer
>>
>>52576623
this guy reposting his inability to using his brain
>>
>>52576598
> When you say multi threaded code, do you mean in the host or in the guest?
Guest.

But if you're not multi-threading the host, then it isn't an issue; you'll always end up emulating a guest with perfect memory ordering. Code which relies upon loose memory ordering typically wouldn't work, although I suppose it's possible that it could be used as an anti-emulation strategy.
>>
>>52576470
> You mean like being retarded and using processor word sizes to define struct offsets?
Yeah, that sort of thing. The sort of thing that every Windows program does, including the official ABIs. A lot of standard data formats are "defined" as C structures, which inherently depends upon specific types having specific sizes and alignments.

You don't think Windows reads e.g. a BITMAPINFOHEADER a byte at a time then assembles the bytes into integers with shifts, right?
>>
>>52574526
Even with a double, it returns 0...

>>52574554
disk_sizemb is 99
part size is the photo I replied to...
>>
>>52576880
>Even with a double, it returns 0...
because you are merely casting 0 from the integer division to 0.0
>>
File: weeee.png (3KB, 640x300px)
weeee.png
3KB, 640x300px
>>52576894
Yeah I just figured that out. I'm using doubles now.
Would you care to explain exactly why this happens, I'm not 100% sure...
>>
File: CPlusPlus.jpg (36KB, 433x455px) Image search: [Google]
CPlusPlus.jpg
36KB, 433x455px
What does /dpt/ think of C++?
>>
I'm just starting C++ and have a really basic problem I need help with. For class:

namespace sict {
class Shape {
public:
int volume;
char colour[10];
}


I'm trying to assign values to the character array in my main file using the following code (which doesn't work):

circle.colour[10] = "Blue";
u(circle.colour[]);


Anybody know what I'm doing wrong?
>>
>>52576916
What's the confusion now? Those are the accurate integer representations, unless you want them to have decimal parts too
>>
>>52576934
It's a meme language

>>52576942
colour[10] is out of bounds, the index goes from 0 to 9
>>
>>52576943
>What's the confusion now?
Sorry, I should have been more clear. It works now.
Could you care to explain why the integer division becomes 0??
>>
>>52576955
why a meme language?
>>
>>52576934
auto duration = now.time_since_epoch();
auto millis = std::chrono::duration_cast<std::chrono::milliseconds>(duration).count();
>>
>>52576971
When you divide 2 integers, you get a truncated integer out of it
>>
>>52576955
>It's a meme language
Why ?
>>
>>52576980
>>52576955

Is Python a meme language?
>>
>>52576986
Ah okay, thank you.
>>
What are my nimfriends up to?
>>
Umaru-chan edition when?
>>
>>52576986
Can't you think it as Euclidean division that discards the remainder?
>>
>>52577088
Hopefully never, take your shit-tier Umaru cancer and fuck off.
>>
>>52577095
sounds long as tits m8
>>
>>52577127
probably using the wrong English term
I mean the shit you do in elementary school when you first learn division and just write down the remainder when it doesn't result in an integer at the end
>>
>>52577152
It is called long division. I guess that was >>52577127
is trying to say
>>
>>52577186

The bump limit seems almost reached.
>>
are there any good torrent libraries for C#?
alternatively, is there another protocol i can use to publish files on a P2P network without having to program everything on my own?
>>
>>52577263
http://www.mono-project.com/archived/monotorrent/

but it looks kind of old. There's binding to other torrent libraries written in C that are more mature.
>>
>>52576942
Go read up on arrays, you've misunderstood something. When you say
char colour[10];

it creates an array of 10 chars. The variable name is "colour", the "[10]" is for the size. Whenever you want to use that variable (the entire array) you refer to it as colour. The individual chars inside the array are referred to by the index, e.g. "colour[0]" is the first, "colour[1]" is second etc.
u(circle.colour);

You can use colour in a function that requires a "char *" argument.

circle.colour[10] = "Blue"; // incorrect, colour[10] is a char, not a char array (and 10 is out of bounds)
circle.colour = "Blue"; // closer to what you intended, but won't work

You can't assign a value to an array directly (only at initialisation). See http://stackoverflow.com/questions/14915924/assigning-value-to-char-array
>>
>>52573666
You should always multiply before diving with ints.
Still won't give you the accuracy of floating point, but if you plan on rounding later anyway then it's just as good.

int a = 3;
int b = 4;
int res;
res = (a / b) * 100; /* If a < b, (a / b) will always evaluate to 0 */
res = (a * 100) / b; /* Evaluates to 75 */


This method is used in old real-time embedded systems that lack hardware floating point support, because software fp is fucking slow as shit.
>>
>>52574602
images are rendered to fill the square in the catalog only
>>
>>52576689
That would be almost just as bad. The sane way to do it is to use the stdint types (and sometimes bswap_32) which is how every sane *nix program these days does it.
>>
>>52573452
glViewport
>>
File: download.png (3KB, 225x225px)
download.png
3KB, 225x225px
What's your username on codeforces anon ?
whats your excuse for not being on codeforces?
Thread posts: 314
Thread images: 31


[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.