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

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

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

What are you working on /g/?
>>
File: runtime get out.png (22 KB, 1161x407) Image search: [Google]
runtime get out.png
22 KB, 1161x407
>>
This is the exact same thread I was about to make, filename and all.

I'm making a socket library in C to do stockfighter challenges and was wondering if it's good practice for a library to return a malloced string or to accept a buffer.
>>
Just finished my heap-less JSON formatting project on my microcontroller.
It's as beautiful as it sounds.
>>
>>54079723
Always accept a buffer.
Don't force the programmer to use the heap.
>>
>>54079723
>return a malloced string or to accept a buffer
You could really argue for either of them, and you can see both in use.
I would go for "accepting a buffer" as it gives the user the ability to store the string on the stack or somewhere else and makes it very clear who is supposed to deal with freeing the buffer.
>>
>>54079751
>>54079754
And if I reach the end just return an error code? The only problem I can see is I have no idea how big GET responses typically are so when I create a buffer and give it I would hate to keep getting size errors.
>>
>>54079779
Well in that case, I don't see much choice other than to return an malloc'd buffer.
Unless you're okay with returning an error.

Is there a reason why you're assuming HTTP?
Usually if you're expecting a specific protocol, you write a protocol layer on top of the socket layer, and in the protocol layer you receive things in chunks and append it to a buffer until you have a valid message.
>>
File: 6Mg3jXs.png (1 KB, 297x59) Image search: [Google]
6Mg3jXs.png
1 KB, 297x59
Not programming, but related
rendering animations for a tutorial series about programming
took ~1.5 hours to do a 1 minute animation, and i've still gotta dub it and edit here and there

