[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
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: 17
File: DPG - Nagato.png (389 KB, 934x1000) Image search: [Google]
DPG - Nagato.png
389 KB, 934x1000
What are you working on, /g/?
>>
>>46460513
Rewriting the Linux kernel in Haskell.
>>
>>46460525
how is that going for you?
>>
Rewriting the Haskell kernel in Linux
>>
Thank you for using an anime image.
>>
Created the new eminent minimal Lisp language called MemeLisp.
>>
Kernel the Haskell rewriting in Linux
>>
>>46460537
pretty good, thanks for asking.
>>
>>46460851
lolwut?
>>
I'm working on some path correlation and recognition stuff. Stuck a bit.
>>
File: some_old_guy.jpg (70 KB, 960x541) Image search: [Google]
some_old_guy.jpg
70 KB, 960x541
All the way from: >>46438832

>allocating/reallocating level structures
>possibly something I am overlooking

>>46448109

>That's one int you are allocating. If you are using it as an array, then you are probably trashing the heap.

I shouldn't need to malloc tiles at the beginning like you see, I had that there in case anyone said that was good or not. (Although at this point it does stand in the code). When the level is being parsed, a layers tiles are allocated AFTER all the other layer information is figured out:
LVL.LYR[l].tile = (int*)malloc( sizeof(int) * LVL.width * LVL.height );

If I ran:
LVL.LYR[l].tile = (int*)realloc( LVL.LYR[l].tile, sizeof(int) * LVL.width * LVL.height );

instead, I would get a crash. l is the number that keeps track of the number of layer nodes. At the beginning of finding a layer node:
if( l > 0 ) { 
LVL.LYR = (struct layer*)realloc( LVL.LYR, l * sizeof(struct layer) );
}

And at the end of finding a layer node, l would go up one for next time (if there is a next time). This works correctly, but it's here if someone asks to see it.

where the game crashes is
free(LVL.LYR);


I said yesterday I might work on it, but sadly school/work sucked up all my free time (video editing/SQL reports).

What I can do, is make a backup of my current project, and change the structure system so that no struct has a struct within it.
>>
File: 1309323158782.png (30 KB, 800x473) Image search: [Google]
1309323158782.png
30 KB, 800x473
I'm writing a PHP parser in Rust when I should be studying for my symmetric cryptanalysis exam on Monday.
>>
>>46461414
>PHP parser
>in Rust

Why do you hate yourself?
>>
File: 1312083244637.png (98 KB, 392x248) Image search: [Google]
1312083244637.png
98 KB, 392x248
>>46461473
I want to implement static analysis for PHP. Finding SQLi and XSS vulnerabilities. The university I work at has an prototype written in PHP and I'm getting payed to extend it. So no, I don't hate myself. That's why I'm trying to rewrite it.
>>
File: screenshot.png (50 KB, 540x960) Image search: [Google]
screenshot.png
50 KB, 540x960
The network manager, again. I set up a lot and built a piece of the web-based management app.
>>
How to Create a Successful Open Source Project

1. Give it an unpronounceable name. Better if it's an acronym.
2. Under no circumstances must you ever tell people what your software actually does. The first thing on your website should be a brief description mentioning that it's modular, multi-threaded, open source, and what programming language it's written in.
3. The next thing on the website should be a Recent Announcements section. Mention that you released version 3.4.8 and fixed bugs #42135 and #47892.
4. Auto-generated Doxygen pages are always a substitute for a real manual.
5. Installers are for babies. Force users to compile from source and find all the dependencies themselves. Bonus points if you make them choose a mirror instead of having a single download link.
6. Have a bug database, but never acknowledge anything on there. Either ignore it or mark everything wontfix.
7. Break compatibility often.
8. Refer to yourself as a "Foundation". You aren't just a fat guy living with your parents. You're a foundation and need donations.
9. Have an outreach program for women. Letting women decide how to spend their free time for themselves is sexist. Telling them what to do and pressuring them into a field they aren't interested in is progressive.
10. Abandon the project. Remove all dates from your website so nobody realizes the latest release is actually 7 years old.
>>
ok /g/uys, I have a problem with C#.
I have this list that I'm trying to assign a value to (I've tried a = b and a.Add(b)) but it keeps throwing me a NullRefrenceException. I find this sort of strange since...
Ofcourse the list is null, that's why I'm trying to set a value to it.
Anyway, Declaring it :
public static List<String> pics,oldpics,newpics = new List<String>();

(this is in the vars class btw)

Triying to set a value to it for the first time
vars.i = 0;
foreach (string pic in pictures) {
vars.pics[vars.i] = pic;
vars.i++;
}


