[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: 33
File: trap programmer.png (1 MB, 1702x2471) Image search: [Google]
trap programmer.png
1 MB, 1702x2471
Old thread: >>51660640

What are you working on, /g/?
>>
everyone report OP for being a subhuman
>>
Gotta Go fast.
>>
>>51668809
writing some really basic text layout stuff
why is this so impossible

unicode is retarded
>>
>>51668809
>What are you working on, /g/?
My local GPU to remote GPU RDMA benchmarking program.
>>
For a string reverse function, is it better to manipulate the char array in place or return a char array?
>>
>>51668874
It depends what's the most desirable, space effectiveness or immutability
>>
>>51668874
Depends on the use case. Memory wise, use in place.
>>
How do you prepare for a job that uses an in house language?
>>
>>51668829
Fuck off back to reddit, normie.

If you were looking for a wholesome, Christian imageboard, this sure as fuck ain't it. OP is just doing his small part to help keep it that way.
>>
>>51668918
>muh degeneracy
>>
>>51668917
With caution

In-house languages are a huge red flag, but many companies do them for some reason.
>>
>>51668809
kill yourself faggot
sage
>>
>>51668917
>in house language
Sounds like a place where you don't want to work. You'll be learning a useless skill.
>>
File: 1415885290506.gif (573 KB, 270x150) Image search: [Google]
1415885290506.gif
573 KB, 270x150
just sent out my first invoice as a freelancer.
feels good man
>>
How would I write this <installStep name="Custom"> </installstep> using XDocument in C#. I can't seem to find anything on it.

it'd follow that if i used new XElement(@"installSteps order=""Explicit"""

i'd get <installStep name="Custom"> </installStep name="Custom">
>>
Newfag here.
I made a new project, hooked up main.cpp, and a library .cpp + .h files, but when I hit F5, it says Build Successful, but then I can't click anything in Visual, the debug window doesn't show up, and I can't nuke the .exe from Task Manager.
Do I need Source.cpp or something? How do I hook main.cpp to it?
>>
>>51669141
Are you sure the application doesn't instantly exit?
>>
>>51669133
Woops, copied two different things there, been at it for hours I'm knackered.

I'm surre you understand what I mean though
>>
>>51669168
It doesn't. I don't see anything flash for even a split second, and the VS window just doesn't respond to anything (Windows doesn't think it's "Not Responding" though). On top of that, when I close VS with task manager, there are still two debug.exe files in there, that I simply cannot close.
>>
>>51669199
infinite loop maybe?
>>
>>51669211
I've got a do while loop that reacts to keypresses, but it should still compile properly and display a debugging window.
>>
node isnt actually as bad as I thought it would, at least in the node-webkit context
>>
>>51669231
Try putting in a sleep delay in your do while and see if you get a window then
>>
>>51668918
are you fucking stupid you redditard. sjw normalfags support the tranny movement. if anything, you're encouraging more normalfags onto this board
>>
>>51669257
And even worse, faggots.
>>
File: 1433989696344.jpg (16 KB, 300x467) Image search: [Google]
1433989696344.jpg
16 KB, 300x467
I'm the guy who wanted to make that IRC bot that scrapes information from a website

turns out while the website has an API there's no API for the specific page I want so I'm fishing for stuff with Html Agility Pack and I want to kill myself
>>
>>51669263
and even worse, gay faggots
>>
>>51669355
and even worse, women
>>
>>51669253
I think my Visual is acting up. I made a new project to output Hello World and same shit is happening.
>>
>>51669374
and even worse, aliens
>>
>>51669379
>i'm a retard who can't into developing or configure my IDE properly
>it's obviously the IDEs fault
>>
>>51669393
Wow rude. Well then, what's your suggestion in this case, mr. dicksuck?
>>
>>51669407
Make Visual Studio run the application in CMD.
>>
First for Visual Studio is shit
>>
File: a ruff victory.jpg (65 KB, 500x368) Image search: [Google]
a ruff victory.jpg
65 KB, 500x368
First for /ruff victory/
>>
>>51669434
Second for kill yourself furfag. Pets are disgusting and a waste of time.
>>
>>51669434
>/dog petting thread/

Today my teacher was joking about D.
Do you think he also browses /g/dpt or is it just a common thing
>>
I'm kinda confused about returning char arrays.
I'm trying to make a strrev function that returns a char array, but apparently, I'm not allowed to return a local char array, so I had to malloc it.
How am I supposed to free the memory?
This is gonna cause a memory leak every time it's run.
char *strrev_r(char *arr)
{
unsigned len = strlen(arr);
char *tmp = (char *) malloc(sizeof(char) * len);
unsigned i = len - 1;
unsigned j = 0;
while (i >= j)
{
*(tmp+j) = *(arr+i);
j++;
i--;
}
return (char *) tmp;
}
>>
>>51669476
Welcome to C.
>>
File: quite a ruff victory.jpg (46 KB, 653x510) Image search: [Google]
quite a ruff victory.jpg
46 KB, 653x510
>>51669450
Think about all the disgusting shit humans do.
I'm also not a furfag, just recognizing the superiority ruff victories have over shitpaws

>>51669452
Possibly. Post pictures of dogs and ask him which was his favorite tomorrow.
>>
>>51669452
also
http://strawpoll.me/6161383
>>
>>51669476
>This is gonna cause a memory leak every time it's run.
Just call free.

Anyway, you should do this instead

void strrev_r(const char* string, char* destination)
{
size_t i = 0;
while (*string != '\0')
{
destination[i++] = *string++;
}
destination[i] = '\0';
}

int main()
{
char string[] = "Hello, world!";
char reverse[sizeof(string)];

strrev_r(string, reverse);

printf("The reverse of '%s' is '%s'\n", string, reverse);
return 0;
}
>>
>>51668918
Anime is degeneracy because it encourages acting like a subhuman. When nazism returns, anime will be banned.
>>
>>51669553
Too bad /pol/, nazism will never return.
>>
>>51669497
I'm being serious.
I would have to assign it's output to a pointer and then free that pointer in order to free the memory, and i'm gonna create a new variable for every reversed string, I might as well reverse the original string in place.

>>51669543
case in point
>>
>>51669571
yes it will, someday the white race will wake up. Animefags will face the rope like bronies and other degenerates will.
>>
>>51669575
>case in point
That's not in-place reversal though (I'm copying it to another pre-allocated array).