taking suggestions for more tutorials i can do, but preferably something not tied down to a specific programming language (i'd rather explain broad/abstract concepts).
>>
>>54079779
You could try doing some crap by reading the Content-length field in the HTTP header, and telling the user how much space they would need, but it seems like just giving them the malloc'd buffer would be a less of a pain in the ass.
>>
>>54079740
If you're going to shitpost with C, at least do it properly:
extern printf(char *, ...);
extern putchar();

fizzbuzz(n)
{
register i;

for (i = 1; i <= n; ++i) {
printf("%s", i % 3 ? "" : "Fizz");
printf("%s", i % 5 ? "" : "Buzz");
if (i % 3 && i % 5)
printf("%d", i);

putchar('\n');
}

return 0;
}

main()
{
fizzbuzz(100);
return 0;
}
>>
>>54079829
now here's a tripcode I can get behind
>>
What are some simple projects I could do in Rust for learning purposes?
>>
>>54079862
Hello world
>>
>>54079829
*flips pizza*
>>
>>54079862
some project euler things, an IRC bot, etc.
>>
I have some C++ code with a getchar() and then some statements, and cin.getline().

The problem is whenever I input something into the getchar(), everything works, but when it gets to the cin.getline() it's automatically inputted with a blank and it doesn't give me a chance to type anything.

Why is this? Is some leftover \n or something being passed as a leftover? Does C++ have some weird buffer shit going on?
>>
Hey /dpt/, I don't know how much you guys will be able to help but:

I'm planning on applying to Google's internship program for first and second-year students in the fall. Right now, I only know C, Java, Python, some C++, and really only have a couple substantial C projects, an engineering company internship, and some other stuff. What can I do to ensure I get the interview? I heard from a former employee (that did AI research there) that learning JavaScript, C++ will help, but I'm just not sure if that's the right way to go. (JS also makes me want to kill myself, as does most webshit)
>>
>>54079898
>Is some leftover \n or something being passed as a leftover?
Probably.
>>
>>54079846
impressed desu
>>
>>54079898
I assume you just need to flush cin.
>>
>>54079898
Yes, it's not C++, it's stdin. When you call getchar(), you only take one character off of the buffer. Call it twice. It's cancerous but:

char c;
//...
c = getchar();
getchar(); // eat the newline
//...

should do the trick. I recommend using another form of input though, as the user can enter more than 1 character and that would cause a problem. Honestly just use getline() and use the first char from that.
>>
>>54079916
Why would a getchar() call do anything to cin though?
>>
>>54079931
Because both of them are taking their input from the same place: stdin.
>>
>>54079931
By cin he means stdin. I don't know C++ but perhaps cin has a function that flushes its stream, i.e. stdin.
>>
>>54079931
Where do you think it gets the character from?

https://stackoverflow.com/questions/257091/how-do-i-flush-the-cin-buffer

fflush(stdin);
>>
File: consider:.jpg (31 KB, 500x375) Image search: [Google]
consider:.jpg
31 KB, 500x375
>>54079710
What happens when you multiply the largest possible floating number (in terms of magnitude) by the smallest possible floating point number (in terms of magnitude)?
>>
>>54079927
>Honestly just use getline() and use the first char from that.

I'm trying to evaluate if the user enters 'y' or 'Y' though. If I do this with cin.getline() my booleans don't work, because cin returns itself when used in comparisons or some weird shit.
>>
>>54079970
Man I just printed the value of LDBL_MAX, fucking hell that's a big number.
>>
>>54079969
It just hangs with an input cursur when I do any of those.
>>
>>54079970
4, apparently.
>>
>>54080100
Exactly with no trailing decimals?
>>
>>54079982
There's something wrong with you.

Get a string from stdin. Check if if first index is y or Y.
>>
I printed it with %Lf, so maybe they weren't printed.
I also just printed it with %Le, and there are no decimals, it's exactly 4.
#include <stdio.h>
#include <float.h>

int main()
{
printf("%Le\n", LDBL_MAX * LDBL_MIN);
return 0;
}
>>
>>54080154
meant for >>54080115
>>
File: clion.png (165 KB, 1600x900) Image search: [Google]
clion.png
165 KB, 1600x900
Post your IDE and show a code snippet of what youre working on.
>>
>>54079969
>>54079940
fflush on stdin is undefined.
>>
>>54079970
>>54080100
>>54080154
I wonder why that is. Like is there a good reason or is it implementation-specific undefined behavior weirdness?
>>
>>54080100
The largest number is 4 times bigger than the reciprocal of the smallest
>>
>>54080173
It's probably undefined behavior, and it's probably 4 only on my platform (x86_64-linux-gnu).
>>
>>54080188
Guess that makes sense, >>54080195 is wrong then.
>>
>>54079970
>(1.7976931348623158 * (10^308)) * ( 2.2250738585072014 * (10^-308))

Turned to Google for the answer, and apparently the answer is 4.
>>
>>54080219
print max and 1/min
you'll see they aren't the same
>>
>>54079970
#include <stdio.h>
#include <float.h>

int main()
{
printf("MAX: %lle\n", LDBL_MAX);
printf("MIN: %lle\n", LDBL_EPSILON);
printf("MAX * MIN: %lle\n", LDBL_MAX * LDBL_EPSILON);
}

Gives me
MAX: 1.189731e+4932
MIN: 1.084202e-19
MAX * MIN: 1.289909e+4913


>>54080154
>LDBL_MIN
That's min in terms of negative numbers. *_EPSILON is the smallest in magnitude.
>>
>>54080188
>>54080219
Will it overflow then if you do the second largest and second smallest?
>>
>>54080169
guess what table it's for and you get a cookie
>>
>>54080254
drivers?

some embedded shit?
>>
>>54080254
Character set?
>>
>>54080289
And by that I mean font.
>>
>>54080254
SSL
>>
>>54080254
Hacking the Gibson.
>>
Which would you prefer to use? The top is nicer but means you'd have to know the type of data you're getting.

char buffer[bufsize];
int returncode = lazyGET(char* URL, char* buffer, int bufsize)
----------------------------------------------------------------------
char* buffer = lazyGET(char* URL, int* size)
(Edits size with the returned size)


Also can you see anything you would want access to? Lower level protocols are available so only stuff related to GETs.
>>
>>54080254
First, what's the language?
>>
>>54080338
Probably C.
>>
>>54080309
close

>>54080338
C
>>
>>54080254
TLS
>>
>>54080366
Think deeper
>>
>>54080422
TCP/IP packets?
>>
>>54080422
UDP packets?
>>
>>54080254
DES
>>
>>54080472
got it
>>
>>54080476
So what's the table for, exactly?
>>
There is a bug in my code that I can't seem to figure out. Below is a summary of it.
typedef struct {
int *matrix array;
int rows;
int cols;
} Matrix;

int createMatrix(int nrow, int ncol, Matrix *matrix);

int main(int argc, const char **argv)
{
Matrix myMatrix;
createMatrix(3, 3, &myMatrix);
printf("rows: %d, cols: %d\n", myMatrix.rows, myMatrix.cols);
return 0;
}

int createMatrix( int nrow, int ncol, int *matrix)
{
// .. skip
printf("rows: %d, cols:%d\n", matrix->rows, matrix->cols);
return 0;
}

How come the values inside the function both print 3, but outside in the main function it consistently prints 4195680, 0?
>>
I have not used PHP much

Im just trying to set an expiring cookie

a cookie to expire after 1 minute

the code is
$timeout = 'ACTIVESESSION';//name
$timeout_value = '1';//value
$timeout_expire = time()+60;//60 seconds

setcookie($timeout,$timeout_value,$timeout_expire,'/');//set cookie


however when i check, the cookie is not set to expire
it is set as a "session" cookie with no expiration date

can anyone explain why this is happening?
>>
>>54080512
>int *matrix array;
That's not valid, unless "array" is a macro.
If "array" is defined as "[]", that is a bug.
>>
>>54080530
It is a mistake, it should be one word, sorry.
>>
>>54080534
Post all of the code, into pastebin if necessary. What you have there isn't enough to go on.
>>
>>54080512
>>54080530
I updated it.
typedef struct {
int *matrixarray;
int rows;
int cols;
} Matrix;

int createMatrix(int nrow, int ncol, Matrix *matrix);

int main(int argc, const char **argv)
{
Matrix myMatrix;
createMatrix(3, 3, &myMatrix);
printf("rows: %d, cols: %d\n", myMatrix.rows, myMatrix.cols);
return 0;
}

int createMatrix( int nrow, int ncol, int *matrix)
{
matrix->rows = nrow;
matrix->cols = ncol;
// .. skip
printf("rows: %d, cols:%d\n", matrix->rows, matrix->cols);
return 0;
}
/
>>
>>54080512
>typedef struct
kys
>>
>>54080553
>>54080512
>int *matrix
Another error I spotted. That shouldn't even compile.
Post the code, unedited, as it appears in your text editor.
>>
>>54080490
It's a permuted choice table https://en.wikipedia.org/wiki/DES_supplementary_material#Permuted_choice_1_.28PC-1.29
>>
>>54080575
Fuck off retard.
>>
>>54080589
Not him, but typedefing structs is usually a bad idea. It's still not as bad as typedefing pointers though.
>>
>>54080575
because it would be better for him to write struct everytime he wants to use a matrix object, right?
>>
>>54080580
Well I mean that particular table is the substitution boxes but whatever
>>
>>54080599
There is no such thing as a bad idea, only bad programmers.
>>
>>54080599
How is typedefing structures bad? Doesn't everyone typedef structures?
>>
>>54080607
>>54080620
All it does is obscure information about the type. It's not obvious at all if it's a struct, a union, an integer or whatever. Typedefing opaque structs isn't as bad, as you aren't supposed to access them in the first place.
>>
>>54080639
>>54080553
>>54080512
>>54080530
>>54080578
Here it is.
>http://pastebin.com/2qm1dsZA
>>
>>54080654
>matrix = malloc(sizeof(matrix));
You're already passing in an allocated area for matrix. You're just discarding the pointer to the Matrix in main and allocating a new one, which goes unused at the end of the function.
Remove this line and the NULL check after it, and your code should work as expected.
>>
>>54080680
Thanks! It worked.
>>
>>54080639
>wahhhh everyone do things the bloated way because it's what I'm used to

Do you think type inference is bad feature too?
>>
>>54080694
Type inference is a crutch for languages that horrible type systems.
>>
>>54080694
>type inference
>good
get out of my /dpt/
>>
>>54080733
>that
that have*
>>
Extremely strong, static typing with no subtyping or implicit casting, and healthy type inference is THE ONLY way to go
>>
>>54080733
Are you saying static type systems are horrible?
>>
>>54080762
t. unproductive programmer
>>
>>54080762
the only healthy type inference is no type inference
>>
>>54080639
lel, k tard.
>>
>>54080680
You seem to be experience with C. What is proper practise for return values? Should one use return values based on the success of the function or should one use it for return a value which was calculated from the function?
>>
>>54080826
depends on the use case
>>
>>54080826
It really depends on the function.
Can you use in-band signalling for the return (NULL for pointers, <0 for integers etc)?
How comprehensive are the errors returned by the function? (Only 1 return for failure or several error codes)
Are you trying to keep a very consistent interface across all of your functions?
>>
>>54080848
>>54080856
Okay, thanks.
>>
File: Kcj7opncq.png (186 KB, 936x590) Image search: [Google]
Kcj7opncq.png
186 KB, 936x590
tfw even reddit is making fun of karlie

https://www.reddit.com/r/InternetIsBeautiful/comments/4f25js/play_around_with_dos/d25hdp1

then you guys will ask why there no girl in cs.
>>
>>54080979
Never before has anyone dared post a link to that site here, in /dpt/
>>
>>54080990
He's a worthless frogposter so it's the level of quality I expect from him.
>>
#include <iostream>
#include "..\headers\FizzyBuzzer.hpp"

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


int main ()
{
FizzyBuzzer fb;

fb.setRule(5, "Buzz");
fb.setRule(3, "Fizz");
// fb.setRule(7, "Spazz");
// fb.revokeRule(7);

for( int i = 1; i <= 100; ++i )
cout << fb.applyRules(i) << endl;

return 0;
}

>>
>>54081034
>applyrules
That's probably way too much functionality for one method you should refactor it to a createRules which returns a Rule, which then you can plug into an applyRule.
>>
so, i learned the emacs keybinds, it's very cool for navigating and shit, but its so hard on my pinky for moving by words etc...

should i try neovim? isn't it annoying to have to press esc to navigate then i to insert then esc to move to the right 2 times then i to insert again and shit like that?
>>
First try Rust
>>
Did you ever make anything with that waste of money Raspberry Pi you bought, /dpt/?
>>
File: fizzbuzz rules.png (27 KB, 1132x264) Image search: [Google]
fizzbuzz rules.png
27 KB, 1132x264
>>54081034
>>
>>54081199
I use it to scrape images from /fit/'s breh/roid/fraud threads, /wsg/ threads, /wg/ threads, and /s/ threads
>>
>>54081210
If you want the rules sorted by their number, replace "applyRules a" with

applyRules (Seq.sortBy fst a)
>>
File: 1454051613645.gif (2 MB, 500x281) Image search: [Google]
1454051613645.gif
2 MB, 500x281
God damn, writing a library is tough. I don't know how to organise things and what to abstract or what to break into what chunks.
>>
>>54081339
monads
>>
>>54081344
nice meme
>>
File: ss (2016-02-20 at 02.45.09).png (12 KB, 498x355) Image search: [Google]
ss (2016-02-20 at 02.45.09).png
12 KB, 498x355
>>54081210
>>
>>54081339
Season 2 when?
>>
File: 1436911314581.png (545 KB, 1273x1001) Image search: [Google]
1436911314581.png
545 KB, 1273x1001
If I accept a buffer and maxsize for that buffer into my get request function (in C) and I receive a response that is bigger than the maxsize what should I do? If I've read bytes already is it possible to read more? If I stop reading and then start reading will I get the old data again? Where the fuck is programming literate when I have an actual question?

>>54081970
Never.
>>
>>54081962
What font and color scheme is that?
>>
File: tre.jpg (105 KB, 1280x720) Image search: [Google]
tre.jpg
105 KB, 1280x720
/dpt/ is so slow now

i blame all the new generals dividing discussion
>>
>>54082022
>If I accept a buffer and maxsize for that buffer into my get request function (in C) and I receive a response that is bigger than the maxsize what should I do?
Up to you. Anything not read will stay there until read.

>If I've read bytes already is it possible to read more?
Yes, just make sure that you have enough space in your buffer(s).

>If I stop reading and then start reading will I get the old data again?
When reading from any in-source, you will read any data not read. So, if you've read a block of data and there is still some left, the next time you read you'll get whatever is left.


>Where the fuck is programming literate when I have an actual question?
THEY ARE DEAD.
>>
GNU turd kernel coming soon, the bootup right now says
DESIGNATED
APPLICATION
SERVERS

meaning all servers (filesystem, gpu driver, network stack) launched after the microkernel loading
>>
File: RhuJ65F.jpg (32 KB, 694x801) Image search: [Google]
RhuJ65F.jpg
32 KB, 694x801
can you guys post variations of this?
>>
>>54082183
Just lurk the threads for a bit.
>>
>>54082183
I found a directory full of them just by reverse searching your image. I won't give you the link because you're a mentally disabled faggot that can't even pull a basic PC task.
>>
>>54082096
It's just a slow time of day. These threads don't require a constant stream of shitposting.
>>
>>54082096
I just came by and saw this. I stopped posting in /dpt/ because of all the inane shitposting in these threads and the low level of 80% of the projects posted here.
>>
>>54082096
All the generals /g/ has:

/mpg/, /spg/, Vape General, /nru/, /dpt/, /fpg/, /sqt/, /fglt/, /tpg/, /noobs/, /bst/, /ptg/, /wt/, Mouse General, Desktop Thread, /oldshit/, /hpg/, /wdg/, /lst/, /mkg/, /guts/, Wallpaper Thread, /csg/

Jesus fucking Christ.
>>
>>54082243
You forgot Homescreen Thread.
>>
>>54082243
/g/ should be renamed to mumbai central with all the poo2loos coming here now to beg for private trackers and android roms
>>
>>54082141
Do you have any suggestions for making a library to handle this? I would like to be able to just call a function and not worry about details but if it fails that means the next call will create a new socket. I saw curl uses and object that is passed which holds the state but I kinda want to keep things more simple.
>>
>>54082409
Select or epoll you fucking noob
>>
>>54082425
I don't understand how that ties with what I said.
>>
File: umarusecret.webm (2 MB, 960x540) Image search: [Google]
umarusecret.webm
2 MB, 960x540
Ask your much beloved programming literate anything (IAMA)

>>54082096
Sauce ?

>>54082243
>All the generals /g/ has:
The subreddits of /g/. up/downvote when ?

>>54081123
http://spacemacs.org/

>>54079846
#include <stdio.h>

int main(void)
{
for (int i = 1; i < 101; ++i)
printf(i % 3 == 0 ? (i % 5 == 0 ? "%s%s\n" : "%s\n")
: (i % 5 == 0 ? "%2$s\n" : "%3$d\n"),
"Fizz",
"Buzz",
i);
return 0;
}


http://ideone.com/b92msF
>>
>>54082461
That's not nearly shitpostey enough.
Mine was littered with implicit ints and unspecified function arguments.
>>
>>54082461
How do I write a good library in the C programming language? The library in question will make socket programming and interacting with the web not horrible and cross-platform.

I basically have no idea how to write the function definitions and how to handle data/state for it though.
>>
>>54082484
Learn to program
>>
>>54082489
I basically have no idea how to *design* the function definitions.
>>
>>54082484
Nobody knows how to write a good API at first. Just do whatever makes the most sense to you and as you're using it, you may notice some horrible inefficiencies that you need to fix.
You don't need to take this shit too seriously. I doubt anyone besides you is going to use it.
>>
>>54082022
A way to do this is to accept like 64kb and read until you reach '\0'

When developing you should be able to guess the "worst case scenario" or the biggest possible packet your program will send/receive. I limit my packets to MTU so about 1400 bytes.
>>
>>54082512
Make the library and then try to use it yourself. Make changes according to what makes it easier to use.
>>
File: anime_eat_burgers.webm (3 MB, 1280x720) Image search: [Google]
anime_eat_burgers.webm
3 MB, 1280x720
>>54082484
you can handle error in two ways:

- Error code returned by the function

eg:
/*
* Add two Numbers a and b, put result into a.
* may return ERROR_OVERFLOW if overflow happen
* otherwise return ERROR_NONE
*/
Error Number_add(Number * const a, Number const * const b);

if (ERROR_NONE != Number_add(a, b))
...


- A global (or per thread) error state variable

eg:
/*
* Copy the current error state in e then reset it.
*/
Error Error_get(Error * const e);

c = Number_add(a, b);
Error_get(&e);

if (ERROR_NONE != e)
...


i prefer the first technique.

Arrange your folder structure like this

- one folder per module
- one source file per public procedure

eg:
Foolib\
|-- Number\
|-- number_add.c ; implements Number_add
|-- number_sub.c ; implements Number_sub
|-- number_toString.c ; ...
|-- String\
|-- string_cat.c
|-- string_toNumber.c


This way your static lib (.a) will be composed of one object (.o) per procedure
>>
Java professional here again willing to help anyone with their assignments or homework they have with programming
>>
>>54082838
pajeet pls
>>
>>54082838
>Java
>professional
HAHAHAHAH
>>54082409
recvfrom should return the packet size
>>
File: TiKI6J2.jpg (109 KB, 750x690) Image search: [Google]
TiKI6J2.jpg
109 KB, 750x690
>>54082838
can you read and program in java bytecode ?
>>
File: 11228833.gif (323 KB, 500x517) Image search: [Google]
11228833.gif
323 KB, 500x517
>>54079710
Evening, /dpt/. Not a programmer here.

I was wondering if anyone could explain me the meme regarding GNOME file upload dialog.

People constantly say it's a gtk-issue.
Well, I also came to know that the Qt's file chooser is just as shitty, it's KDE that overrides it.

Why won't GNOME override the shitty file uploader dialog so we can get a proper thumbnail view?
>>
>>54080356
>>54080254
Something something DES fbcrypt.

I know because I tried something with it too.
Is it for your tripcode program?
>>
>>54080237
but that's wrong you knob
>>
>>54080173
>>54080195
floating-point numbers are well-defined for all relevant platforms goddamn shitters, it's not some magical unexplainable phenomenon
>>
>>54082866
>>54082895
>>54082911
This proves you guys aren't real programmers if you make fun of a language for no reason. Seriously grow up
>>
File: 1439648511159.jpg (116 KB, 469x469) Image search: [Google]
1439648511159.jpg
116 KB, 469x469
I think I found the git repo that perfectly embodies /dpt/
https://github.com/Keith-S-Thompson/fizzbuzz-c
>78 distinct solutions to fizzbuzz
>All in C
>>
File: readtext.png (50 KB, 852x290) Image search: [Google]
readtext.png
50 KB, 852x290
How do I do this in C++? I am so confused.

Triggered af tbqh.
>>
>>54083086
pajeet...
>>
File: yuno_byAnon.gif (35 KB, 470x337) Image search: [Google]
yuno_byAnon.gif
35 KB, 470x337
>>54083097
I like him!
>>
>>54083257
How likely is it that a ~1400 byte UDP datagram will get "lost" on the net anyways?
>>
>>54083349
Depends.
>>
Does anyone know why I might be getting a 403 from this website? I'm trying to get the data with C.
http://www.timeapi.org/utc/now

Here's my request string template
GET /utc/now HTTP/1.0\r\nHost: www.timeapi.org\r\n\r\n
>>
>>54083391
Set your User-Agent
>>
>>54083441
For some reason I thought user agents would be a fancy high profile thing that you had to register and get approved. What the fuck is the point if anyone can write anything?
>>
>>54083487
It can identify features that a browser can possibly accept, and it may affect how a webpage is generated. For example. if you load youtube with Chrome's user agent, many of the thumbnails will be .webp, but other browsers will not get that.
>>
>>54083487
There is no point. User agents are a goddamn joke.

http://webaim.org/blog/user-agent-string-history/
>>
File: muh-apple.png (66 KB, 1032x699) Image search: [Google]
muh-apple.png
66 KB, 1032x699
>>54082183
>>
File: justzoom.jpg (23 KB, 366x364) Image search: [Google]
justzoom.jpg
23 KB, 366x364
SEND HELP
I'm on vb net (VS 2015)
My program reads data from a csv file and then shows it on a reportviewer how can i add an image? Am i better off making some kind of database or something? What do you recommend me?
>>
>>54083764
This. Even MS spoofs its browsers as "mozilla"
>>
idly working on browser #113, now that #112 is out.
>>
>>54083764
all webshit is a goddamn joke
>>
>>54079722
auto out = static_output(...)

Should be left assignment i guess
>>
>>54084639
*keeps scrolling*
>>
What does an AST for a type/struct deceleration typically look like?
>>
Working on an implementation of a key exchange algorithm.

What's a good/quick/simple way to generate smallish primes in C#? Right now I'm just using a sieve to get a list of primes and picking randomly from the list, but that seems like a stupid way to do it.
>>
File: Untitled.png (894 KB, 840x1010) Image search: [Google]
Untitled.png
894 KB, 840x1010
>>54084787
well yes, that IS how one uses it. :^)
> *move mouse around*
> *use scroll wheel to read replies*
>>
per definition, are stack and queue limited in size or can they be expaneded ?
>>
>>54084923
they can be expanded
>>
>>54084949
wow that was fast, thanks
>>
>>54084990
A google search would have been faster.
>>
>>54085010
>expecting fast expert results from google
may as well try yahoo answers
>>
>>54085010
i fucked somehow up and didnt find quick results, and while youre here: are there downsides to binary search, ? just yes/NO
>>
>>54085025
>expert

