[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: 32
Previous thread: >>55610026

What are you working on, /g/?
>>
I'm trying to learn how to use OpenGL (the graphics library for C/C++), and am using the following tutorial:
http://www.opengl-tutorial.org/beginners-tutorials/tutorial-1-opening-a-window/

I'm currently on tutorial 2 and am getting the following error

/Projects/OpenGLTutorials/ogl-OpenGL-tutorial_0015_33/tutorial02_red_triangle/tutorial02_red_triangle 

Impossible to open SimpleVertexShader.vertexshader. Are you in the right directory ? Don't forget to read the FAQ !



Even though I followed the instructions for how to build it on the mac perfectly

What am I doing wrong? And if possible, are there any other tutorials for OpenGL for Mac users?
>>
>>55617401
What does this picture has to do with programming?
>>
>>55617402
>>55617413
can we talk about this cuckery

this is #kodewithklossy level bullshit
>>
>>55617432
Link?
>>
File: .png (1 MB, 1920x1080) Image search: [Google]
.png
1 MB, 1920x1080
Trying to rig this shit, How do I know if it's working?
Can someone check if this is correct and working?
I'm not sure if 'elo' is the rank or not.
Help?
>http://ideathmatch.com/
import requests
import json

num=666
headers = {'Accept-Encoding': 'identity',
'User-Agent': 'Mozilla/5.0 (Android 4.4; Tablet; rv:41.0) Gecko/41.0 Firefox/41.0'}
text= ["nigger", "4chan", "pedo", "NORMIE"]
while True:
#num+=1
POST1 = {
'_': num
}
r2 = requests.get("http://ideathmatch.com/php/ladder_pertime.php?_={0}".format(num),
headers=headers,data=POST1, timeout=10).json()
for ids in r2:
for words in text:
if words in str(ids["text"]):
print(words in str(ids["text"]),",",words,"matched with: ",ids["text"])
print(ids["id"],ids["elo"])
theid=ids["id"]
print("working?")
POST = {
'winnerID': int(theid),
'loserID' : int(r2[1]["id"])
}
try:

t = requests.get("http://ideathmatch.com/php/matchend.php",
headers=headers,data=POST, timeout=5)
print(t.text)
except requests.exceptions.RequestException as e:
print(e)
>>
>>55617436
www.google.com

durr
>>
>>55617468
It's not there faglord. I already checked.
>>
>>55617468
>google.com is the only domain google owns
>>
>Until now, emoji representing women haven’t been, well…representative. Let’s change that. Google is working to make sure emoji include a wider range of female professions.
>female professions
GAS THEM
>>
>>55617480
here's the link it goes to dick hole

https://www.madewithcode.com/
>>
https://images.google.com/
>>
>>55617485
That's where it is. If it isn't there then you must be on mobile or blind you fucking faggot
>>
>>55617508
Well, except it is not. Fucking retard.
>>
https://twitter.com/madewithcode

FUCKING DIE KYS KYS KYS
>>
>>55617524
It is because I took a screenshot of it, so you must be retarded
>>
Teach me to get good like you guys at programming
>>
>>55617578
Well, even if you took a screenshot it is not there. Stupid fag
>>
>>55617559
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
>>
>>55617586
>I can't see it even though there's evidence it's there so everyone else is retarded

Your argument is retarded and so are you
>>
>>55617609
Well, I can't see it because it is not there. As simple as that.

Also, you are quoting things that were not said nor implied.
>>
File: 1439779749929.jpg (95 KB, 630x421) Image search: [Google]
1439779749929.jpg
95 KB, 630x421
>>55617422
>tutorials for OpenGL for Mac users
>for Mac users
>>
>>55617422
>I'm trying to learn how to use OpenGL (the graphics library for C/C++)
rofl
>>
>>55617629
(you)
>>
>>55617679
Epic meme /b/ro xD
>>
>>55617685
>pls gib attention
>>
File: anime.png (201 KB, 335x365) Image search: [Google]
anime.png
201 KB, 335x365
What was OP pic?
>>
>>55617693
(you)
>>
>>55617422
you just need a string (char array), either fix the mac-specific file paths or whatever or just use a string literal for now

https://www.opengl.org/sdk/docs/man/html/glShaderSource.xhtml
>>
>>55617700
Epic meme /b/ro xD
>>
>>55617633
>>55617654
What's so funny?
>>
>>55617699
Recep Erdogan with ostentatious/foppish makeup and the gay flag behind him, also some text about how sharing the picture.

It wasn't related at all to programming
>>
>>55617721
>pls gib attention
>>
>>55617728
(you)
>>
>>55617726
u, n00b
>>
>>55617726
opengl is the same across different platforms (except for slightly different versions especially opengl es which is used for mobile devices and web browsers) so you don't need a tutorial specifically for mac
>>
File: q.jpg (111 KB, 500x500) Image search: [Google]
q.jpg
111 KB, 500x500
Does anyone here understand RxJava?
>>
>>55617727
Is it the same guy who keeps posting political images for /dpt/ OPs? How autistic is he?
>>
>>55617762
gay webshit >>>/g/wdg
>>
>>55617784
lol wut?
>>
>>55617794
idk seems like a shitty meme at least
>>
>>55617712
Okay... Good news: after I fixed the filepath names for the shaders, I stopped getting the error. However, now I'm getting this error:

/Desktop/Projects/OpenGLTutorials/ogl-OpenGL-tutorial_0015_33/tutorial02_red_triangle/SimpleVertexShader.vertexshader
ERROR: 0:5: Invalid use of layout 'location'
ERROR: 0:9: Use of undeclared identifier 'gl_Position'
ERROR: 0:9: Use of undeclared identifier 'vertexPosition_modelspace'
ERROR: 0:10: Use of undeclared identifier 'gl_Position'

Linking program
ERROR: One or more attached shaders not successfully compiled

>>
>>55617870
>that font
are you fucking kidding me?
>>
>>55617886
It's awesome
>>
>>55617870
swap the order of vertex shader and fragment shader in the parameters of LoadShaders
>>
>>55617736
Epic meme /b/ro xD
>>
>>55617401
Write the most fastest way of displaying n number fibonacci sequence in your fav lang, make it count the time or give proof by some kind

C++
int slowFibonacci(const int x)
{
int fib = 0;

if (x == 0) return 0;
if (x == 1) return 1;
else {
return (fibonacci(x - 1) + fibonacci(x - 2));
}
}
>>
>>55617886
The font is OK, the rendering sucks

whats the font btw ?
>>
>>55617941
#include <iostream>
#include <array>
#include <utility>

template<int I>
struct Fib
{
static const int val = Fib<I-1>::val + Fib<I-2>::val;
};

template<>
struct Fib<0>
{
static const int val = 0;
};

template<>
struct Fib<1>
{
static const int val = 1;
};

template<size_t ... I>
int fib_impl(std::index_sequence<I...>, const int i)
{
constexpr std::array<int, sizeof...(I)> a
= {Fib<I>::val... };

return a[i];
}

int fib(const int i)
{
return fib_impl(std::make_index_sequence<46>(), i);
}

int main(int argc, const char*[])
{
std::cout << Fib<45>::val << '\n';
return 0;
}


beat that faggot
>>
>>55618006
/wdg/ here
teach me the basics of your stuff I'll teach you everything you need to know in matter of days
>>
>>55617971
easy ;^)
I already did