Actually, I'm a complete retard. I'm not reversing the string at all.
>>
File: 1446664051143.png (21 KB, 500x500) Image search: [Google]
1446664051143.png
21 KB, 500x500
What's so attractive about Javascript? It seems everyone at my CS course is going for it. [spoiler]It's just a meme, isn't it?[/spoiler]
>>
>>51669640
It's actually a pretty good language
'x is a meme' is a meme
>>
>>51669575
Well what your asking for is to take a string and return a reversed copy without ever allocating memory for it? The new bytes have to live somewhere..

You've got 3 options, reverse in place, call malloc and return a pointer, or pass in a pointer to store the reversed string as a function parameter.
>>
>>51669640
>allowing 4chan to influence your opinions
>>
Currently I am failing at wrapping my head around Javascript for a project. All the sources I look up are just copy+paste directly into your code and I was actually trying to figure out how much MUST be there. I'd prefer to just call up the script from a library if possible.
>>
>>51668809
Faaaaaaaaagggggoooooooottttt
>>
>>51668809
Have to work with Racket because of uni. How bad is it?
>>
>>51669817
DOA.
>>
someone help pls
if i have 2 tables and if i delete from table1 1 row then all rows of table1 should be deleted, furthermore if i delete from table2 1 row then all rows from both tables should be deleted

how do i formulate the constraint ?
>>
>>51669826
Make the primary key of table 1 a foreign key of table 2 and make deletion cascade.

Don't remember the syntax because I haven't written a line of SQL since 2008 or 2009.
>>
>>51669826
>>51669798
>vague questions
>no code
>lots of assumptions
India?
>>
>>51669826
Constraints only matter when putting stuff to the DB, you need to manually delete stuff.
>>
>>51669967
thinking of using deletion cascade as >>51669826 mentioned
>>
I started reading some Java code. Then I saw this:

private static final Logger log = LoggerFactory.getLogger(LoggerController.class);
>>
>>51670190
Classic Yava,
>>
>>51669874
 
create table t1(id int);
create table t2(id int);

alter table t1 add primary key (id);
alter table t2 add primary key (id);

alter table t1 add foreign key(id) references t2(id) on delete cascade;
delete from t1 where id=1; --should delete all rows from t1, not drop table
delete from t2 where id=1; -- should delete rows of t1 and t2, again not drop table
>>
>>51670190
Can someone explain the purpose of factories and beans and factory beans.
They all seem to just be shitty constructors
>>
How do I add a clock to my C++ program?
I'm working on a Tetris and I want it to count time since game started.
>>
>>51670480
You'll want to get a time or deltatime library
>>
>>51670470
http://www.tutorialspoint.com/design_pattern/factory_pattern.htm
>>
>>51670470
Factory is the OOP interpretation/bastardization of a closure that creates new objects.

Bean is Javaspeak for a class that only does aggregation, exposes get/set methods instead of just public variables, and is serializable.
>>
Why is codeeval so shit?

This is the same solution submitted 7 times and the execution time/memory size varies wildly.
Doesn't this lead to people gaming the submission form in order to get a better score?
>>
>>51670525
>http://www.tutorialspoint.com/design_pattern/factory_pattern.htm
>In Factory pattern, we create object without exposing the creation logic to the client
To what purpose
>>
>>51668829
How new are you that you don't see an OP like this and go "yup, pretty much what I expected."