(this is happening inside the Deserialize function that's being called from the Check function)

Main :
public static void Main () {
Input ();
if (!Directory.Exists(vars.downloc)) {
Directory.CreateDirectory(vars.downloc);
}
while (true) {
Check ();
}
}
>>
>>46462240
>5. Installers are for babies. Force users to compile from source and find all the dependencies themselves. Bonus points if you make them choose a mirror instead of having a single download link.
this.
as an end user I shouldn't have to click 'US' or "UK", I should just be able to click one link and your cdn should handle that automatically
>>
Minecraft bot. Upside, we have a curses interface now. Downside, I broke settings parsing again

https://github.com/SpockBotMC/SpockBot
>>
>int ofTheJedi;
>return ofTheJedi;

god damnit
>>
OP here from previous thread that asked question about the missing digit problem >>46460474

Lets say i pic the number 326. I add the digits and get 11. Subtract that with 326 and i get 315. I give the computer the digits 1 and 5. I add 1+5, getting 6 which i divid by 9. That leaves me with a remainder 6 which if i subtract from 9 i get the missing number which is 3.

Is that the correct way to find the missing digit?
>>
>>46460525
Why do you hate yourself so much?
>>
>>46461285
No need to cast the result of malloc
>>
>>46461285
>sizeof(struct)
I hope you know how that really works.

Also, never use 'l' as a variable name.
>>
What should my max line length be?
>>
>>46462250
>I have a problem
>C#
There's your problem.
>>
>>46462810
80 characters.
>>
>>46462772
well kinda
compiler will warn if you don't explicitelly cast
>>
>>46462772
I think you have to in C++. I may be wrong, though.
>>
>>46462850
Does this refer to a line length that no line should cross or should I be measuring from the first character of the line? 80 seems difficult to maintain if I have to indent for loops.
>>
>>46460513
Slacking off. Patterson's Computer Architecture books are so fucking impenetrable.
>>
>>46462850
Bullshit, unless you use shitty variable names like n or p, or you don't comment anything.
>>
>>46462250
public static List<String> pics,oldpics,newpics = new List<String>();


There's your problem. You define three variables. Only newpics is ever assigned to anything. If you want pics and oldpics to be new lists, you have to do the "= new" thing each time.
>>
>>46462899
I just needed to take my time when reading them. The language isn't difficult to understand but they're extremely dense.
>>
File: at-night-spongebob[1].jpg (32 KB, 554x397) Image search: [Google]
at-night-spongebob[1].jpg
32 KB, 554x397
>>46460525
Programming a bacterial growth simulator...

...in Haskell.
>>
>>46462250
>public static List<String> pics,oldpics,newpics = new List<String>();
You're only creating newpics, pics and oldpics are null.

Out of curiosity, what's the type of pictures?
>>
>>46462923
Computer Organization and Design (the first one) is pretty neat, but Computer Architecture is really confusing.
>>
>>46462804
I don't know how it works to the hundreth percent, just that when I am shown code to malloc/realloc, to use it.

And why not?
>>
>>46463006
Look up sizeof in the structs chapter on K&R. The sizeof a struct may not always be the sum of the sizes of its members.

l is a shity variable name because it's a single letter (which means it doesn't tell anything about what's supposed to represent), and can be easily mistaken by a 1 or a capital i.
>>
>>46463091
I should probably make it CurLyr for "current layer" instead of l then.
>>
>>46462918
you're an idiot, it's 80 characters, has been since way before you were born.
>>
>>46460513
>>46460711
>not /dpt/ - Daily Programming Thread
>DPG in the file name instead of dpt (dpt in the file name would have compensated for the lack of /dpt/)
>same old unattractive anime character (is it a boy or a girl?)
>no link to the old thread
>no link from the old thread to here
>>
>>46462810
>>46462850
>>46463169
the 80 character max is deprecated as fuck. it was relevant when we used punch hole cards, and those were only that size because of the size of U.S. dollar bills a century ago. when you have 4K or 8K monitors in portrait mode, will you still only have 80 characters per line? just reduce the font size and have whatever width you want. don't force a bunch of line breaks that lack any semantics or short undescriptive line breaks just because you have some autistic idea in your head that it has to be less than 80 characters per line.
>>
>>46463312
>or short undescriptive line breaks
*or short undescriptive variable names
>>
>>46463312
>when you have 4K or 8K monitors in portrait mode, will you still only have 80 characters per line?
Yes because I want vertical splits of the same or another file, pdf or web browser on the side, etc.
It's also generally harder to read longer lines because it takes more effort to scan back to the beginning of the next one since the distance is so huge.
>>
>>46463312
>when
>implying I haven't had one for almost 3 years

anon pls
>>
GUYS GUYS!

I can't figure this shit out!

okay so I was in the other thread trying to screen out negatives through a while loop and I succeeded.

I said
while (entered_int < 0)
{
cout << " Please enter positive whole numbers only!"
cin >> entered_int
}
it works, but then I also have to screen characters!
so I used this loop
while(!(cin >> entered_int))
{
cout << " Please enter postive whole numbers only";
cin.clear();
cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
}

righ right! They both work, but heres the problem! I don't know how to combine both of these while loops to screen out either one.

I mean, I just wan thte user to input integers that are not negative or characters.... ugh! I'm almost done too.

can someone help me out really quick, please?
>>
>>46463634
Would this not work?
while(!(cin >> entered_int) && entered_int < 0)
>>
>>46463694
nope.

Its weird, this is what I'm trying to run now, but it screens out characters but when I input a negative integer, it just skips line on the command line

while(!(cin >> entered_int) || (entered_int < 0))
{
cout << " Please enter positive whole numbers only!!";
cin.clear();
cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');

}
>>
>>46463694
damn, i don't how, but I made it work lol!

I switched it up like this,

while((entered_int < 0) || !(entered_int))
{
cout << " Please enter positive whole numbers only!";
cin.clear();
cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
cin >> costumer_ID;
}

I'm lost as how this exactly works, but it does and I'm pretty much done with my assignment now.

so boss, so based!
>>
>>46463984
0
>>
>>46464004

The sum doesn't matter I just want the series.

I guess it makes a bit more sense if I write it down like this (0+1) - (1+2) - (2+3)...
>>
test
def rps():
import random
>>
>>46464181
>/g/ converts tabs to white spaces
Fucking dropped.
>>
File: visual-studio.jpg (31 KB, 640x249) Image search: [Google]
visual-studio.jpg
31 KB, 640x249
Hey /g/, a question

I am a JavaScript dev using GNU/Linux. I am generally OK with that since browsers work the same everywhere anyway.

Well, now I need to debug some C++ code that I need to get working, and I find all the debugging tools quite lacking. I found several gdb frontends, but they all either don't work or suck. (Especially compared to picture related.)

Nemiver sucks because it lacks even the most basic functions. Kdbg is KDE so it sucks by definition (it doesn't even run here, no idea why). Ddd is the only one that actually works but it has user interface from 1999.

Do I seriously need to learn GDB?
>>
>>46464214
well damn, it seems I really have to, since "GDB frontend" seems to be equated with "sucks and doesn't work"

fuck you Linus

I didn't pay for this
>>
does anyone know if there's a way in java you can pass a constructor for a class in a argurment for a method or constructor.
like instead of this
OnlineCourse java1 = new OnlineCourse("Java 1", "Davis", 125, startDate, endDate, "UTA", true, 12);

this
OnlineCourse java1 = new OnlineCourse("Java 1", "Davis", 125, Date(1,1,2015), Date(2,1,2015), "UTA", true, 12);
>>
>>46464685
just write "new", if memory serves me well (sorry, no java in some time)

so instead of
Date(1,1,2015)


write

new Date(1,1,2015)
>>
>>46464740
omg haha. awesome thanks
>>
Old fag lurker here.

Trying to learn C and machine code.
>>
>>46464810
Learn Javascript instead

node.js is the shit
>>
>>46464214

At my university, we have had to use GDB to debug executables with no source code and no debugging symbols as part of a required assignment for a systems programming class that is required for half of the classes in the computer science curriculum. Stop being a lazy shit and learn GDB already.
>>
>>46464880
But... but.. but I want to add breakpoints with a right click! I want to see stuff visually! Even fucking Turbo Pascal had this in the 80s.

This is so annoying.

Well of course I will have to learn this GNUshit, since I really need to get this code working. But I am slightly angry about it.
>>
>>46464962

The command to set up a break point is literally just fucking "b". Fuck your right click! If you can compile with a terminal, you can debug with one too. And if you can't compile with a terminal, fuck you, learn to do so anyways and roll your own makefiles.
>>
            floatBuffer.position(offset);
floatBuffer.put(verts, offset, length);
floatBuffer.position(offset);
Gdx.gl20.glBufferSubData(GL20.GL_ARRAY_BUFFER, offset*4, length*4, floatBuffer);
Gdx.gl20.glDrawArrays(GL20.GL_TRIANGLES, offset/6, length/6);
floatBuffer.position(0);


            floatBuffer.position(0);
floatBuffer.put(verts, offset, length);
floatBuffer.position(0);
Gdx.gl20.glBufferSubData(GL20.GL_ARRAY_BUFFER, offset*4, length*4, floatBuffer);
Gdx.gl20.glDrawArrays(GL20.GL_TRIANGLES, offset/6, length/6);
floatBuffer.position(0);


why the heck aren't these equivalent? the contents of floatBuffer are disposable (it doesn't matter if floatBuffer gets overwritten). the stuff gets drawn when the floatBuffer position is "offset" but not when it's zero. should these pieces of code be equivalent under these circumstances?
>>
>>46464995
Yeah make is cool, except for the stupid tabs (seriously, who decided that tab is OK but spaces are not. Even python with its whitespace love is better than that.)

It can get complex but it's still not the insane shit of autotools that only GNU people could think of

anyway I should really start learning it instead of sitting here
>>
>>46465028
actually it gets drawn but it never gets updated in the second case
>>
>>46465028
>Using weird lunix engines instead of native OpenGL
What's floatBuffer even supposed to be?
A VBO?
>>
noob question. why cant i use void function call in when doing cout?

void name ()
{
cout<<"Steve"<<endl;
}

int main ()
{
cout<<"This C++ program is written by " << name() <<endl;
system("pause");
return 0;
}
>>
>>46465087
java.nio.FloatBuffer

it's a multi-platform gaymen framework called libGDX. it's pretty sweet actually and OpenGL GL ES 2.0 should be implemented correctly.
>>
>>46465138
Java guy, never really coded c++ (and the << overloading is still breaking my heart) , but

 std::cout<<name() 


takes the result of name and puts it into cout. Result of name is nothing, it cannot put that into cout.

The fact that the side-effect of name() is printing "steve" into cout is another thing. But the result is nothing, you cannot put that into cout.

Change name() from void to string and return "Steve" from the function
>>

function min(a,b) {
if (a < b){
alert(a); }
else {
alert(b);} }



Is this clean code? I'm learning JavaScript and understand a lot of material, I'm just worried the code quality is disgusting...
>>
>>46465261
No, it's shit code.

Don't use alert unless you really really need to. Use console.log(...) for internal stuff/debugging, and for actual user interaction, just write that stuff onto the page. Alerts are ugly and stupid.

Don't use this weird style of closing braces. Some people would write it like this

function min(a,b) {
if (a < b)
{
alert(a);
}
else
{
alert(b);
}
}


Other people would write it like this

function min(a,b) {
if (a < b) {
alert(a);
}
else {
alert(b);
}
}


Some people (like me) like this


function min(a,b) {
if (a < b) {
alert(a);
} else {
alert(b);
}
}


No people write it like you. The point is - the closing brace should be on the same "level" as the opening one, so you can quickly look at it and see what belongs to what
>>
>>46465354
Fuck, the last one should be

function min(a,b) {
if (a < b) {
alert(a);
} else {
alert(b);
}
}
>>
>>46465354
Do the different styles have names? I think I'm going to go with that second format you showed.
>>
>>46465261
my god those brackets are disgusting
>>
>>46465362
Never mind, this one looks a lot better than those two others.
>>
>>46465138

One assumes you have the line

using namespace std;

at the top of the code.

You can't call the function like that. The function itself works best on a separate line, just use the "<< endl;" from the function to provide the character return.
>>
>>46460513

A binary parser in C++... Before I started learning C++, I wondered why anyone would bother with Java. And now that I've learnt a bit about the language, I think Java is an over complicated brick of shit. Take any given C++ library, and it's Java equivalent, and so long as you've grokked the basics, the C++ version will be far more legible than the bloated and over engineered Java equivalent.

It's not even funny, as there are a lot of Java builds out there.

I think Java took hold in the mid to late 90's, because the lecturers had not a clue about how to teach C++, and didn't want to admit it.
>>
trying to crawl facebook
>>
>>46465138

Add this

using std::endl;
using std::cout;

To the top of you file.
>>
>>46465383
Probably. There is something written in here

http://en.wikipedia.org/wiki/Indent_style#Styles

and people like to argue about this shit for hours but it's really aesthetics. What's more important in my opinion is to pick one style that's not totally insane and keep it consistent in the whole project. (Well not your style of course.)

Same with camelCaseStyleOfNamingProcedures() and underscore_style_of_the_same(). Just pick one and use it (and take into the consideration the conventions of the language.... underscore style in Java for example is stupid, while javascript has no conventions and every project is different)

I wanted to say something about spaces around === and + etc. but then I realized I am the worst offender of this since I put them randomly as I see fit so yeah, I will shut up about that, haha
>>
>>46465425
C++'s std might be nice, but if you take any other library written for the language, it will be just as complicated if not worse than the Java equivalent.

Part of this is due to how horrible C++ is as a language. There are so many rules and contradictions that have been tacked on over the years such that C++ is now nearly a sunk ship.

Java, however, was purposefully designed for stupid people, so the language itself is much simpler. A consequence, however, is that the libraries designed by Java developers are often horrendous.
>>
>>46465489
I feel like the perfect programming language would give you no stylistic choice in how you write your source code. Just think about how much productive it would make everyone.
>>
>>46465547
You mean python then?
>>
>>46465526
this

c++ has no design, it's just random things thrown together and not working that well

Java at least has a design. But as a result of that design, we got RequestProcessorFactoryFactory.
>>
>>46465555
There are still too many options.
def example1(a, b):
if (a + b) % (a - b) == 0:
return a
else:
return b

def example2(a, b):
return a if (a + b) % (a - b) == 0 else b

example3 = lambda a, b: (a + b) % (a - b) and b or a
>>
File: the fuk.jpg (79 KB, 640x434) Image search: [Google]
the fuk.jpg
79 KB, 640x434
>>46465028
i'm guessing that i have to keep a 1:1 copy of the GPU-side stuff in floatBuffer? this just goes against my previous conceptions of how this works. glDrawArrays doesn't seem to just work with whatever floatBuffer's position is, it seems like the position has to be exactly the same as the starting point of the destination in the vertex buffer object. so if i only want to create floatBuffer once then it has to be as large as the most memory the GPU will ever use?!
>>
>>46465526

I use the same rule of thumb as a use for any library or framework in any language. If key routines have stupid names, or if the tookit does nothing in particular, then I'll walk away.

This happens more often than not in Java, but less in C++. Javascript is going through a particularly interesting trend right now. It all started badly for Javascript, because the core library was stupid. Then JQuery came along (like Boost for JS), and people started to write some decent shit. The sheer genuis of JSON also helped a lot. Then the Java devs got hold of it, because they realized how stupid the JSF and GWT approach to web development was, and now, with the likes of Angular JS and Backbone, people are starting to write odd JavaScript libraries that have no specific purpose again.
>>
>>46465138

1. void has no return value. The << operator is going to two distinct objects on each end of it. One of the types it is overloaded for is std::ostream& and const char*, which returns another std::ostream&. So cout takes steve, returns cout is an example of this. Now, imagine if you had written this:

cout << "This C++ program is written by " << /* */ << end;


It's as if there was no expression there. That's because there isn't, because void isn't a type and doesn't return anything.

Also, stop doing system("pause"). Permanently.
>>
>>46465028
>>46465678
oh sweet baby jesus, i figured it out. floatBuffer.limit() - floatBuffer.position() was too big to fit in the memory allocated on the GPU side, so the buffering simply didn't happen. i'll just have to use floatBuffer.flip() before buffering
>>
>>46465592

This. Is exactly what I'm talking about.
Say what you like about C++ though, 'new' is preferable to 'malloc', vectors are better than C arrays, and 'String'. Well...

It can be better though.

Is Rust any good? And does Go compile proper binaries?
>>
http://pastebin.com/R9cm9Tzr

I've cleaned up my code from earlier, and it runs on ~7% CPU max now.

-I've ham'd up the image loading. There are loads of blank dictionaries contained in it. Will this cause performance issues at all?
-Is there any way I can make the button clicks (Lines 99-107, 129-139) any more efficient? Can't really iterate through a for loop for them, since they will each require a separate action.
-Is there much I can do about the blitting images to screen? There's enough variation in the statements (and there will be more once I add the other screens) that I'm not sure if there's a proper way I ought to be doing it, rather than just typing them out separately. I've done what I can see as being obvious with blit_standard(), but is there much else?

Will convert to a state machine once I've tidied everything up here.
>>
>>46465756
>vectors are better than C arrays
I respectfully disagree.
>>
>>46465800

I'd say I've got a lot to learn about C++ and C, so please enlighten me.

I'm at least sure that vectors will take up more memory.
>>
File: Untitled.png (13 KB, 660x260) Image search: [Google]
Untitled.png
13 KB, 660x260
>>46465724
>because void isn't a type and doesn't return anything.

Ahh so that's why.

>Also, stop doing system("pause")
ye ik. use cin.get().

I have another question. i have the code like this for now:

void name ()
{
cout<<"Steve Anderson";
}

int main ()
{
cout<<"This C++ program is written by ";
name();
cout<< " This is for CS200 with Prof Tim Blalala"<<endl;
cin.get();
return 0;
}


How can i get it to be a new line after i call my name() function? i want a new line starting with: This is for CS200 with Prof Tim Blalala
if i add an endl; to the name(); then the code doesnt work anymore
>>
>>46464168

Figured out the solution. It is (1 - (-1)^n(2n+1))/4

In case anyone wants to know wtf I needed it for, I wanted to make an IP list, starting with the closest IPs.

int aRange = ~subnet[3] & 0xFF;
int bRange = ~subnet[2] & 0xFF;
int cRange = ~subnet[1] & 0xFF;
int dRange = ~subnet[0] & 0xFF;
InetAddress[] addresses = new InetAddress[aRange + bRange + cRange + dRange];
int count = 0;

for(int i = 0 ; i <= aRange*2 ; i++)
for(int j = 0; j <= bRange*2 ; j++)
for(int k = 0; k <= cRange*2 ; k++)
for (int l = 0; l <= dRange*2 ; l++){
int first = (int) (1 - Math.pow(-1, i)*(2*i+1))/4;
int second = (int) (1 - Math.pow(-1, j)*(2*j+1))/4;
int third = (int) (1 - Math.pow(-1, k)*(2*k+1))/4;
int fourth = (int) (1 - Math.pow(-1, l)*(2*l+1))/4;
if ( first + (ipArray[0] & 0xFF)< 0 || second + (ipArray[1] & 0xFF) < 0 ||
third + (ipArray[2] & 0xFF)< 0 || fourth + (ipArray[2] & 0xFF)< 0)
continue;
try {
byte a = (byte) ((ipArray[0] & 0xFF) + first);
byte b = (byte) ((ipArray[1] & 0xFF) + second);
byte c = (byte) ((ipArray[2] & 0xFF) + third);
byte d = (byte) ((ipArray[3] & 0xFF) + fourth);

InetAddress addy = InetAddress.getByAddress(new byte[]{a,b,c,d});
if(!addy.equals(gatewayAddy) && !addy.equals(ipAddy)) {
addresses[count] = addy;
count++;
}
} catch (UnknownHostException e) {
e.printStackTrace();
}
}
>>
Learning Objective-C because work has an iOS app and it's either I learn to maintain it or we outsource it to some shitfucker who's gonna constantly ask me to make shitty changes to our backend to make his life easier.

Objective-C is a pretty weird syntax but conceptually nothing really new. I like ARC, I'm surprised this concept isn't used in place of GC by other languages. I also like the fact that any C code is legal code.

On the other hand, working on OSX is pretty terrible because I'm not used to it at all. Xcode is a shitshow of options and buttons. I don't generally like IDEs to begin with and this one is one of the least pleasant I've seen.

Oh and one thing that struck me as fucked was that calling a method on a null in obj C doesn't cause the program to crash or raise an error or anything. It just... does nothing? WTF is that? How is that better than crashing?
>>
You have 5 minutes to write a binary search for a sorted int array that returns the index of the found number, in any language of your choosing.

Go.
>>
My computer blue screend and now my IDE is broken. Wat do.
>>
>>46464962
eclipse debugger
>>
>>46466092
best practice would be to do:

string name = "Steve Anderson";
>>
>>46465821
vectors wrap around an array so you have minimal overhead
but the overhead doesn't matter in 2015
>>
Okay so my level works now that I got rid of the LVL struct. Layer and Object are their own independant structs now. Everything is like:
char *lvlName = NULL;
int lvlWidth = NULL;
int lvlHeight = NULL;

int numLayer = NULL;
int numTile = NULL;
int numObject = NULL;

struct layer *lvlLayer;
struct object *lvlObject;

When I deinitialize:
void lvlDeinitialize() { 
lvlName = NULL;
lvlWidth = NULL;
lvlHeight = NULL;
if( lvlLayer != NULL ) {
free(lvlLayer);
lvlLayer = NULL;
}
if( lvlObject != NULL ) {
free(lvlObject);
lvlObject = NULL;
}
}

When I initialize:
void lvlInitialize() { 
lvlName = NULL;
lvlWidth = NULL;
lvlHeight = NULL;
lvlLayer = (struct layer*)malloc( 1 * sizeof(struct layer) );
lvlObject = (struct object*)malloc( 1 * sizeof(struct object) );
}

Parsing them is the same more or less. One sublte memory issue, but I think it might have something to do with not freeing the tiles first.
>>
>>46466502
are you using C or C++
>>
>>46462250
>I have a problem with C#.
Everyone does, pick a better language.
>>
>>46466327
def bin_search(arr, val):
return bin_search_recursive(arr, val, 0, len(arr) - 1)

def bin_search_recursive(arr, val, begin, end):
if begin > end:
return -1
mid = begin + ((end - begin) / 2)
mid_val = arr[mid]
if mid_val == val:
return mid
elif mid_val < val:
return bin_search_recursive(arr, val, mid + 1, end)
elif mid_val > val:
return bin_search_recursive(arr, val, begin, mid - 1)

def unit_tests():
TEST_ARR = [0,1,3,6,8,14]
print 'running tests'
assert bin_search(TEST_ARR, 1) == 1 # finds in lower half
assert bin_search(TEST_ARR, 14) == 5 # finds in upper half
assert bin_search(TEST_ARR, -4) == -1 # under bounds
assert bin_search(TEST_ARR, 20) == -1 # over bounds
assert bin_search([1], 1) == 0 # works with array of one
assert bin_search([], 1) == -1 # works w/ empty array
print 'all tests pass'

unit_tests()


Always good to keep on your toes.
>>
>>46465425
right...


template< typename Arg >
class push_coroutine
{
private:
template<
typename X, typename Y, typename Z, typename V, typename W
>
friend class detail::pull_coroutine_object;

typedef detail::push_coroutine_base< Arg > base_t;
typedef typename base_t::ptr_t ptr_t;

struct dummy
{ void nonnull() {} };

typedef void ( dummy::*safe_bool)();

ptr_t impl_;

BOOST_MOVABLE_BUT_NOT_COPYABLE( push_coroutine)

template< typename Allocator >
push_coroutine( detail::coroutine_context const& callee,
bool unwind, bool preserve_fpu,
Allocator const& alloc) :
impl_()
{
typedef detail::push_coroutine_caller<
Arg, Allocator
> caller_t;
typename caller_t::allocator_t a( alloc);
impl_ = ptr_t(
// placement new
::new( a.allocate( 1) ) caller_t(
callee, unwind, preserve_fpu, a) );
}

public:
push_coroutine() BOOST_NOEXCEPT :
impl_()
{}

#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
#ifdef BOOST_MSVC
typedef void ( * coroutine_fn) ( pull_coroutine< Arg > &);

explicit push_coroutine( coroutine_fn fn, attributes const& attr = attributes(),
stack_allocator const& stack_alloc =
stack_allocator(),
std::allocator< push_coroutine > const& alloc =
std::allocator< push_coroutine >(),
typename disable_if<
is_same< typename decay< coroutine_fn >::type, push_coroutine >,
dummy *
>::type = 0);

>>
>>46460513
rewriting a simple php site in python with flask and eating banana chips
>>
>>46465592

I'm not really sure a language needs a design to be good. C++ might be a little inconsistent on syntax, but more or less, it does what it needs to do. It's "we need a language with the speed of a systems programming language and any and all features that might be more useful as a general purpose language."

>>46465821

Vectors shouldn't take up more memory per element, just a small amount of memory overhead for keeping track of length, capacity, and of course, a pointer to the first element, or something to that degree.

As for whether or not they are better... it depends upon whether or not you need a resizable array. If you don't, then just use a regular C array or an std::array. If you do, then std vectors are likely a better solution than rolling your own.
>>
>>46466520
C
>>
File: Untitled.png (28 KB, 657x307) Image search: [Google]
Untitled.png
28 KB, 657x307
>>46466443
Yea someone here said to use strings as well. I tried that but i kept getting crashes/ messed up outputs

string name (){
cout<<"Steve Anderson";
}

int main ()
{
cout<<"This C++ program is written by " << name() <<endl;
cout<< " This is for CS200 with Prof Tim Blalala"<<endl;
>>
>>46466667
is this what you want?

#include <iostream>
using namespace std;

void print_name() {
cout << "Steve Anderson" << endl;
}

int main() {
cout << "This C++ program is written by ";
print_name();
cout << "This is for CS200 with Prof Tim Blalala" << endl;
}


now who is >>46466666
>>
>>46466504
Poorly formatted and uncommented code is ugly and difficult to read regardless of what language you're using. I'm not at my desktop right now, but I'd bet that just running clang-format on that would make it much more readable.
>>
>>46464831

I shall commit to this Java you speak of.
Thanks for the input.
>>
>>46466327
Here you go.
def search(a, v):
if not len(a): return
l, r = 0, len(a) - 1
while r - l > 1:
c = (l + r) >> 1
if a[c] < v: l = c
else: r = c
if a[l] == v: return l
elif a[r] == v: return r
else: return
>>
>>46466327
int cmp(const void *a, const void *b) {
return *(int*)a - *(int*)b;
}

bsearch(target, array, array_len, sizeof(int), cmp);
>>
>>46466644
>it depends upon whether or not you need a resizable array. If you don't, then just use a regular C array or an std::array
9 times out of 10, you want to use std::vector. The only time you use anything else is when you're _absolutely sure_ that you need a statically sized array. If you're even a little bit unsure which one to use, use std::vector. It saves you the headache of retrofitting it later.
>>
>>46466092

>ye ik. use cin.get()
I highly recommend replacing it with nothing. Your program should terminate after producing its output.
>>
Why does Java need a special snowflake IDE just so I can use it's .jar library bullshit?
>>
Exe modification statically in C#
Small chunk. Actual code about 1000 lines.
public void RandomSectionNames(string path)
{
PeHeaderReader lolpe = new PeHeaderReader(path);
int numberofsections = lolpe.FileHeader.NumberOfSections;
FileStream fs = new FileStream(path, FileMode.Open);
BinaryReader br = new BinaryReader(fs);
BinaryWriter bw = new BinaryWriter(fs);
fs.Seek(0x3c, SeekOrigin.Begin); // go to the value of e_lfanew
int my_e_lfanew = br.ReadInt32();
fs.Seek(my_e_lfanew + 248, SeekOrigin.Begin);

for (int x = 0; x < numberofsections; x++)
{
byte[] NewSectionName = Encoding.ASCII.GetBytes(RandomString(8));
bw.Write(NewSectionName);
// section names 32 bytes apart
fs.Seek(32,SeekOrigin.Current);
}
bw.Close();
br.Close();
fs.Close();
}

public void NullifyMZHeader(string path)
{
FileStream fs = new FileStream(path, FileMode.Open);
BinaryReader br = new BinaryReader(fs);
byte[] nullmeout;
fs.Seek(0x3c, SeekOrigin.Begin); // go to the value of e_lfanew
int my_e_lfanew;
my_e_lfanew = br.ReadInt32(); // number of bytes to stop at
fs.Seek(2, SeekOrigin.Begin); // skip MZ bytes
nullmeout = br.ReadBytes(my_e_lfanew);
for (int x = 0; x < nullmeout.Count() - 2; x++)
{
if (x == 58)
{
nullmeout[x] = (byte)my_e_lfanew; // save the e_lfanew value (60 -2 for MZ)

}
else
{
nullmeout[x] = 0x00;
}
}

fs.Seek(2, SeekOrigin.Begin);
BinaryWriter bw = new BinaryWriter(fs);
bw.Write(nullmeout, 0, nullmeout.Count());
bw.Close();
br.Close();
fs.Close();
}
>>
>>46460513
Learning nim. Why does it produce such fuckhuge executables? The hello world program sems to compile into a program bigger than the compiler itself
>>
>>46466789
Get back to hackforums skid.
>>
>>46466602

Yes. Start your argument in the right place...

"Boost.Coroutine provides two implementations - asymmetric and symmetric coroutines.

Symmetric coroutines occur usually in the context of concurrent programming in order to represent independent units of execution. Implementations that produce sequences of values typically use asymmetric coroutines. [5]"
>>
>>46466667
Your name() function has no return. Your program is crashing because when it looks for a return and finds nothing there, it doesn't know what to do.

#include <iostream>
#include <string>

using std::string;
using std::cout;
using std::endl;

string name() {
return "Steve Anderson";
}

int main() {
cout << "This C++ program is written by " << name() << endl;
cout << " This is for CS200 with Prof Tim Blalala" << endl;
return 0;
}
>>
>>46466692
Yea. I want the output to look like that. However, instead of void i want to use string as ppl her suggested but even i try to do that my compiler crashes...

>>46466763
It (the window) doesnt stay open long enough for me to see the output. idk how to fix that
>>
>>46466767
Because java is shit, using IDE like intelliJ helps you forget about it
>>
>>46466767
you don't
describe your problem and i can help you

>>46466812
whats your point

>>46466815
technically there's a garbage pointer in %rax and you most likely don't have permission to access the data it points to
>>
File: 1284743204174.jpg (69 KB, 574x1293) Image search: [Google]
1284743204174.jpg
69 KB, 574x1293
>>46466811
>coding your own shit
>skiddy
sure thing bro.
>>
>>46466742

While I'm not actually sure as to the numbers on how often arrays may be wanted over vectors, I will have to more or less agree that vectors make for a good default, especially if you take advantage of using reserve to make push_back operations almost free.
>>
>>46466848
>re-coding a shitty packer
>deleting the header to hide imports
>c#
>thinks this is original and new and is worth re-doing

ok kid.
>>
>>46466327
define method binary-search
(array, value :: <integer>,
#key min-index :: <integer> = 0,
max-index :: <integer> = size(array))
=> (index :: <integer>)

if (max-index < min-index)
-1
else
let midpoint :: <integer> = floor/(min-index + max-index, 2);
case
array[midpoint] > value
=> binary-search(array, value,
min-index: min-index,
max-index: midpoint - 1);
array[midpoint] < value
=> binary-search(array, value,
min-index: midpoint + 1,
max-index: max-index);
otherwise
=> midpoint
end case
end if

end method binary-search
>>
>>46466829

Well for starters, you are running it wrong. It's a console application, so you run it in a console. And if you're running it from Visual Studio... fucking Ctrl+F5, you dolt!
>>
>>46466829
>It (the window) doesnt stay open long enough for me to see the output. idk how to fix that
That's actually Window's fault because it doesn't care about whether it should keep its window open long enough for you to read the output. If you run the program directly from cmd.exe (instead of clicking on the .exe), the terminal window will stay open after the program terminates.

Alternatively, you can write a .bat file that runs your program and pauses the terminal so that you can read it:

In the same directory as your program, open a text file and name it run.bat. Then put this in it:
@echo off
name-of-my-program.exe
pause


where you replace "name-of-my-program.exe" with the actual name of the exe you're generating. Then, you can click on the .bat file, and it'll run your program in a terminal window and ask you to press enter before closing it.
>>
>>46460513
Not doing currently, but I am going to release an album with haskore, a music library for Haskell
>>
>>46466846

> whats your point

RTFM.

You should only really need to look at the implementation if you're developing Boost, of performing a deep evaluation. I hate Java builds, because they often forget that libraries should be designed for their users first.

Hence this type of shit.

> Java at least has a design. But as a result of that design, we got RequestProcessorFactoryFactory.
>>
>>46466941

I thought if was a fucking joke too, but no. Here it is...

https://ws.apache.org/xmlrpc/apidocs/org/apache/xmlrpc/server/RequestProcessorFactoryFactory
>>
>>46466846
>technically there's a garbage pointer in %rax and you most likely don't have permission to access the data it points to
Yes, but that's an implementation detail I think he can go without. I didn't really want to explain what undefined behavior is and what most compilers' implementation of this code would lead to.
>>
>>46466815
Ty. Ik its a simple program but i def learned some stuff. Ty all for the help
>>
any cool open source android projects to contribute to?
>>
>>46467132
try my dick
>>
LEL the java haters from a few threads ago sure got told. i and a few others already pointed out these things but here:

http://programmers.stackexchange.com/questions/272433/why-instance-creation-is-the-way-it-is

>>46466767
there's nothing wrong with using an IDE you dunning-kruger afflicted elitist autist prick.
>>
>>46467152
>LEL the java haters from a few threads ago sure got told
and literally the only argument they had why java a shit was that you "repeat" yourself when instantiating things
>>
>>46466952
the idea of undefined behavior is important
he has to know that the computer can do anything it wants in this case including not immediately crash
>>
DPT, would it be at all advisable for me to get a teaching assistantship while doing my masters in comp sci?
>>
>>46461542
If the PHP version works, why bother re-writing from scratch? Unless the code is completely untenable due to terrible design, or it's a trivial amount of code, seems to me that you're spending a lot of time for relatively little gain.
>>
>>46467225
You get money, so yeah why not? (or at least reduced fees I think)

You can also make friends and what not with people that you'll be helping, is a way of networking, kinda.
>>
>>46461542

Purchase Burp Pro.
Run the automated shiznit.
Profit.
>>
so im taking my first computer science course and on one of these labs it says to
>Write a program to analyze the integers input by the user. Ask the
user to input positive integers one by one. If they input a -99 then
print the final results.

thats not the issue though. the issue is that it then says
>After every input, print all adjacent duplicates. For example, if the input is 1 4 4 5 6 7 7 7 1, the
program should print 4 7 7

how the fuck would i express that in pseudo-code? heres what i have of the code so far

Create PositiveCount as double = 0.0
Create NegativeCount as double = 0.0
Create ZeroCount as double = 0.0
Create CumulativeTotal as double
CumulativeTotal= CumulativeTotal + Input
Create Input as double
Write “Please enter an integer:”
Get Input
Write “Your cumulative total is:” CumulativeTotal
If (Input > 0)
PositiveCount = PositiveCount +1
Else (Input < 0)
NegativeCount= NegativeCount +1
Else (Input = 0)
ZeroCount= ZeroCount +1
Else (Input = -99)
Write “You had” PositiveCount “positives”
Write “You had” NegativeCount “negatives”
Write “You had” ZeroCount “zeros”
EndIf
>>
>>46467174
I agree that it's important for any competent C and C++ programmer to know what UB is and what kinds of code can lead to it, but he seems to be a beginner programmer, and it's not worth inundating him with information now because he'll just be discouraged from continuing the learning process. For someone in the middle of the learning process, it's more important that they aren't blocked with what they want to do, than that they learn all the details of the correct implementation because they're more likely to give up than go through the all the side-work.

Looking back, I probably should have told him that this situation is called "undefined behavior", and he could have Googled it later. That said, I think it's easier to tell a beginner "the program doesn't know what to do" rather than saying "your implementation elicits undefined behavior" because a beginner will more easily grok the first explanation, IMO. He can learn the full extent of UB after he understands the fundamentals of programming (for example, that non-void functions should always have a return statement).
>>
>>46467363
You need to keep a list of integers you've found to be adjacent, and an extra int to keep track of the previous number the user put in. Every time you read a number, check if it's equal to the last number they put in. If so, append that value to the list of adjacents. Finally, update the previous int value with the newly input value for the next iteration of the loop.

Does that help?
>>
>>46467363
>double
>integers
what even...

all you need is a PreviousNumber integer and a Duplicates array of integers. If PreviousNumber = Input Then Add Input To Array

then just print the array
>>
>>46460513
Just finished making a program in C that acts as a tunnel between two hosts. Let me simplify

>a normal connection

ANYDEVICE <-> WEBSITE/ANOTHER DEVICE

>using my program

ANYDEVICE <-> DEVICE RUNNING MY PROGRAM <-> WEBSITE/ANOTHER DEVICE

It stores the data from both sides and sends it on their way too
maybe i'll just use it to steal facebook passwords, or make a tor network clone...
>>
>>46467402
yes! this is awesome. thank you so much.

>>46467413
yeah, that was a stupid mistake. and thank you for the help, but we havent covered arrays, so i have no idea what that really means.
>>
>>46467472
>we havent covered arrays, so i have no idea what that really means
it's the same thing as what >>46467402 said with "list of integers".
>>
>>46467472
instead of an "array" you can just append the newly repeated number to a string, that way you can print it.

if(readNumber == previousNumber)
adjacentString + readNumber
>>
>>46467506
>>46467572
how would i make it write an integer to PreviousNumber though? what should i initially set PreviousNumber equal to?
>>
>>46467738
-99, since if that's the first number they enter it terminates anyway
>>
>>46466502
Don't set non-pointer variables to NULL. You also need to initialize lvlLayer and lvlObject:

char *lvlName = NULL;
int lvlWidth = 0;
int lvlHeight = 0;

int numLayer = 0;
int numTile = 0;
int numObject = 0;

struct layer *lvlLayer = NULL;
struct object *lvlObject = NULL;
>>
What's the best way to implement this line of Android code?

File coverimg = new File(files[i].getAbsolutePath() + "/cover." + "jpg" || "gif" || "png");


The above obviously does not work but I hope you get the idea. Basically I need a line that searches for a cover.jpg/cover.png/cover.gif and if it exists I'll have it print the path to it. Sorry I'm just super dumb and not sure what to search for
>>
>>46467417
you could have just said proxy
>>
>>46467872
>-99, since if that's the first number they enter it terminates anyway
If he does that, he'll have to be careful to make the -99 check in the loop before making the check for adjacent integers. Otherwise, he'll end up adding -99 to the list.

Personally, I'd just special case it and add a "is_first" bool. Sure it's an extra check, but with branch prediction, it's free anyway. Plus, I'd say it's easier to read since you don't have to understand that input ends on -99 to know that you're skipping the first number.
>>
>>46467915
Tunnel implies the connection is going through a secure channel or is side-stepping some sort of firewall. Proxy just implies that requests are being forwarded to a third endpoint.
>>
>>46467949
Its a proxy then, my program has absolutely no security
>>
>>46467872
>>46467923
so far, this is what i have:
Create PositiveCount as integer = 0
Create NegativeCount as integer = 0
Create ZeroCount as integer = 0
Create CumulativeTotal as integer
CumulativeTotal= CumulativeTotal + Input
Create Input as integer
Create PreviousInput as integer
Create AdjacentString as string
Write “Please enter an integer:”
Get Input
Write “Your cumulative total is:” CumulativeTotal
If (Input = -99)
Write “You had” PositiveCount “positives”
Write “You had” NegativeCount “negatives”
Write “You had” ZeroCount “zeros”

Else (Input > 0)
PositiveCount = PositiveCount +1
Else (Input < 0)
NegativeCount= NegativeCount +1
Else (Input = 0)
ZeroCount= ZeroCount +1
EndIf

i have no idea how to make the input check the previous input to see if its adjacent. its probably an if statement but i dont know for sure
>>
Is it worth going to a Uni/Tech School to learn programming?

What will land me a job in this field?
>>
I've been working on a video game and setup a gitlab server for it.

Guess I'm a git novice, but I let people push to master because I figured it would be easier for me to fix things than to teach others how to branch.

Someone ended up pushing a commit with no parents, and then merged our stuff into it, making it look like all the files got added again. Any ideas what he did? I'll ask him when I get ahold of him, but his English isn't the best, so I thought it'd be a good idea to ask here first.
>>
I have a for loop that goes 100 times and I'd like to generate a "phase" variable that goes from 0 to 0xffffffff within these 100 "steps"
>>
>>46460513
I'm still a beginner but currently working through Project Euler.
>>
>>46460851
Fucking Brilliant.
>>
GUYS I USED SOME RANDOM ASS FLAGS WHILE COMPILING C++ CODE.

now my compiler is giving my error code lines as hexadicimal, and it's compiling the code from a copy in my appdata folder not the regular directory.

is there a way to reset my compiler setting or what? shits getting annoying.
>>
Ive been trying to get an integer-only linear interpolation function working for days now and I am just not getting any luck.
How the hell did old microprocessors do it?

Just a simple god damn lerp function when 0.0 - 1.0 is mapped to 0x0 - 0xffffffff. with n o floats.

just integers.

how did the old rasterizers do it?
>>
>>46460851
Post the source.
>>
WHY THE FUCK IS MY COMPILER SHOWING LINE NUMBERS IN HEX NOW?
>>
>>46468753
>>46468562
What compiler? GCC, MSVC, or something else?
>>
>>46468787
gcc. i was trying to link a library because gdi32.lib is not being linked properly. i typed in some flags that people were suggesting using (via google)

and now my compiler is spitting out hexadicimal for line numbers.

i think i tried -lm? no idea what it did
>>
>>46468850
GCC only does what you tell it to do. Show your command line. Show us the output too.
>>
>>46468865
When compiling before it gave me line numbers in decimal not hexadecimal.

what it SHOULD be printing is.
[
input: g++ -o Driver Driver.cpp
output: C:/Programs/Project:Driver.cpp48:2: undefined reference to 'PatBlt@24'


what its doing ever since i tried with a -lm flag ONCE

input: same as above
output:
C:/Users/Mike/AppData/Local/Temp/ccNxAzi.o:Driver.cpp:(.text+0x156): undefined reference to 'PatBlt@24'

Collect2.exe: error: ld returned 1 exit status
>>
>>46468918
I don't see anything weird in that output. It looks completely normal. Those aren't line numbers, they're offsets; and they're supposed to look like that. Your "what it should be printing" is wrong. It can look like that, but it does not have to.

You're getting that error because the linker doesn't know where the function PatBlt is. That's a Windows GDI function, so you have to link with gdi32. That is, put -lgdi32 on the command line.
>>
File: 1421828075674.jpg (556 KB, 1198x1265) Image search: [Google]
1421828075674.jpg
556 KB, 1198x1265
>>46460513
What are some interesting short-term projects for me to do? I'm trying to get an internship but I have fuck all to put on a cv besides my current level of education
>>
>>46468971
nigga you dont understand. it doesnt matter what it can and can't look like

IT LOOKED LIKE THE TOP
NOW IT LOOKS LIKE THE BOTTOM

HOW THE FUCK DO I GET THE TOP ONE BACK?
i don't even care about the linker error anymore. i want my compiler debug messages appearing how they used to. my point is for weeks my output compiler code has looked like the first one. then all of a sudden one setting is changed and its permanently different?
>>
>>46468994
What does it matter how the message looks like? The latter error is reported by the linker, it does not have access to the source code, it does not know anything about line numbers. It only knows offsets. You get the former error from the compiler if it can detect the error and can pinpoint the exact location of the problem. The compiler has access to the source code.

I can also tell you that adding -lm to the command line has nothing to do with your problem.
>>
>>46469161
Then don't read the hexadecimal part. You don't need that right now. The relevant part is

undefined reference to 'PatBlt@24'


Everything else is just noise you can ignore.

Your compiler will give you the error message when it can. Why it reported the missing function earlier and now doesn't, I don't know. It's not my machine, I don't know what you've done. You will get error messages with line numbers and even column numbers when the compiler can give those. When it can't, the linker will complain, but with offsets. Live with that.
>>
>>46465383
That style is OTB (one true brace) and it is programming style masterrace
>>
>>46466829
You can just out #include <string> at the top then change the return type of the print function to string. Then in the function return whatever string you want. To print you can then use cout << print_whatever()
>>
>>46462250
Fix your formatting first. It's atrocious, told you yesterday.
>>
>>46462250
Also, calling Exists before CreateDirectory is redundant.
And finally, what is this infinite loop Check business? Are you checking the folder for new files? If so, https://msdn.microsoft.com/en-us/library/system.io.filesystemwatcher(v=vs.110).aspx
>>
>>46462933
4chan pics :p
>>
>>46466742
There's only one person I know who types like that. Back to teaching Hyatt.
>>
File: 1421595810567.jpg (71 KB, 356x427) Image search: [Google]
1421595810567.jpg
71 KB, 356x427
this is a test
>>
Can someone post the programming language choice flow chart.
>>
Someone knows a good design pattern tutorial about MVC ?
>>
File: 1421210166027.png (1010 KB, 2000x2210) Image search: [Google]
1421210166027.png
1010 KB, 2000x2210
>>46470615
>>
>==25625== ERROR SUMMARY: 2292722 errors from 26 contexts (suppressed: 0 from 0)
>>
>>46470659
Jesus Christ this chart is out of date by like 5 years.
>>
>>46470673
It's pretty silly to begin with
>>
Wow, fuck reddit.

I make a thread asking for help, because books and I do not mix well when it comes to learning/retaining, and I get downvoted.

Seriously.

Fuck them. I asked if there is any good C++ tutorials out there, in video form
>>
>>46470718
Probably because it's been asked a million times before. Use the search option before starting a thread.
>>
>>46470659
>no lisp
>>
Anyone here experience with MVC in PHP? Trying to write a CMS but have no idea how to start.
>>
I am learning ia-32 asm and am now trying to traverse a linked list.
I don't really know how, though.
Each node has a 32 bit number and the 32 bit address of the next node directly following.
I've got the address of my first node in eax.
Getting the first number is easy and to get the address of the next node I just add 4 to eax (address is directly following, so 4 byte after start of number). Now eax is the address of my next address.
But how do I get the actual next address into eax?
mov eax, [eax] doesn't seem to work
>>
>>46471000
1. Build a time machine
2. Travel back to 2001
3. Build a CMS with PHP.
You're welcome.
>>
>>46471199
I already have my CMS, but it is unstructured and based on if else statements (80 LOC). Thought MVC would be a good way to structure it and maybe implement a backend and a plugin system.
>>
whats some useful stuff to make in C? things like a linked list and other utility things
>>
I made a batch script to encode videos using x264.exe, so I can queue encodes up
@echo off
setlocal EnableDelayedExpansion
set n=0
set tune[0]=default
set tune[1]=film
set tune[2]=animation
set tune[3]=grain
set tune[4]=psnr
set tune[5]=ssim
set tune[6]=fastdecode

:selectFiles
set /a n+=1

:inputFile
set /p inFile[%n%]="Input file %n%:"
if not exist "!inFile[%n%]!" goto inputFile

:outputFile
ver > nul
set /p outFile[%n%]="Output file %n%:"
echo !outFile[%n%]!| findstr /r /c:".*\.mkv$" /c:".*\.mp4$" /c:".*\.264$" /c:".*\.flv$" > nul
if %errorlevel% neq 0 goto outputFile

echo.
echo Tune encode for !inFile[%n%]! as:
for /l %%i in (0,1,6) do echo %%i. !tune[%%i]!
:tuneSelection
set /p j="Selection: "
if not %j% geq 1 goto tuneSelection
if not %j% leq 6 goto tuneSelection
set tuneFile[%n%]=!tune[%j%]!

:chooseMore
echo.
set /P choice="Choose another file? [Y/N] "
if /I "%choice%" equ "Y" (
call :listFiles
goto selectFiles
)
if /I "%choice%" equ "N" (
if %n% neq 0 goto execute
if %n% equ 0 goto end
)
goto chooseMore

:execute
call :listFiles
for /l %%i in (1,1,!n!) do (
@echo on
@if %%i neq 1 @echo.
@echo ##### Encoding first pass of '!inFile[%%i]!' to '!outFile[%%i]!' #####
x264.exe --quiet --preset veryslow --tune !tuneFile[%%i]! --pass 1 --bitrate 2500 --stats "D:\Encodes\!outFile[%%i]!.stats" --output NUL "!inFile[%%i]!"
@echo.
@echo ##### Encoding second pass of '!inFile[%%i]!' to '!outFile[%%i]!' #####
x264.exe --quiet --preset veryslow --tune !tuneFile[%%i]! --pass 2 --bitrate 2500 --stats "D:\Encodes\!outFile[%%i]!.stats" --output "D:\Encodes\!outFile[%%i]!" "!inFile[%%i]!"
@echo off
)
set n=0
goto chooseMore

:listFiles
cls
if %n% neq 0 (
echo Files to encode:
for /l %%i in (1,1,!n!) do echo %%i "!inFile[%%i]!" --^> "!outFile[%%i]!"
echo.
)
GOTO:EOF

:end
pause
>>
>>46471401
A linked list is a good idea. Write your own stack. Make things like that, it will help you to learn a lot about these structures.Only if you want to learn more about things like that
>>
Is it possible to make a firefox addon which upon right clicking a link, allows a "Open link location in mpv."?

Is it possible to launch other programs from a firefox addon?
>>
I MADE THIS FUCKING AWESOME PROGRAM!!!
#include <stdio.h>
int main(int * argc, char * argv[])
{
char fil[1024], nam[10];
int len, wid,a,b,c, cou=0;
srand(time(NULL));
len = 500;
wid = 500;
while(atoi(argv[1]) > cou)
{
a = rand() % 255;
b = rand() % 255;
c = rand() % 255;
sprintf(fil, "<svg>\n<rect width=\"%d\" height=\"%d\" fill=\"rgb(%d, %d, %d)\"/>\n</svg>", len,wid, a,b,c);
FILE *f;
sprintf(nam, "%d.svg", cou);
f = fopen(nam, "w");
fprintf(f, "%s", fil);
fclose(f);
memset(nam, 0, sizeof(nam));
memset(fil,0,sizeof(fil));
cou++;
}
}


Yeah memset because i have worked far too long with low memory bullshit.
>>
File: rbouRsp[1].png (12 KB, 1916x999) Image search: [Google]
rbouRsp[1].png
12 KB, 1916x999
Working on this
>>
>>46471455
stack sounds interesting, thanks
>>
>>46471473
Worked it out. You have to download this addon

https://addons.mozilla.org/en-US/firefox/addon/open-with/

Then create shell script at /usr/bin/mpvy

#!/bin/bash
mpv $( youtube-dl -g $1 )


Make it executable

chmod +x /usr/bin/mpvy


Then open about:openwith and add it as a command. Fiddle with the settings to get it to appear where you want.

>Why both coding when the job is done
>>
How do I make programs that automate sending or posting messages on websites?
>>
>>46466705
Top Kek
>>
Learning java and have a more work ethic regarding question:

How can you do your job without caffeine?
Or without food breaks?
How can you convince your colleagues that their lifestyle and your company's recess ethic and party mentality is very detrimental to your Health and can't join in all the time?

I heard that people are just intermittently fasting to ensure nothing wrecks havoc on their bodies until after work and a heavy workout, where they eat normally.
And they take whole naps.

How can I convince my employer that taking a good sleep as a flexible recess is better than a fixed one?
>>
Hey if any of you want a laugh check this link
http://www.cplusplus.com/forum/beginner/155946/
Jesus...
>>
File: mcmahon.gif (2 MB, 200x150) Image search: [Google]
mcmahon.gif
2 MB, 200x150
>>46472275
>>
>>46472275
>Click on link
>if(a=a,b=b,c=c,d=d,e=e,f=f,g=g,h=h,i=i,j=j,k=k,l=l,m=m,n=n,o=o,p=p,q=q,r=r,s=s,t=t,u=u,v=v,w=w,x=x,y=y,z=z)
Thank you America, you scammed another CS major.
>>
>>46472275
I refuse to believe this isn't a troll.
>>
>>46472318
yeah, it must be..
>>
>>46460513
Help
why my code still giv error in
if (m[j] == m[i])
"cannot implicitly convert type double to in "
 public static double moda(double [] m)
{
double maxVal = 0, mC;

for (double i = 0; i < m.Length; i++)
{
double c = 0;
for (double j = 0; j < m.Length; j++)
{
if (m[j] == (double)m[i])
{
mC = c;
maxVal = m[i];
}
}
}
return maxrVal;
}
>>
>>46472332
Why are you making your for loop indices doubles? Just do int.
>>
>>46472275
I've always done everything by myself when learning to program.
Seriously, is was like 15 and no one around me knew anything about programming, and I was to afraid / did not know how to ask questions on the internet.

This is why I refuse to help some people with things that they can solve themselves after spending enough time with the problem. If that guy spend an hour researching by himself he could have figured it out.
>>
>>46472332
double maxVal = m.Max();
>>
>>46472348
ok i will do
thnks
>>
>>46472416
what?
why double maxVal = m.Max()
>>
>>46468045
im back. can anyone help me out?
>>
Now i got BASS in my nazi MLG pong.
>>
>>46472475
I figured finding the max value is what you were trying to achieve.
>>
>>46472502
I'm looking for the number that is repeated more times
>>
>>46472567
Dictionary<double, int> count = new Dictionary<double, int>();

foreach (double d in m) {
if (count.ContainsKey(d))
count[d] += 1;
else
count[d] = 1;
}

double max = count.Aggregate((a, b) => a.Value > b.Value ? a : b).Key;
>>
>>46472666
>using the wrong bracing style
>not using var
Nice solution otherwise.
>>
>>46472366
this. even if you spoon feed some of these people with the exact same solution that worked for you, they'll put about a thousandth of the effort you put into writing the answer (let alone finding out the solution in the first place) and decide that it didn't work. stupid, lazy, unpassionate, ungrateful cunts.
>>
>>46471519
it's shit
>>
>>46462869
Either you use a C++ compiler for a C source, and you are retarded.
Or you use malloc in a C++ program, and then you are even more retarded.
Go die in a fire faggot.

>>46462883
Exact. Except, you don't use malloc in C++.
>>
i want to make a code that's count the numbers between what the user entered in python .. im gussin i should use xrange or while but i have no clue how to start
>>
>>46472835
Subtraction. Do you even kindergarten level math?
>>
>>46472799
Not that guy but using gcc -std=gnu99 will give you a warning for not casting a malloc
>>
>>46472835
for n in xrange(number1, number2):
print(n)
>>
>>46472867
neither c89, c99, c11, gnu89, gnu99, or gnu11 gives me a warning with -Wall
>>
>>46472666
>>46472332
Pure LINQ solution (assuming m is non-empty for simplicity):

private static double Mode(IEnumerable<double> m)
{
return m.GroupBy(x => x).OrderBy(x => -x.Count()).First().Key;
}
>>
>>46472867
Bullshit.
>>
>>46472883
this is what i mean now how do i make number 1 and number 2 choosable by the user ? like "choose a number to start counting from " and " choose another number to end " also how to add an error massage in case of picking a letter ?
>>
>>46472912
Why is this deleted
>>
>>46472789
AHHAHAHA
ITS BIG BROTHER IS HERE
SAY THAT TO HIS FACE IF YOU DARE!!
(its pretty fun to generate images actually..)

http://pastebin.com/dk8NHyEH
>>
>>46472933
if you are using Python 2:
number1 = int(raw_input("choose a number to start counting from: "))


if you are using Python 3:
number1 = int(input("choose a number to start counting from: "))
>>
>>46472992
thanks alot im using python 2 i did the exact same thing except int .. do you mind explaining it how it work and whats it propose ?
>>
>>46472933
def ask_number(s = "Enter a number"):
while True:
try:
return int(raw_input(s))
catch ValueError:
pass
>>
Alright, guys, I'm working on a school project about NFAs.
My partner is handling conversion to DFAs, and had some old code from his last attempt.
I'm trying to fix the intersection between two DFAs, and it's not working out too well.

The approach the code takes is:
Keep a counter for the 'current' node.
For every node in a2: = n2
For every node in the current automaton: = n1
First, add a node in the new automaton, with the same 'order' (start | finish | etc) as the intersection of n2 and n1.
If no special intersection is found, it's just a normal node.
This seems to work, as far as I can see.
For every edge that starts in n2: = e2
For every edge that starts in n1: = e1
if the values are the same:
add a new edge from this node, with that same value, to another node with id 'n2.id * nodes in n2 + n1.id'
else:
add a new edge with the same value as e1 that goes to n1.id
add a new edge with the same value as e2 that goes to 'n2.id * nodes in n2 + n1.id'.


This doesn't work. Could someone explain to me what I'm doing wrong, please?
>>
>>46473018
converts the text "1234" to the number 1234
>>
>>46473052
it gave me an error at "catch" as invalid syntax
>>
>>46473090
sorry, confusion. Replace the "catch" with "except".
>>
>>46473101
okay im trying it your way atm and this is what i wrote

def ask_number(s = "Enter a number"):
while True:
try:
return int(raw_input(s))
except ValueError:
pass

def ask_number2(s = "Enter a number"):
while True:
try:
return int(raw_input(s))
except ValueError:
pass
for n in xrange(ask_number, ask_number2):
print(n)


and this is the error i got

 File "E:/paython/test", line 14, in <module>
for n in xrange(ask_number, ask_number2):
TypeError: an integer is required
>>
>>46472835


num1 = raw_input(': '))
num2 = raw_input(': '))

try:
for x in range(int(num1), int(num2)):
print x
except:
print 'Invalid'

>>
>>46473153
for n in range(ask_number("lower limit ? ="), ask_number("higher limit ? =")):
>>
>>46473153
Make a main() function, then save your two numbers in the main function by running the 2 other functions.


def main():
num1 = ask_number
num2 = ask_number2
for n in xrange(number, number2):
print n

>>
>>46473195
Sorry I totally fucked that up:


def main():
num1 = ask_number()
num2 = ask_number2()
for n in xrange(num1, num2):
print n



I should proofread better.
Thread replies: 255
Thread images: 17

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.