top heh
>>
>>54085078
oh yeah, I forget about expertsexhange.
>>
>>54085078
>>54085025
>>54085089


not me, but are there real disadvantages of binary search, I cant really think of one
>>
>>54085035
Not the guy who answered you before, but yes.
>>
>>54085025
StackOverflow bb
>>
>>54085109
different tools for different situations
>>
>>54085109
>but are there real disadvantages of binary search

The source needs to be sorted.
>>
>>54085124
like that you have to sort the list, before searching and that it doesnt make much sense on small lists ?

>>54085149
are there more ?
>>
>>54085149
>>54085146
And it has O(log n) as average case
>>
>>54085168
so the only thing than binary search is hashing ?
>>
>>54085194
what

depending on your use case, you could have an array or indeed a hash table to look things up in O(1) instead of searching for it
>>
>>54085270
thanks a lot, that answered my questions
>>
>>54085194
median of medians for unsorted data is pretty cool.
>>
>>54082022
Why don't you make it like the read function for files
ssize_t read(int fd, void *buf, size_t count);


Your fd will be a struct for the context where the data will be read.
If there are mode data you can return a status flag indicating that (name it EMORE or something like that). You continue reading from the point you left it. You shouldn't return again data that have already been read.
>>
>>54083101
What part do you find challenging?
>>
>Implying any of your applications will make you money
>>
>>54085460
pajeet pls
>>
>>54085460
are you the guy who whined that his shit game "only" made $100 a day
>>
>>54085460
>being a moneycuck
>>
>>54080169
What is that ide?
>>
File: ??????????.gif (294 KB, 242x333) Image search: [Google]
??????????.gif
294 KB, 242x333
Why is it called overloading?
>>
>>54085590
Because you're imposing multiple meanings to the same thing.
It's a mess, pls dont use it.
>>
>>54085553
clion also its right in the picture
>>
Why is it called refactoring?
>>
>>54080254
It's definitely a block cypher
>>
File: Desktop.png (131 KB, 1920x1080) Image search: [Google]
Desktop.png
131 KB, 1920x1080
>>54080169
>>
>>54084837
Please respond.
>>
>>54085604
Is it better to use template instantiation?
>>
>>54085613
factor: a circumstance, fact, or influence that contributes to a result or outcome.