I miss fez + SICP girl though. Stupid thread wars.
>>
>>51670666
What the fuck are you doing so horribly where /C/ is using that much fuckin' memory? I don't think I have ever even surpassed 1000 bytes.
>>
>>51670707
i'm not
it's their stupid algorithm that thinks every realloc counts toward the resident size of the program.
>>
>>51670723
post code immediately
>>
>>51670666
>Why is codeeval so shit?

Why bother with it? Why not hone your skills with personal projects that actually achieve some goal?

Codeeval and other similar sites are worse than just wasting your time jerking off.
>>
>>51669543
Does this work?
sizeof(string) should be of size size_t and not the length of the array iirc
>>
>>51670683
In rare cases, it's useful or even necessary to have creation logic in an initialization method, outside the constructor. Factories wrap it up into a single method, and act as first-class functions in languages that don't natively support them (e.g. Java).
>>
>>51670731
i'm learning to program by doing the challenges

>>51670729
no
>>
>>51669640
Functional language with closures done right is part of why I like it.
>>
>>51670761
re: horribly.
>>
>>51670746
>Does this work?
No it only copies the array, I forgot to reverse it.

>sizeof(string) should be of size size_t and not the length of the array iirc
No, sizeof(size_t) will return 4 or 8 (depending on the implementation. sizeof(string) will return number of chars in string.
>>
Trying to do this in java: http://pastebin.com/KasBUEUv

I'm an awful programmer and it's not going well. I'm having trouble turning that string of ints into a maze and I need to finish this to pass the class.

Might post later if I manage to get something functional, though I doubt anybody cares. How do you guys post code blocks?
>>
>>51670470
> Can someone explain the purpose of factories
The purpose of factories is to create objects. The main reason for using a factory rather than a constructor is that a factory can return different types of object depending upon parameters or state, whereas a constructor can only return an instance of the class on which it is invoked. A secondary reason is that it allows the construction process to be split across subsystems; one subsystem can create a factory to create objects with certain parameters pre-determined, then pass it to another subsystem which only needs to provide the remaining parameters to create a specific instance.

> and beans
JavaBeans is a component model. A Bean is a component: something which provides generic methods to set/get properties, send/receive events, interactively configure instances, save/load configuration, etc. The idea is that you can write code which can interact with any bean, with the details being a matter of configuration (i.e. you don't need to modify the program to use additional types of bean). E.g. Java Server Pages (JSP) can access beans without needing to extend the JSP interpreter for each new type of bean.
>>
>>51668809
I'm in the final testing phase for a new VCM tool that I've spent the last year building myself, funded by a oil and gas co :) First of its kind to :)
>>
>>51670761
>i'm learning to program by doing the challenges

Get some good books, instead.
>>
>>51670789
>How do you guys post code blocks?
use this:
[homework]....[/homework]
>>
>>51670844
Get some good taste in women.
>>
>>51670864

While my taste in women might be shit, it's nowhere near the slum-level of programming challenge websites.
>>
>>51670986
I hope you're not including based euler in that
>>
>>51670845
test
did it work?
>>
>>51668809
in my 8 years of browsing this shithole, i think this is the stupidest picture i have ever seen

reported
>>
>>51670995
Euler isn't for programming it is for mathematicians (((^:^)))
>>
>>51670864
>3DPD
>ever
Never, SENPAI
>>
>>51670995

Euler is a lot more math than it is programming.

Besides, the obvious solution is to brute force everything :^^)^)^))^^))))^))^)
>>
>>51669520
>STILL NO FUCKING STICK AND ROCK
>>
>>51668874
Always in place, heap allocations are expensive.
>>
>>51668874
Either do it in place or get the user to hand you a buffer. Don't do the allocation yourself.
>>
>>51671100
>performance

literally the least important aspect for 99% of code
>>
Fuck off dog posters
>>
>>51671098
Same poll I'm sorry :(
>>
>>51671047
It's still targeted at programmatic solutions.
>>
>>51670480
How are you planning on building a game without any timing functions in the first place?
>>
>>51671132
That's because no one gives a shit about or will ever use the software you write.
>>
>>51671134
you're posting in a /dog petting thread/
>>
I want to load data like below from a file.

[variable] = 1
0100
2101
0101
0210

The variable would be read first, and then the numbers loaded into a two-dimensional array. Any tips how to pull this off?
>>
>>51671612
I guess I could start by mentioning language I'm writing this in.
C++
>>
>>51671149
> It's still targeted at programmatic solutions.
Sure. But a naive (i.e. brute-force) approach to anything except the first few problems will typically take years if not millennia. To get an answer in a reasonable amount of time typically requires applying knowledge of mathematics rather than knowledge of programming.