constexpr int fastFibonacci(const int i)
{
const auto sqrt_5 = std::sqrt(5);

if(i == 0) return 0;
if(i == 1) return 1;

return static_cast<int>((std::pow(1 + sqrt_5, i)
- std::pow(1 -sqrt_5, i)) / (std::pow(2, i) * sqrt_5));
}
>>
>>55618021
>teach me the basics of your stuff I'll teach you everything you need to know in matter of days
not a fair trade
>>
>>55617941
unsigned long long fib[100];
inline unsigned long long GetFib(int n) {
return fib[n];
}

all you have to do is initialize it somewhere first
>>
>>55618056
manually ?

int[] arr = {0,1,1,2,3,5,8...};


like that ?
>>
File: enterNumber.png (171 KB, 946x887) Image search: [Google]
enterNumber.png
171 KB, 946x887
>>55618056
>>55618107
/wdg/ faggot detected
>>
>>55618107
sure, doesn't matter since the initialization only happens once
>>
>>55617941
Nigga, where's your TCO at?
>>
>>55618056
GetFib(101)
>>
>>55618200
wouldn't work anyway since there's no basic type high enough to hold that value
>>
>>55618208
template <typename T, T ...>
struct CTList;
>>
My IDE says that this method is missing a return statement. Why? The return statement is inside the try block.