refactoring: to look over one's code while optimizing and simplifying while maintaining the same result or outcome.
>>
>>54085731
no, use C style macros
>>
Why does /g/ hate Rust?
>>
>>54085760
it's very (perhaps overly) complex. I don't think /g/ really hates it though, it is an interesting language.
>>
>>54085750
>use C style macros

Vomit is coming out.

>>54085788
>it's very (perhaps overly) complex.

Indeed. It's not a bad language, but the learning curve is massive. Writing something that compiles the first time is damned near impossible.

The error messages are really good, though. They tell you when things don't implement copy/clone, when things have been moved (perhaps unwittingly).
>>
>>54085760
Because it's not C
>>
>>54085760
It's too different from C and doesn't feature any of it's benefits.

Same with Go.
They only use it to host golang.org
>>
>>54085788
This.
I tried it back before 1.0 and it had some nice ideas, but I felt like I had to fight with the compiler a lot.
Maybe I'll try it again when it becomes more developed and when it can be built on more architectures.
>>
why is programming so hard?
>>
>>54086260
It's not, you just suck.

I'm a MechE doing this shit on the side.
>>
>>54086260
because you're not used to thinking like a computer
>>
File: IMG_0176.gif (3 MB, 320x180) Image search: [Google]
IMG_0176.gif
3 MB, 320x180
I'm livestreaming some web development at ShTheSuper on twitch if you guys need a self-esteem boost.
>>
>>54086368
*self of steam