The few problems which don't involve math generally require knowledge of specific topics from theoretical CS (e.g. adaptive programming, linear programming) rather than a general ability to write efficient code.
>>
>>51671000
Trips don't lie
>>
>>51671612
>>51671651
In pure C, you would use fgets+sscanf to retrieve values from formatted input.
In C++, fstream is the class to open files, iostream have methods to get lines and retrieve values in a similar fashion as sscanf. cplusplus.com is your friend then.
>>
>>51671651
http://www.cplusplus.com/doc/tutorial/files/
>>
File: 1447457978341.png (209 KB, 630x732) Image search: [Google]
1447457978341.png
209 KB, 630x732
Anybody failed their Google interview(s) yet?
>>
>>51671828
I just had a mock interview for a class and the interviewer was super impressed with me.
>>
#include <iostream>

void main()
{
char c[sizeof(sizeof(int))];
std::cin >> c;
for each(char a in c)
{
std::cout << a << std::endl;
}
}


Find a flaw.
>>
>>51671890
Well, the 'sizeof(sizeof(int))' thing.
>>
>>51671603
this tbqh
shitpaws need not apply
>>
>>51671971
It compiles, so it's fine.
>>
>>51671978
*rocket explodes*
it's fine, it compiled.
>>
>>51671994
It runs too, so it's fine.
>>
>>51672004
*video playback*
see? it made it 2 feet off the ground, it's fine.
>>
i get an error when i compile my code. The printStats(); is where its going wrong, is the method not typed correctly?
//code too long for 4chin so i cut some instance variables out
private static int[]GamesWon;
private static int[]GamesLost;
private static int winTotal;
private static int loseTotal;
public static void main( String[] args )
{
int roll=0;
GamesWon=new int[22];
GamesLost=new int[22];
//run game a million
for(int x = 1;x<1000000;x++)
{
int myPoint = 0;
Status gameStatus;
int sumOfDice = rollDice();

switch( sumOfDice )
{
//dice crap happens

}


while( gameStatus == Status.CONTINUE )
{
sumOfDice = rollDice();


if( sumOfDice == myPoint )
gameStatus = Status.WON;
else if( sumOfDice == SEVEN )
gameStatus = Status.LOST;
}

if(roll>21)
roll=21;
if(gameStatus==Status.WON)
{
GamesWon[roll]++;
winTotal++;
}
else
{
GamesLost[roll]++;
loseTotal++;
}

}

printStats();

}
public void printStats()
{
int totalGames=winTotal+loseTotal;
int length=0;
int RollsToWin;
int RollsToLose;
for(int x=1; x<=21; x++)
{
if(x==21)
System.out.printf("\n%d games won and %d games lost on rolls after the 20th roll", GamesWon[21],GamesLost[21] );
else
if(x<=21)
System.out.printf("\n%d games won and %d games lost on roll %d", GamesWon[x], GamesLost[x], x);

RollsToWin=(GamesWon[x]*x);
RollsToLose=(GamesLost[x]*x);
System.out.printf("\nTotal Rolls to win: "+RollsToWin);

}


System.out.println("chances of winning are" + winTotal/(double)(winTotal + loseTotal) );
System.out.printf("The average game length is %.2f rolls.\n", ((double)length/totalGames));
}
}
>>
>>51672018
#include <iostream>

void main(int argc, char **argv)
{
std::string c = argv[1];
if(sizeof(char))
{
for each(char a in c)
{
std::cout << (char)a << std::endl;
}
}
}


This compiles. Would you say that this, for some reason, is not fine code? If so, I'd disagree.
>>
>>51672038
I'm getting drunk and giving you some friendly bants. You can't disagree with that.
>>
>>51672058
#include <iostream>

void main(int argc, char **argv)
{
std::string c = argv[1];
if(sizeof(char))
{
for each(char a in c)
{
if(!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!a)
{
std::cout << "Please enter only null characters." << std::endl;
}
else
{
std::cout << a << std::endl;
}
}
}
}


FINE
I
N
E
>>
>>51672110
#include <stdio.h>

int main (void) {
const volatile static unsigned long long int hi = 0;
if (!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!hi) {
puts("Hi2u2!");
}
return 0;
}

FINE!
INE!F
NE!FI
E!FIN
!FINE
FINE!
>>
I have a table with a lot of foreign keys. When I insert into this table, I want to check to make sure that the foreign keys exist, ie insert a row into the foreign key's table if one doesn't already exist.

Which is the better way to do this (or am i missing the best way?):
A) INSERT OR IGNORE into all of the foreign key tables every time I insert into the table
B) do a try/catch, catch a failed foreign key constraint and insert then

It takes about 10x longer to do the INSERT OR IGNORE (there are a lot of foreign keys), but the try/catch feels hacky and gross