static int[] setTimer() {
boolean gettingInput = true;

while (gettingInput) {
try {
Scanner input = new Scanner(System.in);
int hour = input.nextInt();
int min = input.nextInt();
int sec = input.nextInt();
gettingInput = false;
int[] timeArray = {hour, min, sec};
return timeArray;
} catch (InputMismatchException e) {
System.out.println("Try again. Use the format H M S:");
}
}
}
>>
Reminder that deferred lighting is a Jewish lie.
>>
>>55618256
if you get an exception it skips the rest of the try block
>>
>>55618256
because if it goes into the catch and gettingInput is false, then there's no return statement
>>
>be me
>have only 2 projects on github
>more than 30K followers

who else knows this feels?
>>
>>55618256
    static int[] setTimer() {
Scanner input = new Scanner(System.in);

int[] timeArray;

while (true) {
try {
int hour = input.nextInt();
int min = input.nextInt();
int sec = input.nextInt();

timeArray = new int[]{ hour, min, sec };

break;
} catch (InputMismatchException e) {
System.out.println("Try again. Use the format H M S:");
}
}

input.close();

return timeArray;
}
>>
>>55618332
Is that you Linus Torvalds?
>>
>>55618332
I have like 50 projects and 0 subs wtf, show me yours m8
>>
What is the recommended book in learning about a PC structure at detail level as Tebauman(or whatever its called) is for networking.
Also ,what about for unix internal structure.
>>
>>55617446
What are you trying to?
>>
>>55618363
Hello! yes!

i'm working on a kernel. if you want to help here's my github:

github.com/torvalds

we need more contributors
>>
>>55617746
thank you for explaining
>>
File: 1450666369314.png (160 KB, 1031x598) Image search: [Google]
1450666369314.png
160 KB, 1031x598
>>55618332
>who else knows this feels?
Linus does.
>>
>>55618366
see >>55618398
>>
>>55618393
Vote for the ones with key words in them.
>>
>>55618398
Kill yourself linus.
>>
>>55618404
40k followers was less than i expected, but on second thought it's quite a lot of programmers
>>
>>55618456
The github repo is just a mirror of the main kernel source tree anyway.
>>
File: Capture.png (16 KB, 383x334) Image search: [Google]
Capture.png
16 KB, 383x334
>>55618275
>>55618277
Ah, that makes sense.