Jesus, get your grammar right
>>
How long would it take me to understand git fully so I could implement a git frontend?

I use it every day, but I hardly know what it does besides sliding the HEAD pointer around.
>>
>>54086486
Fuck git: it's unnecessary bloat.

Just save your code to a flash drive.
>>
>>54086486
Can't you just use the git-bash tool?
>>
Few months ago I learned basics of python so I know what loops are and what variable or classes are and so on. Now I really don't remember how to program in pyton and I interested to learn C++ but I really like python. Should I learn python again or C++?
>>
In C when is it necessary or what are the advantages/disadvantages of static data (scalar, aggregate, or array) over stack allocated objects if they are only scoped within one function?
>>
>>54086526
>current year
>actually thinking this

Jesus Christ.
>>
>>54086486
there are lots of git clients already, gitkraken (not FOSS, though free) smartgit, and tortoisegit for example, you dont have to write one yourself
>>
>>54086534
I'd go the java => c++ route,

java is more forgiving when your make mistakes
>>
how much of a meme? http://cppinstitute.org/
>>
>>54086617
I know you can pass a pointer to the static data out of the function and the data still be valid through additional function calls because it's stored in the data segment. But for functions that don't do that, or initialize the data the only difference would be that 'static' makes the data take up permanent space, wasting space. Right?
>>
File: 1447949370768.png (528 KB, 1280x1057) Image search: [Google]
1447949370768.png
528 KB, 1280x1057
I have a c program prime.c with a method
bool isPrime(int x)