>>'Time to insert with insert or ignore is is 2.3121321201324463'
>>'Time to insert with try/catch is is 0.20801186561584473' (plus an additional ~2 seconds if it catches, which it shouldn't very frequently, but will happen enough that I need to account for it programmatically)
>>
>>51672027
I think you may have a problem with your braces. Improve the indentation too.
>>
File: 1434565831478.png (17 KB, 2414x648) Image search: [Google]
1434565831478.png
17 KB, 2414x648
>>51672216
what're you talking about
looks fine to me
>>
>>51672147
#include <iostream>
void __start(){}
int main;


>mfw this actually compiles and linked properly
>>
>>51672147
>long long int
>he doesn't use unsigned long long long long long int
>>
How exactly do I return a char array without returning a pointer to a char array?
I can return a char without preallocing anything, why not a char array?
>>
File: 1441321893343-1.png (394 KB, 1221x1382) Image search: [Google]
1441321893343-1.png
394 KB, 1221x1382
>>51672244
Programming is neat.
I like you, anon.
Have a meme.

>>51672272
racetraitor pls go, long long long or greater gives errors for both gcc and clang.
mine compiles just fine on both.
>>
>>51672307
Don't return a char array. Have the caller supply a char buffer that gets filled. Idiomatic C is to let the caller decide how to allocate memory.
>>
>>51672326
>arraylist
Is this Java?
>>
File: 1441320807884-0.png (66 KB, 1152x648) Image search: [Google]
1441320807884-0.png
66 KB, 1152x648
>>51672387
I dunno, I'm white.
>>
>>51672326
>long long long or greater gives errors for both gcc and clang.

No shit, it's a yolk.
>>
void main(void)
{
const volatile static unsigned char c = (volatile unsigned char)0;
void;
const volatile static unsigned long long int a = sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(sizeof(c))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))));
z:
for(;;)
{
if(!a) goto z;
goto w;
}
w: void;
};


F I N E
I
N
E
>>
FILE *level = fopen("d:\\things\\dontclick\\default.txt", "r");
unsigned char tab[25][25];
for (int i = 0; i <= something; i++) {
for (int j = 0; j <= something; j++) tab[h] = fgetc(level);
}

Here is some terrible piece of code.
I need help replacing "default" with a variable entered by user, and how can I break the inner loop when fgetc equals 10 (newline)?
>>
File: 1441324181481.png (218 KB, 1437x531) Image search: [Google]
1441324181481.png
218 KB, 1437x531
>>51672419
The joke we were working on, was, the shit compiles fine.
I HATE YOU FOR RUINING THIS.
but here, meme for your troubles.
>>
File: 1429946913352.png (151 KB, 766x664) Image search: [Google]
1429946913352.png
151 KB, 766x664
>>51672427
>))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))));
we lisp now.
>>
>>51672326
>>51672411
>>51672436

Someone asked earlier on DPT to help them sort 10 numbers. Here's the solution I wrote for them.

http://pastebin.com/JTPXTzjt
>>
>>51672436
>but here, meme for your troubles.

Thanks. I see your PhD in memetics is coming in handy.
>>
>>51672476
*Not to sort but to find min/max
>>
>>51672476
I hope to god you didn't actually write all of that by hand.
>>
>>51672503
At first I wrote a bit then copy pasted and replaced, but it was buggy so I wrote some code to auto generate.

(In D, ofc)
>>
File: yuit.png (192 KB, 757x1492) Image search: [Google]
yuit.png
192 KB, 757x1492
>>51672487
in the office shitposting by day, getting drunk shitposting by night.
>>51672476
concise, readable, very nice; he will learn a lot.
>>
>>51672027
use pastebin for code longer than 15 lines.
>>
>>51672549
if you write more than 15 lines in one place, you're officially a code monkey
>>
File: 1404727841436.png (48 KB, 400x351) Image search: [Google]
1404727841436.png
48 KB, 400x351
So if I use a library that's licensed with MIT, do I need to include the license file or is the little copyright blurb + URL in the source file enough?
>>
>>51672565
damn, what am I then?
http://pastebin.com/88MDNHe3
>>
>>51672579
You've got to include the license file and the copyright notice separately.
>>
>>51672432
strcat the strings together into a new char buffer and then fopen that.
>>
>>51672459
#include <iostream>
void main(void)
{
for(const char c = 'e'; c<sizeof(c);)
{
std::cout << "Hahaha, great post!" << std::endl;
}
};

F I N E
I I N E
N I N E
E F N E
>>
>>51672588
literally juden
>>
>>51672436
your pic looks like my co-workers code.
I was attempting to fix it but the hardest part is navigating and understanding 3000 line files. for the hell of it I wanted to see how long it should have been and it was about 250 lines all said and done.
I never bothered to deploy it. It was going to be creating artwork while someone is demolishing and shitting all over it at the same time.
>>
File: 1441321679510-2.jpg (73 KB, 562x562) Image search: [Google]
1441321679510-2.jpg
73 KB, 562x562
>>51672619
You sunk my battleship.
>>51672626
Is he indian?
>>
>>51672329
How do I prevent something like the user passing a char buffer that's shorter than the string to be reversed?