>>55618353
Thanks for cleaning up the code.
But it prints out the error statement forever.
>>
What are some good resources for learning C other than the K&R book? (I already have it but I don't really have access to it right now)
>>
>>55618414
Perhaps you should change:
requests.get 


to
requests.post

for POST

I think you to encode whatever you want to post before passing it in as params.

I usually use urllib2
>>
I'm learning how to use codenameOne for cross platform app development. Does anyone have experience with it?
>>
>>55618508
all of these
>>
>>55618490
ah, put
input.nextLine();
in the catch statement to clear out the old incorrect input
>>
>>55617957
Gohu, I think... It's fucking amazing

http://font.gohu.org/
>>
>>55618551
Thanks anon.
>>
Reminder that if your first program wasn't a kernel, or if it wasn't programmed in C or assembly, or if it was just a shitty DOS clone, then you have no business calling yourself a programmer, and you should stop right now, get off your computer, and never return to it ever again.
>>
QUICK, WRITE A FUNCTION THAT TAKES AN ARRAY OF NUMBERS (REPRESENTING STOCKS), AND RETURNS AN ARRAY WITH THE PERIOD IN WHICH YOU COULD'VE MADE THE MOST MONEY (AKA, MAXIMUM - MINIMUM IS THE HIGHEST NUMBER)
>>
>>55618537
holly shit that worked
thanks senpai
>>
>>55618611
show me ur github
>>
>>55617941
{-# LANGUAGE BangPatterns #-}

fibby :: Int -> Integer -> Integer -> IO()
fibby 0 _ _ = return ()
fibby n !a !b = do
print a
fibby (n - 1) (a + b) a


main :: IO ()
main = do
putStrLn "How many fibs?"
n <- fmap read getLine
fibby n 1 0


Proof (If you restrict to Int-sized Integer): Printing n fibonaccis takes Ω(n) time, since you have to print n things. fibby takes a constant amount of work before tail recursing, so takes O(n) time. So this is the fastest possible, asymptotically.

If you consider fibonaccis arbitrarily large, I don't really know. This algorithm would take O(n log n) since addition of arbitrary size takes O(log n) time, but maybe it is possible to do better?
>>
File: Capture.png (13 KB, 411x327) Image search: [Google]
Capture.png
13 KB, 411x327
>>55618573
Perfect!
>>
>>55618640
No, you'll just steal my code.
>>
>>55618641
is that impementation better than the 0 : 1 : zipWith version?
>>55618655
I don't even know how to do github, its too hard
>>
>>55617905
Oh... Duh. Now I feel dumb

That makes sense. Thanks!
>>
File: Untitled.png (10 KB, 693x161) Image search: [Google]
Untitled.png
10 KB, 693x161
>>55618639
c:
>>
>>55618667
Ok fine, here it is:
https://github.com/torvalds
>>
>>55618655
>posts code on shithub despite caring if people steal his code
>thinks his neckbeard code is worth anything in the first place
>implying
>>
>>55618667
zipWith has the same asymptotic performance. I didn't use it because it would be simpler this way
>>
>>55618684
hahah, I lied, I know how to git clone haha
>>55618696
well, I would never come up with either implementation
its nice to see someone competent, unless u copied off some forum
>>
>>55617401
Custom recovery for Samsung J3.
And a Deep Learning Neural Network to reconize people by the way they sneeze, answer the phone, cough, groan, moan and other actions.
>>
A simple return method is returning

--0.1999999999999802
When the real value is 15
I have no idea why. The value isn't modified at all.
public double getVolume() {
return volume;
}


public class Chemical {
private String name;
public double volume;
private double metabolization;
private double damage;

public Chemical() {
name = "Chemical";
volume = 15;
metabolization = .5;
damage = 0;

}
public Chemical(String str, double a, double b, double c) {
name = str;
volume = a;
metabolization = b;
damage = c;

}


What's the issue?
>>
>>55618684
>https://github.com/torvalds

Implying you're Linus Torvalds an lurking on /g
>>
>>55618783
And of course there's this.

 Chemical Toxin = new Chemical ("Toxin",15,.5,1.5);
System.out.println(Toxin.getVolume());
>>
>>55618791
>github.com/torvalds
are you that retarded m8 ?
>>
>>55618838
>>55618783
works on my machine

clean and rebuild project
set a breakpoint on that method and see what's happening
>>
>>55618949
What's a breakpoint? Nobody ever taught me how to debug.
>>
>>55618683
>1. NORMIES GET OUT

>2. Kill all niggers.

>3. GAS THE JEWS

>4. No niggers.

>5. Make pedophilia legal

>6. GAS THE JEWS

kek
>>
File: vs.png (10 KB, 556x340) Image search: [Google]
vs.png
10 KB, 556x340
>>55618580

Looks better when it's the right size.
>>
>>55618968
Actually I figured it out. Now to see if I can make sense of what it shows me.
>>
>>55619034
No clue what's going on. Oh well. Wonder if I just copy paste the code and everything will be okay.
>>
>>55619122
Oh I was using a Japanese keyboard. So uh... that may have had something do with it.
>>
>>55618611
My first program was a todo-list written in C, but I barely call myself a programmer since I don't get paid for it. Hopefully in the next few months going to start interviewing.
>>
>>55619002
rude
>>
Based Dijkstra algos
>>
>>55619467
What font is that?
>>
Where do I find full 4chan API? There is a page on github but those are readonly methods. How do I make replies/threads programmatically?
>>
>>55619494
Roboto sans 9
>>
File: lena.webm (490 KB, 576x576) Image search: [Google]
lena.webm
490 KB, 576x576
>>55610629
>>55610657
>>55611855
How do you get this shit to actually look cool?
>>
>>55619558
The api IS read only.
>>
>>55619467
>java
>no ide
ISHYGDDT
>>
>>55619743
>needing and ide to solve simple problems

kys
>>
>>55619467
>10*10*(10*10)
>1000
huh, really makes you think
>>
>>55619761
ok kid
>>
>>55619743
...lolwut, why would I need an IDE for something that just uses the stdlibs

Fixed + test client. Time to push to the algorithm-implementations repo.
>>
>>55619786
Dat sum clean Java
>>
>>55619786
because calling javac and java manually is ridiculous
>>
>>55619770

makes me think status: really
>>
>>55619607
you don't?
but maybe I just don't get the appeal of intentionally fucking up an image
>>
>>55619828
kys
>>
>>55619786
import java.util.*;

public class ExpressionEvaluation {

public static Double evaluate(String expresion) {
Stack<String> operators = new Stack<String>();
Stack<Double> operands = new Stack<Double>();

for (String token : expresion.split(" ")) {
switch (token) {
case "(":
continue;
case "+":
case "-":
case "*":
case "/":
case "sqrt":
operators.push(token);
break;
case ")": {
String operator = operators.pop();
double value = operands.pop();

switch (operator) {
case "+":
value = operands.pop() + value;
break;
case "-":
value = operands.pop() - value;
break;
case "*":
value = operands.pop() * value;
break;
case "/":
value = operands.pop() / value;
break;
case "sqrt":
value = Math.sqrt(value);
break;
}
operands.push(value);
break;
}
default: {
operands.push(Double.parseDouble(token));
}
}
}
return operands.pop();
}

public static void main(String[] args) {
// test client
for (double x = 0; x < 100; x++) {
for (double y = 0; y < 100; y++) {
String expresion = "( ( " + x + " * " + x + " ) * ( " + y + " * " + y + " ) )";
if (! ( evaluate(expresion) == (x * x * (y * y))))
throw new AssertionError();
}
}
System.out.println(evaluate("( ( 10 * 10 ) * ( 10 * 10 ) )"));
}
}
>>
>>55619873
ok kid
>>
>>55619871
The two webms the OP posted look really nice though.

>I don't get the appeal of image processing
OK.
>>
>>55619900
>The two webms the OP posted look really nice though.
to me they just look like clips that got fucked up during transfer
>>
>>55619828
this, just click to run
>>
>>55619761
>needing basic necessities of modern society to solve simple problems

kys
>>
>>55619761
back to c neet
>>
>>55619786
>unironically using java without IDE
>>
>>55619786
it's not like you need to have any compromise with productivity
>>
>>55617559
>>55617592
What are you even upset about?
>>
>>55619885
Lol did you type this all out bro? I noticed you didn't capitalize // test client

Final implementation: https://github.com/kennyledet/Algorithm-Implementations/blob/master/Expression_Evaluation/Java/kennyledet/ExpressionEvaluation.java


Now to continue with Algorithms, 4th ed.
>>
What's the Final Solution to the Java Menace?
>>
I'm stuck with a person who claims to not be all that favorable to OOP and uses the sane parts of C++11/14 but he's gone absolutely mad.

He tries to do code-reuse everywhere, he refers to code that's hard to read and doesn't do very much as 'incredibly cool'.

Can I save him? How do you even show someone that's that far gone what they're doing?

We have std's all over the code and it does nothing but draw a still frame using SFML.
>>
File: 1468725072421.png (341 KB, 500x686) Image search: [Google]
1468725072421.png
341 KB, 500x686
>>55620143
>std's all over the code
>>
>>55620143
>We have std's all over the code and it does nothing but draw a still frame using SFML.

That's not a bad thing, Anon. Show some sample btw.
>>
File: a.jpg (16 KB, 285x267) Image search: [Google]
a.jpg
16 KB, 285x267
>>55620105
>Lol did you type this all out bro?

Lol no. i have a program that does image recognition on code using deep convolutional neural networks.

the output might not be the same as the original, though
>>
>>55620143
would you say... std ridden code?
>>
File: 1467070554775.png (55 KB, 217x190) Image search: [Google]
1467070554775.png
55 KB, 217x190
>>55620143
>C++
>STD
Sasuga Sepples-chan.
>>
>>55620254
studded
>>
>>55620180
>i have a program that does image recognition on code using deep convolutional neural networks.

Nice nice. Sauce?
>>
Is there any case where the arg1 -> arg2 -> ret makes more sense than (arg1, arg2) -> ret?
>>
>>55620315
When you want to make it easy to partially apply the first argument
>>
>>55620338
I see, thanks.
>>
>>55620179
>Show some sample btw.
I know he browses this place, he's gone to work now but I don't want to be recognized.

But it's the normal stuff of abstracting and abstracting things that'd take a line or two to write at most.

He doesn't really appreciate the fact that enforcing all these structures upon anyone writing code slows down the process immensely.
>that's not a bad thing anon
Yeah in contrast to doing using namespace std.
But it's terrible. Here I found a place in the code where he introduced a construct for linking sprites to sounds. That doesn't even make any sense here. And all he does is get them as a std::pair and use them separately.
Seems entirely arbitrary and there's no comments to explain the (presumably weak) reasoning for this.

Maybe if I just ask him to comment his code more he will start realizing his issues?
>>
>>55620315
>>55620369
(arg1, arg2) makes more sense if you are feeding it the output of a function that outputs a tuple.

Also I think GHC represents arg1 -> arg2 -> ret more efficiently than (arg1, arg2) -> ret if you don't turn on optimizations. Otherwise they're about equal.
>>
>>55620381
>Maybe if I just ask him to comment his code
He doesn't comments it because he wants to be the only one that understands that mess.
>>
OP of the plugin here
https://wunkolo.itch.io/pixsort

I use pixel sorting and a vector field to chose the interval of pixels that are being sorted. I also have a box-blur filter option that can make it even smoother.

The spiral vector field is calculated like so:

        Vector -= Params.FlowOrigin;
if( glm::length(Vector) <=
glm::length(Params.FlowEnd - Params.FlowOrigin) )
{
return glm::dvec2(
-Vector.y - Vector.x / 2.0,
Vector.x - Vector.y / 2.0
);
}
return glm::dvec2(0, 0);
>>
>>55620381
>I know he browses this place, he's gone to work now but I don't want to be recognized.

You've already posted enough clues for him to figure it out, anyway.
>>
>>55620456
I don't think he's malicious anon.
It all just makes me feel bad.
>>55620486
There's many differences between code and text describing code.
>>
>>55620482
meant as a reply to >>55619607
>>
>>55617941
(defun fib (n)
(caar (matrix-expt '((1 1) (1 0)) n)))
(defun matrix-expt (matrix n)
(cond ((= n 0) '((1 0) (0 1)))
((evenp n)
(let ((a (matrix-expt matrix (/ n 2))))
(matrix-mul a a)))
(T (matrix-mul (matrix-expt matrix (1- n)) matrix))))
(defun matrix-mul (a b)
(mapcar (lambda (row)
(mapcar (lambda (col)
(reduce #'+ (mapcar #'* row col)))
(apply #'mapcar #'list b))
a))

O(log n) time
>>
Is there a better way to break out of a nested loop?
        for words in want:
if words in str(ids["text"]):
#stuff1
for ids in r2:
if bl==1:break
for words in donotwant:
if words in str(ids["text"]):
#stuff2
bl=1
break
bl=0
>>
>>55620482
>15.00 USD


where can i do this to my images without paying?
>>
Any pythonfag here? How do I validate something like this using flask? Two forms on the same page
>>
>>55620700
http://stackoverflow.com/questions/21949452/wtforms-two-forms-on-the-same-page
>>
>>55620683
Split it into functions
>>
>>55620683
If your lang provides a goto, yeah.
>>
File: ideathmatch.png (27 KB, 437x364) Image search: [Google]
ideathmatch.png
27 KB, 437x364
>>55618683
>>55619002
>>
>>55620865
wtf are you doing
>>
>>55620865
/pol/ tags?
>>
>>55620814
Any way to do this using flask's builtin request?
>>
File: colourwheel.png (2 MB, 3190x674) Image search: [Google]
colourwheel.png
2 MB, 3190x674
learned that if you set the S value of the CSV wheel to various values you get some cool effects.
>>
File: myColorSpaceIsBroken.png (619 KB, 792x722) Image search: [Google]
myColorSpaceIsBroken.png
619 KB, 792x722
>>55621109

Found a better one
>>
>>55621109
>>55621166
These are rad, I love to muck around with gradients and blend modes in PS
>>
>>55621166
>>55621109
i don't get it. explain pls
>>
>>55620848
>goto
>ever
>>
>>55621186
>le goto is bad meme

please explain with reasonable arguments why goto is bad.

i'm waiting.
>>
>>55621186
>muh for
>muh while
>lol goto??? rly?
>>
>>55621180

I wanted to make a program to generate one of those colour pickers you get in paint programs.

After some thought it turns out that you can make one by going through every point in a circle and setting it to HSV(angle(center_of_circle, point) / 360, vectorDistance(center, point), 1).

Messing around with the saturation value produces some cool effects.
>>
>>55621186
It's useful for just a pair of cases, like exiting nested loops/switchs, handling exceptions, and other things I can't remember.
Of course, using it in a bad way could lead to spaghetti code, but you need to blame the programmer.
>>
>>55620683
functions
>>
how do I move data (let's say a struct) to a specified memory address?
>>
>>55621442
Why would you wan't to do that? I don't think your OS lets you do it.
>>
>>55621442
memcpy
>>
>>55621470
I mean

to a specified virtual memory address
>>
>>55621483
thanks
>>
>>55621503
or memmove
 void *memmove(void *dest, const void *src, size_t n)
>>
>>55620482
>>55620522
Cool thanks for the reply.
>>
>>55620865
>>55618683
Fuck off, skiddie.
>>
A small c program that asks the user to create a string.
#include <stdio.h>
int main(void){
char X[];
scanf("%s",X);
printf("%s",X);
return 0;

So basically the user enters a string, and it's size should be however long the user wants it to be.
It doesn't work and I don't know how to go about doing this.
>>
>>55621655
Making your own scripts is being a skiddie now?
>>
>>55621761
Read about memory allocation.
>>
>>55621761
It does not work because what you are doing does not make sense.
>>
>>55621761
variable length arrays were a mistake
>>
>>55621761
}

Also X has no size.
>>
>>55621775
I understand memory allocation.
You have the reference operator & and the dereferencing operator *.
Anyways any more help would be appreciated.
>>55621788
I want it to be whatever size the user chooses. Oh yeah I can do that prompting the user before that.
Thanks. Any more help would be appreciated.
>>55621776
What I am trying to do is ask the user to input a string that will be saved later on into a data type char variable[size].

Here is the updated code.
#include <stdio.h> int main(void){
printf("enter the size of the url-string:");
scanf("%d",&size);
char X[size];
printf("enter the url");
scanf("%s",&X);
>>
>>55621878
You didn't declare "size".

X, not &X. X is already a pointer.
>>
>>55621878
you forgot to declare size
you forgot }
You need to indent your code and add a new line before int main
>>
>>55621655
One of those isn't even the original post you baka.
Define skiddie also.
>>
>>55621878
That will not work. You cannot use the stack to allocate char X[size] where size is a variable. you have to use malloc. Also, asking the user how big the string will be is a terrible solution. You should malloc some reasonable size, then read in char by char, reallocing as necessary (increase size exponentially, for example) when your string runs out of room.
>>
meanwhile in sane languages:

#include <iostream>
#include <string>

int main() {
std::string s;
std::cin >> s;
std::cout << s << std::endl;
}


>faster
>more secure
>more readable

Welcome to the 3. millennia
>>
>>55621898
>>55621899
#include <stdio.h>//hate writing this  and int main everyday when im writing and testing small c stuff (using a unix OS so i have to vim testfile.c and do that everytime but i guess ill create a hotkey soon)
int main(void){
int size;
printf("enter the size of the url-string:");
scanf("%d",&size);
char X[size];
printf("enter the url");
scanf("%s",X);
printf("%s",X);
return 0;
}


thanks it worked!!!
why are arrays always pointers?
>>
>>55618743
Post github
>>
>>55621994
>You cannot use the stack to allocate char X[size] where size is a variable


what is variable length arrays, introduced in the C99 standard for 420?
>>
>>55617924
Holy shit what a toxic string of posts
>>
>>55621994
I got it working, I am eager to know what you think about this.
>>55622018
>>
>>55621994
>That will not work. You cannot use the stack to allocate char X[size] where size is a variable
This is wrong.

>Also, asking the user how big the string will be is a terrible solution
It is the best solution if you are reading from a file for example.

>increase size exponentially, for example
This is a bad idea.
>>
>>55622035
https://github.com/Charlotteis
>>
>>55622018
>read in char by char, reallocing as necessary
as seen in "How to achieve worse performance in C than in interpreted languages".
>>
>>55622072
>javascript tumblr script kiddie
>>
>>55618743
How are you going to train that?
>>
>>55622072
you're joking right
>>
>>55622018
Just a tip: use size_t from stddef.h for sizes and indexes instead of int. (%zu in printf/scanf)

>using a unix OS
What OS exactly? If GNU/Linux what distro?

>so i have to vim testfile.c
Huh? You can use any editor of your choice.

Are you doing this as part of a university course?
>>
>>55622090
>>55622108
>they fell for it
>>
>>55622083
>as seen in "How to achieve worse performance in C than in interpreted languages".

this is untrue if the IO is buffered
>>
>>55622134
Especially if the IO is buffered. By reading char by char you're just throwing away the work of buffering.

Reading in chunks is better.
>>
>>55622016
main = getLine >>= putStrLn
>>
>>55622233
>putStrLn
>Ln
This is stupid
>>
>>55622233
>hasklel

dude 50k SLOC runtime lmao
>>
>>55622018
What happens if the user lies or is mistaken about the string length? They answer, for example, that the string has 10 characters but it actually has 1000? It seems like you are just inviting the user to overflow buffers here.
>>
>>55622233

print (input())
>>
>>55622279
main = interact id
>>
>>55622254
Tell me about Glibc's SLOC count.
>>
>>55622016
(print (read))
>>
>>55622340
#!/bin/cat
>>
>>55622332
do you even know what a runtime is?

haskell can't even run unless it includes those 50k lines

C's runtime is just a few bytes (to allocate the main stack frame and execute main)
>>
>>55622381
You can't anything useful without Libc though.
>>
>>55622381
>haskell can't even run unless it includes those 50k lines

not the person you replied to, but could you explain this please?
>>
There is literally nothing wrong with 3d women
>>
>>55622458
haskell needs RTS to run
https://downloads.haskell.org/~ghc/7.10.3/docs/html/users_guide/runtime-control.html

read here, and google haskell RTS for more info

here is what C needs
https://en.wikipedia.org/wiki/Crt0
>>
>>55622474
Except maybe that they're not technology.
>>
>>55622504
yeah they are when you program an application you think of your target audience in this case women
>>
>>55622502
>>55622381
Are you retarded?

If you include std*.h (which I'm pretty sure you will), the program will be linked against a multi-million-SLOC libc.

50k is nothing compared to that.
>>
you all suck at programming my cat can out program all of you
>>
>>55622608
Well, my cat can program the same as whatever is its input.
>>
>>55622109
No I have a c course that I'm doing, but I was just doing this for fun.
>>
>>55622577
int printf(const char *s,...);

int main()
{
printf("get fucked\n");

return 0;
}
>>
>>55622608
that's because your mom taught me how to program

i overflowed her buffer again and again
>>
>>55622631
women are the best programmers
>>
>>55622577
>include = linked
Do you know how static and dynamic linking works?

libc is usually dynamically linked
>>
>>55622629
$ ldd retard.out
linux-vdso.so.1 (0x00007ffdb6be1000)
libc.so.6 => /usr/lib/libc.so.6 (0x00007f142de84000)
/lib64/ld-linux-x86-64.so.2 (0x00007f142e225000)
>>
>>55622644
>the only winning code is not to run
what did he mean by this
>>
>>55622629
Still links to a multi-million-SLOC libc.

>>55622577
You will have to count the standard haskell libs then.
>>
>>55622644
name a single relevant application made by a woman after 2000
>>
>>55622660
>Still links to a multi-million-SLOC libc.
do you see any #includes in that block of code?

retard
>>
>>55622659
he confirmed my cat is mvp at programming and he can't program at all
>>
>>55622650
It's still a (huge) runtime, even if dynamically linked.
>>
File: should have been a weebm.gif (3 MB, 240x239) Image search: [Google]
should have been a weebm.gif
3 MB, 240x239
>>55622608

fuck you are cat.
>>
>>55622677
>do you see any #includes in that block of code?
No, what does this has to do with my post? It still links to a multi-million-SLOC libc.
>>
>>55622668
Here is a whole list

http://alltopstartups.com/2015/07/03/apps-created-by-women/
>>
>>55622707
>asks for relevant
>posts a list of trash
>>
Newfag here, I'm writing a software that need to read files in a certain directory, the problem is that said directory may also be a zip compressed archive.
My solution was to create a "Folder" class; on its initialization it get a listing of the files into the target folder, or, this is a compressed archive, opens it with zlib beforehand. It also set a boolean variable "is_compressed".
Then it is possible to call a function Folder.open(filename) that simply open and read the file if is_compressed is false or, if it's true, extract the file from the archive returning the content.
Does it sound like a decent solution? Also, given that the initialization of Folder class may open (and keep opened) a compressed archive, do I need to close it before the program exits or this is automatically managed by the garbage collector?
>>
>>55622677
>equating including to linking
Yep, you're retarded.

See: >>55622658
/usr/lib/libc.so.6
is part of your C program's runtime.
>>
>>55622688
libc is not required
RTS is required

you can run a C program without libc
you cannot run a haskell program without RTS

>>55622703
depends on the compiler and the options you give it. I think gcc automatically runs -lc, but that can be turned off
>>
>>55622723
define "Relevant"
>>
File: 1453657295316.jpg (112 KB, 1920x1080) Image search: [Google]
1453657295316.jpg
112 KB, 1920x1080
>>55622724
>>My solution was to create a "Folder" class
>OOP fags are at it again
Thread replies: 255
Thread images: 32

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.