How would I call it in a separate .c program?
I know I have to make an #include a prime.h header file, it still doesn't let me call it
>>
>>54086934
prime.c:
#include "prime.h"
...

bool isPrime(int x)
{
...
}


prime.h
bool isPrime(int x);


main.c
#include "bool.h"

int main(void)
{
return isPrime(7);
}


You will also want to look into include guards for headers.
>>
>>54086981
I'm pretty sure you don't need to include prime.h in prime.c

prime.h just tells the compiler that isPrime(int) exists somewhere else and will defer the linking step till later.
>>
>>54086934
prime.c
bool isPrime(int x) {
...
}


prime.h
#ifndef PRIME_H
#define PRIME_H

bool isPrime(int);

#endif


program.c
#include "prime.h"

...
if (isPrime(n)) {
...


compile:
gcc -Wall -std=c11 -O2 $(OTHER_FLAGS) program.c prime.c -o program
>>
>>54086367
how does one think like a computer?
>>
>>54087017
by being autistic
you can give yourself autism by watching anime and dressing like a schoolgirl
>>
>>54087017
Become dumb and think of everything as glorified counting.
>>
>>54087009
$(wildcard *.c)
works better
>>
>>54087033
I don't have autism and I also don't like anime or dressing up as a lady
>>
File: 118051.jpg (32 KB, 640x360) Image search: [Google]
118051.jpg
32 KB, 640x360
>>54086534
pls answer
>>
If I wanted write toy language with interface to C, would it be easier with interpreter written in C or compiler which compiles to C?
>>
>>54087071
see my answer above
>>
>>54087075
If you compile your language down to C, it can be compiled by any C compiler in the world.
>>
>>54087047
It doesn't work "better", just easier. Fucks up if you keep more than one project's c files in the same directory.
>Buh why would you do that? Doing it my way is better.
Yeah, we know, shut up.
>>
>>54087092
why would you keep multiple projects in the same folder?
just use
$(wildcard $(SRCDIR)/*.c)
>>
>>54087075
Easier? SSA bytecode interpreter. Faster? Compile to C. Best of both worlds? Compile to LLVM IR.

>>54087108
>why would you keep multiple projects in the same folder?
Read the entirety of my post.
>>
Why aren't you guys making applications to make you money?
>>
Trying to unwrap some plsql and it is driving me insane! Anyone good at this?
>>
>>54087178
why arent you?
>>
>>54087178
Because programming is oversaturated and 99.999% of everything has already been done.
>>
Why everyone codes in C? It's old and gay
>>
>>54087213
>Why everyone codes in C?

masochism probably.
>>
>>54087199
>99.999% of everything has already been done.
This belief is the only reason you aren't making applications for money.
>>
learning python like a noob
>>
>>54087235
He's right though it's already been made
>>
Not super newbie but know DS and shit. Android or iOS as a way to learn more about programming and other aspects such as networking and OS related things.
>>
>>54087249
Is this some sort of ironic meme? If you genuinely believe there aren't any more new ideas to create or improve on you're a fool. If this was even remotely true we would only see a handful of new successful startups from this point in time to infinity. It's more realistic to assume we've barely cracked open the barrel of ideas that we could possibly create and will create in just our lifetime.

Putting in the time to think of something to create or improve is what separates people who are actually good at this from code monkeys.
>>
Is there any point to the C preprocessor in C++ besides for conditional compilation?
>>
>>54087368
easier to debug broken macros than broken templates a lot of the time
>>
>>54087323
So why aren't you rich?
>>
>>54087323
We will never be out of new ideas to make things better, but we certainly are on the plateau of diminishing returns.
>>
>>54087213
It's just the best.
>>
>>54087454
Part lack of creativity, part lack of work ethic, and large part lack of skill, I'm the "exec("sudo python /home/pi/PythonScripts/ToggleDB.py Curtain");" guy.

I don't have to be able to correctly do something to understand how it should be done.
>>54087499
That's certainly a possibility but I imagine 10 years from now we'll look back at all the things new things we've created and say the same thing, I'm sure we were saying to back in 2006.
>>
>>54087213
I use it at work, so I'm really familiar with it.
That and I'm too lazy to learn another language.
Thread replies: 255
Thread images: 32

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

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