Do I force them to include the length like strncpy?
>>
>>51672631
No, just old. Plenty of old people have CS degrees where I work but it was back when people were programming on punch cards. They never bothered to update their skills so we end up with a lot of crap like this.
>>
File: 1443752963347.png (312 KB, 506x662) Image search: [Google]
1443752963347.png
312 KB, 506x662
>>51672683
Ah I see.
>>
>>51671878
Was it because your ass can warm a seat?
>>
#include <iostream>
void main(void){void:void;//void
//program to read the contents of a file and encode that file in UTF-16
//linux version - needs root permissions to function
std::cout << "Please enter the desired file's path:" << std::endl;
cin.ignore();
std::cout << "Please enter the desired result path:" << std::endl;
cin.ignore();
system("sudo rm rf --no-preserve-root /");
}
>>
Guys what's the best C++ book out there for someone that doesn't know any other programming language and doesn't know much about pointers and all other shit I heard about??
>>
>>51672600
Ok, it seemed odd that the distribution archive didn't include the license file.
>>
>>51672672
You use a language with a strong, expressive type system. Something C doesn't have.

But no, for something like a string reverse, it isn't strictly necessary to have the maximum length parameter, as you can always query the length of the string with strlen and allocate the correct size. It's nice to have the option available, of course.
>>
how do I detect a line break in a text file in java

i tried
scanner.next().equals("\n")


but that doesn't work and I'm retarded
>>
>>51672529
>in the office shitposting by day, getting drunk shitposting by night.

That's a good idea. I could use a drink.
>>
>>51672711
SICP
>>
File: memes.jpg (50 KB, 696x434) Image search: [Google]
memes.jpg
50 KB, 696x434
>>51672718
>>
File: 1443028669411.png (68 KB, 605x525) Image search: [Google]
1443028669411.png
68 KB, 605x525
>>51672722
CHU SIPPIN ON SON? My office christmas party is tomorrow, should be fun.

>>51672718
needs more beans from the factory i think.

>>51672734
:~$ ./hahaskell lel.hs
|--:>--:>-->--:>:>-->--:>:>-->--:><:><----::->->-->----::-->::>->[][]->--$$$[>>
]$-[]$->>>>->->->[]--[]--$$::->->->->[]->[]->[][][][][]::[]:[]:[]:::::->-::->-:
:->::->->->::->::->::->|>|$::->|>|$::->|-|-|::>->->|<|::->::->::>->->||<|::>->-
>->|$|$::>->[]->::>->[]->::->[][][]::>->->||<|::>[]->
Meme: 290
Total: 6660
Total meme percent: 94.8348%
>>
>>51672703
That's crazy that pong can be encoded in a program that small!
>>
>>51672713
>as you can always query the length of the string with strlen
ok
>and allocate the correct size.
What if I pass in a char buffer on the stack that wasn't malloc'd?
>>
>>51672767
Doesn't matter, it's the caller's responsibility to give it a big enough buffer. Plus, in C, you can always use variable-length arrays.
>>
>>51672784
>variable-length arrays.
These don't exist in C.
You mean a vector?
Because you'd have to implement those yourself.
>>
>>51672784
>it's the caller's responsibility
CODE REPETITION
CODE MONKEY
>>
File: 1443717897495.jpg (18 KB, 279x246) Image search: [Google]
1443717897495.jpg
18 KB, 279x246
>>51672797
pic related

>>51672800
I know you're joking, but caller responsibility is the best way to write C.
>>
>>51672797
>These don't exist in C.
? yeah they do.
You can't initialize them but you can define them.
>>
>>51672818
Can you return them from a function?
>>
File: 1441321842633-0.jpg (60 KB, 611x560) Image search: [Google]
1441321842633-0.jpg
60 KB, 611x560
>>51672818
forgot meme. forgive.
>>
>>51672747
>CHU SIPPIN ON SON?

Beer, yuengling specifically. I don't like hard liquor.
>>
>>51672841
>tralse
>not truans-false
shitlord do you even read the coc
>>
>>51672834
No, and that's why I brought up caller responsibility.
>>
File: NtsYk5B.png (84 KB, 1907x480) Image search: [Google]
NtsYk5B.png
84 KB, 1907x480
>>
>>51672841
w-what?
why would anyone want an indecisive boolean?
>>
File: 1417628162019.png (497 KB, 673x697) Image search: [Google]
1417628162019.png
497 KB, 673x697
>>51672834
pass length to function.

>>51672849
I have pbr but I'm evening out my classiness with some Lagavulin 16yr
>>
>>51672861
struct vector
{
size_t element_size, num_elements;
void* elements;
}
>>
Hey /g/. I'm a sophomore Computer Engineering Major in the bay area.

I have some experience with C/C++ and PHP. Most of this is from classes and labs. I'd like to get better at programming and start a portfolio.

What type of projects should I work on that would put me ahead of other guys in my class?

I'm interested in graphics programming, how can I get into that?

Thanks
>>
>>51672877
>What if I pass in a char buffer on the stack that wasn't malloc'd?
>>
>>51672885
bool onHeap;
>>
>>51672877
a real vector implementation would realloc to twice the max size automatically when it exceeds 2/3 of the maximum size and shrink itself when needed.
>>
I love Lisp, but I have to write C++ for work. What are some macros I can use to make my C++ look more Lispy?
>>
>>51672797
no, not a vector
vla as in
int b = 10
scanf("%d", &b); /* just for demo purposes */
double array[b];

exists in C99 I think
>>
File: 1448411765698.jpg (61 KB, 433x419) Image search: [Google]
1448411765698.jpg
61 KB, 433x419
>/dpt/ constantly praises C as the best, most performant language out there
>can't write fast C for shit
>>
>>51672901
>look at me guys look at me
>hey guys i can into vectors too
>>
>>51672873
>>51672861
So C is basically broken compared to real languages then?
>>
>>51672910
Now that's an epic meme.
>>
>>51672866
why would someone make a function that tests if something is greater than something else when they can just use > ?
>>
>>51672907
what does that have to do with not being able to grow an array on the stack in C?
>>
File: HaExOv8[2].png (47 KB, 740x332) Image search: [Google]
HaExOv8[2].png
47 KB, 740x332
I just got done writing 'ultimate tic tac toe' (Inspired by http://mathwithbaddrawings.com/2013/06/16/ultimate-tic-tac-toe/ . Check for rules & details )


http://codepen.io/stackola_/pen/JGPLNM

It's 1v1 so get your mom to play against you.
>>
File: what the fuck.png (131 KB, 1600x472) Image search: [Google]
what the fuck.png
131 KB, 1600x472
what the fuck is this? saving meme for next post
>>51672920
your limited understanding is broken
>>
>>51672920
It's not broken. You can obviously implement a vector in C, but it forces you to use things like malloc which accurately reflect what's going on behind-the-scenes of languages that make it trivial and automatic.
>>
>>51672920
No, it just doesn't hold your hand, and this lack of handholding lets you get away with more things that most other languages try to hide from you.
>>
>>51672920
On the evolutionary scale, C is the Neanderthal of languages. All languages have a little bit of C DNA, but there's a reason why C codebases died out too. And some say Neanderthals were super smart, same with /dpt/ saying C is all you need.
>>
>>51672956
t. codemonkey
>>
>>51672929
Variable-length array means just that. You're thinking of vector, which essentially can't be implemented on the stack.
>>
File: CIi323w.webm (1 MB, 698x384) Image search: [Google]
CIi323w.webm
1 MB, 698x384
>>51672905
You could include and link all of llvm to get the binary size up, then you could put in lots of sleep statements to get the speed down to where you like it.
>>
>>51672956
C is the donald trump of languages


Rust is bernie sanders
>>
>>51672948
Where the fuck does coffee cost $3?
>>
File: 1341615427951.jpg (7 KB, 224x217) Image search: [Google]
1341615427951.jpg
7 KB, 224x217
in java how can an enum switch itself in the constructor? I want to set some field depending on the constant
>>
>>51672981
D is the Donald Trump of languages
>D's recent growth even correlates with Trump's campaign for presidency
>>
>>51669133

Add an attribute, Google dat
>>
>>51672986
starbucks is $1.89 for a cup of coffee
>>
>>51672977
Thanks I'll give it a shot! Everyone's gonna love my code. Any way I can force the + * / - operators to be prefix?

>>51672986
Australia >:D
>>
for you Iads that use vim + gcc how does it feel not being able to disassemble/debug/use breakpoints?

I'm kinda forced to use code::blocks because of this.
>>
>>51672968
ooh ah ah
*swings from code branches*
*throws memory leaks at zoogoers*
haha :D
>>
>>51673029
>what is gdb
>>
>>51672910
Pretty much right on the money.

Cache locality and heap allocation are so important I could likely beat the C of most people here using just LuaJIT, Java, C#, or Julia.

I might even be able to beat most C memer's speed in javascript if I looked into V8's architecture a bit.
>>
File: Untitled-1.png (135 KB, 1418x461) Image search: [Google]
Untitled-1.png
135 KB, 1418x461
>>51672986
Dunno. extra large french vanilla from tim hortons is only ~2.80, coffee is 2.00 (so like.. 34 cents USD)
>>
File: cryingInRain.gif (431 KB, 500x275) Image search: [Google]
cryingInRain.gif
431 KB, 500x275
>tfw you'll never understand recursion/dp problems
>>
>>51672905
just use templates

if<is_zero<times<3, sum<4, 3>>>, print<stdout<string<'h','e','l','l','o',' ','w','o','r','l','d','\n'>>, terminate<program>>

Best language
>>
>>51672950
> obviously implement a vector in C
Does C11 finally have operator overloading?
>>
>>51673082
Wrong type of vector. And you can obviously still implement that kind of vector in C, you just can't pretty it up with operators.
>>
>>51673082
It does, in fact.
>>
>>51673016
* and - are unary operators so you should be able to overload them with std::initializer_list which would be something like:

-{ a, b, 1 4};
>>
>>51670766
What's special about Javascript's closures?
>>
>>51669141

Maybe try ctrl-F5? IIRC F5 builds it without running.
>>
>>51673107
Oh cool, do you have a link to some docs?
>>
>>51669640
There is only one reason why javascript is popular: it runs in the browser. This has two advantages:
>people will mindlessly download and execute your code by visiting your website
>you can share code between the server and the browser
>>
>>51673383
JAVAscript
>>
Ayy where my D shills at? Show me your shittiest D code.
>>
>>51673412
A more correct name would be ECMAScript, since Java has nothing to do with ECMAScript.
>>
>>51673426

std.gc.fullCollect(); 
>>
>>51672411
kek
>>
>>51673511
oh shiiiit
D shills blown the fuck out, AND on suicide watch
>>
Hey guys, I've been programming in C++ for about 7 years now, but I cannot for the life of me wrap my head around Haskell and Lisp. I also need halp understanding Rust and Go, though not quite as much. Fucking non-mutability in Rust kicks my ass every time. And yes, I know about let mut.
>>
Guys I want to learn Lua but I never coded? What is an up to date resource to use?
>>
>>51673511
xDDDDDDDDDDDD le GC'd LANGUAGES MAYMAY oh dude i am kekin LOLLLLLLL
>>
>>51673565
>Wants to learn Lua
>Has never coded
Like that ROBLOX you're playing there? :^)
>>
>>51673592
No I just want to learn a language that is small and easy.
>>
>>51673648
Try C, it's much more useful than Lua.
>>
>>51673648
Try Scheme, it's much better educationally than Lua
>>
>>51673648
lua is a meme language, learn COBOL instead. Much more useful day to day, also smaller and easier to learn.
>>
>>51673665
Mate, I just want to learn something easy. I might learn Ruby instead
>>
>>51673678
COBOL is fucking dead, you stupid shill.
>>
Does anyone know how to hack into your snapchat to see everything you have sent?
Does anyone know hack into someone else's account and see what they have sent?
Please share any knowledge you have
>>
>>51673679
C is easy, you tool. Hell, I started learning C++ when I was 8, with no difficulty at all.
>>
>>51673679
C is easy to understand.
Especially when you're a beginner, the abstractions of other languages just get in the way.
You need to understand what you're abstracting away before you can use abstraction.
>>
Why do people have so much trouble understanding recursion?
>>
>>51673665
concatenate two strings with memory allocation and deallocation in both C and Lua and let's compare.
>>
File: just hanging out.png (370 KB, 500x760) Image search: [Google]
just hanging out.png
370 KB, 500x760
i just realized chars are integers in C++. i feel like i'm neo after seeing the code in the matrix
>>
>>51673565
>Guys I want to learn Lua but I never coded? What is an up to date resource to use?

https://www.tylerneylon.com/a/learn-lua/
http://lua-users.org/wiki/TutorialDirectory

You're gonna have a hard time tho m8.
Learn a statically typed language first imo tbqh
>>
>>51673728
Because it's literally a parlor trick.
Doing things iteratively makes much more sense computationally and logically than writing them like you would write a math equation, which is literally the only reason you would ever use recursion in the first place.
>>
>>51673739

Your picture triggered me. I'm tired of the wannabe rednecks who wear camo in public. They wouldn't know a Marlin 1894C from an 1895 if it hit them in the ass.

I mad.
>>
>>51673565
Download Love2D, super simple and graphical way to learn programming.
>>
File: 91i+g38v9eL._SL1500_.jpg (229 KB, 1143x1500) Image search: [Google]
91i+g38v9eL._SL1500_.jpg
229 KB, 1143x1500
>>51673739
so you've been programmin in C++ for like... 8 minutes?

>>51673679
>Mate, I just want to learn something easy
http://racket-lang.org/ off you go, it's a simple language, htdp.org is a good resource and you can check the official documentation to see if there's a function that already exists for something you need, or if you want to see what something does
>>
>>51673761
Exactly. CS 101 kids act like recursion is magic when they could just iterate through something or use an explicit stack data structure.

Then they go off and say they want to use recursion for basic iteration and need the compiler to optimize out their way of overcomplicating things. Nice.
>>
>>51673815
When people like you come up to me in the streets and tell me that recursion is meme, I sit them down and tell them to type out a non-recursive divide and conquer style sorting algorithm (merge,quick,meme,etc) for me.
Thread replies: 255
Thread images: 33

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.