Old thread: >>54463714
What are you working on /g/?
>>54469966
Nice doubles dubs
>>54469966int i;main(){for(;i["]<i;++i){--i;}"];read('-'-'-',i+++"hell\
o, world!\n",'/'/'/'));}read(j,i,p){write(j/p+p,i---j,i/i);}
Please do not use an anime image next time., thank you.
Thank you for using the traditional Yuki image.
>>54470018
>wants 7 year old tradition to die
kys
A macrokernel for ARM64 written is assembly anon, thinking of making some 3d games for it that use purely the SIMD instructions
I'm learning C++ and i'm doing problems on Project Euler to motivate that. I've noticed that every problem will overflow int and most will also overflow long long int. I made my own class of ints as vectors of digits but its clunky and probably slow so now I just use a BigInt header. Do C++ devs often experience this problem or is my situation rather synthetic
scheme edition
>>54470109
its a common problem in project euler, less so in real life. its not confined to C++, other languages will overflow in similar situations
>>54469966
So my emulator still has a black screen. I created a WebView project on my desktop and it has a black screen too. I have 90 minutes to finish this. I am really pissed off.
Rewriting the Linux kernel in a mix of C and assembly
>>54469966
>>54469977
>>54469988
>>54470100
>>54470144
I hope thats not a script.
Just started to learn how to use wireshark and that shit is amazing.
>>54470457
Forget to say the rest, What are some good projects I can work on that involve wireshark? I am working in C++.
Any good opengl tutorials?
>>54470472
Try intercepting game packets, perhaps make a simple bot
>>54470472
Implement your own network protocol on top of UDP, play with sockets and write a Wireshark dissector to check the fields of your protocol packets.
Remember: you should not send POD structs through the sockets, since padding and order in the case of bitfields is implementation-defined. Only exchange array of bytes that you may mask then to get the value of each field.
Is =< slower than plain <?
>>54470632
On bad architectures? Yes.
On good architectures? No.
>>54470518
NeHe is super ancient retro antique opengl from the early '00s and '90s but it's still worth going through. You can learn the modern opengl shit afterwards though.
>>54470144
>its not confined to C++, other languages will overflow in similar situations
No, it's pretty much confined to shitty outdated languages like C and C++.
>>54470632
Never seen it. If you are worrying about the performance difference between ja and jae you are worrying about the wrong thing.
What's the rationale behind Python's PEP-8 E731?
> Always use a def statement instead of an assignment statement that binds a lambda expression directly to an identifier.
Using a lambda conveys that the function is pure, so I always prefer it over def, if possible.
>>54470769
i would figure that jae requires more logic and more processor cycles to evaluate than ja
>>54470775f = lambda x: print(random.randint(0, x))
>>54470813
Nope. Being greater than and being equal to are computed in parallel by hardware.
>>54470833
Sure, it does not enforce it, but semantically, it conveys that is should be pure. So just don't use it for print & random.
In any case, even if you were to use it for impure functions, what's the argument for forbidding it? PEP-8 does not say?
what do you think about concepts, since gcc 6.1 now supports them.
>>54470813
>>54470862
More specifically, on x86, any comparison is made by subtracting the two arguments, that's where most cycles are spent. The difference between ja and jae is just that ja check the Zero Flag while jae does not. Shouldn't have an impact on performance.
>>54470878
>but semantically, it conveys that is should be pure
I'm still unconvinced of that, especially since this is Python we're talking about.
>what's the argument for forbidding it? PEP-8 does not say?
As written, the argument is just for a slightly better backtrace and "no need for it".
I don't think anyone would shoot you for just using a lambda, but I wouldn't bother with it myself.
>>54469966
Making 4chan moot.
>>54470273
Okay, I deployed the app and it works, but I still need to fix the emulator for future work.
>>54470100
What's a macrokernel? A monolitic kernel?
C++ or Java?
>>54471233
Definitely C++.
>>54471233
100% c++
>>54471191
Yes, it's a monolithic kernel.
>>54471233
Java jobs pay better if you're gonna do it for the money
whats a good persistent linux OS i can put on a flash drive and boot "anywhere".
as in i can go to some computer and plug in my flash drive and have it boot from it and have it -persist- so software and files I download or install STAY on the next time I boot up.
>>54471287
What language has the best impact on your sanity for the money.
>>54471313
Java is less nightmare to work with than C++
>>54471302
Puppy Linux
>>54471302
everything but tails.
>>54471323
>>54471313
Oh, sorry, I wasn't the Java, C++ guy. I meant in general.
>>54471302
Driver issues might be a pain. Why not carry portable programs on there? That's what I do.
>>54471365
Depends on you really. Some people hate brackets and love the white space in Python, other's vice versa. Some people like dynamic languages, others don't. It depends on what kind of development you like and what fits in with your 'flow' what will make you the happiest to work in.
I love working in Python but I have a job doing .NET with C# because there's just not a lot of Python jobs where I am.
>>54471233
For what purpose?
>>54471525
For being a programmer
>>54471633
By that criteria alone then both are suited to the task.
>assignment due in <12 hours
>havent started yet
>estimated time to produce is 40-60 hours
>dont feel like doing fucking anything
help
What language should I learn if I want to make 300k/year starting?
>>54471663
Drop out.
>>54471663
Better order a waifu pillow, because you're gonna become neet soon enough.
>>54471730
You need to learn an entire stack, not just one language
>>54471746
>>54471750
i dont want to fail though, i want to be productive
>>54471805
Should have started being productive 40-60 hours ago
>>54471822
i didnt have the will power
What is /dpt/ consensus regarding template metaprogramming?
https://www.youtube.com/watch?v=Am2is2QCvxY
https://www.youtube.com/watch?v=a0FliKwcwXE
>>54471860
Pretty cool, even if it was never intended.
>>54471663
What's the assignment, I'm curious.
>>54471851
>He doesn't have the spark
>>54471985
just some C++ assignment meant to test our knowledge of data structures, testing, etc, fairly dull shit desu
>>54471995
this stuff doesnt excite me anymore, anything C# or C++ bores the shit out of me. the AI modules were fun as fuck, but this stuff is dull by comparison.
>>54471860
it's honestly pretty cool, but I think Jonathan Blow might've made something better: https://www.youtube.com/watch?v=iVN3LLf4wMg
What SO do you guys use in your work machine?
>>54472128
Tbh, I'm a little excited for Blowlang. I don't think it's revolutionary, but it does look nice to write in.
why are ML-like functional languages so based
>>54472165
>SO
I use Felicity Jones.
But really I run Windows on my office computer with Linux Mint in a VM and use OS X with Windows in Bootcamp at home.
>>54472199
desu i dont even know why i like ocaml as much as i do, it's just better than almost everything else
>>54472168
me too. it feels like it'll be sort of an in-between for Rust and C, so that when i dont want all the extra shit Rust adds i'm not limited to using C/C++. although im kinda doubtful about performance at this point
I have no idea why SDL still fucks me over here.
SDL seems to think I still have locked surfaces even after the surface unlocking loop in there.
Looking through the implimentation for SDL_UnlockSurface gives no clues.
http://pastebin.com/NHAm780P
The output goes$ ./test
load BMP
blit
Surfaces must not be locked dusring blit
$
>>54471233
C++11/14
>>54471663
>>54472022
No data structures assignment could possibly take 40-60 hours unless it was a fucking term project that lasted the entire quarter/semester. Fuck what you've been told. Make yourself a pot of coffee, because you're going to do this entire fucking assignment in 6-8 hours.
Or at the very least, you'll have a product that can earn partial credit.
>>54471860
An excellent application of black magic.
>>54472326
>struct Window *win = &(struct Window){.win=tmp_win, .surf=tmp_surf};
this shouldnt compile
>>54472353
yeah, looks simple enough, ive just gotta knock up some simple node and relation data structure, a few simple query functions, and write a report on performance testing it
>>54472407
Too much fuckery with pointers and "obscure" assignment syntax?
Any sugestions? I'm still new to this.
>>54472445
you are taking the address of a temporary object, which should be an error.
you need to allocate some memory for that struct.struct Window *win = malloc(sizeof(*win));
*win = (struct Window){.win=tmp_win, .surf=tmp_surf};
return win;
and in destroy_window function you need to free that memory once you are done with it.free(win);
>>54472440
You sure it was 40-60 hours? Not 40-60 MINUTES?
Because mate, my symbol table took about 12 hours of work this weekend, and a portion of that was spent multitasking, and about a half hour to an hour of that was just spent reading YACC documentation.
>>54472510
I don't even know of an assignment that would take that long, unless he had the entire semester to do it.
>>54472510
im fairly new to C++, so i imagine its for the mistakes im likely to make on the way
>>54472609
well, kinda, im fucking awful for procrastinating
Honestly, is there anything python can't do besides be fast? It seems good at everything
>>54472488
You're a legend mate.
This has been plaguing me since last night.
So /dpt/,
When you start a new project, how much time do you spend prototyping things and identifying data relationships on paper before actually coding the stuff?
Or do you code into your text editor immediately like what most Open Source losers do?
>>54472659
pypy is fast
>>54472693
PyPy is still stuck in 2.7
Any of you nigs do swift and ios dev? I just got hired to work on an ios app and wtf man, xcode is gay as shit. How do people make apps on that shit? Fucking thing kept crashing and maxing out the 1 core it uses and giving me the spinning beachball of death when just doing some trivial auto layout tasks. I have and i7 in my macbook pro so it's not like I'm using a complete garbage system.
>>54472709
Lots of things are still stuck in 2.7, using 2.7 isn't much of a price to pay if you want excellent performance from python.
>>54472709
>implying any good code has been written in python 3
2.7 for lyfe nigga!
Can someone explain why in c++ switch statements with strings isnt allowed.
>>54472689
>how much time do you spend prototyping things and identifying data relationships on paper before actually coding the stuff?
No time, and that's why all my projects are half baked.
>>54472799
What fucking language allows strings in switch statements? Swift?
>>54472819
c# for one
>>54472819
Pretty much all of them designed sometime within the past millennium, thereby excluding C and C++.
How my professor teaches algorithms:
1. Go over formal rules of algorithm with abstract examples
2. Maybe give a concrete example in the end
How I learn:
1. See a concrete example of the algorithm being used
2. Figure out the formal rules based on what it appears to be doing
3. Check against the actual formal rules later to get a better understanding of what the fuck we're doing.
>>54472689
Depends on the nature of the project. I typically do a back and forth of jumping into code and reading documentation, and many times I do jump straight into a text editor, if nothing else to get a skeleton framework going.
As far as C++ not allowing strings in switch statements, the branch table is generated the same as in C, which does not have real strings.
Really unfortunate too, because switching on strings is very nifty.
>>54472849
I agree, I can never understand a complex algorithm until I see a worked example.
>>54472799
Same reason you also can't use a switch statement with a float. The intention is to make it easier to create a jump table, which requires integers. Otherwise, whatever you're writing is just going to be syntactic sugar for a bunch of if/else statements.
While we're on the topic of C, make sure you demonstrate to prospective employers that you are a 10X programmer via liberal application of longjmp.
How do I learn C++?
>>54472799
for you.
i was bored#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct foo { const char *str; void *lbl; };
int foocmp(const void *lhs, const void *rhs) {
return strcmp(((foo*)lhs)->str, ((foo*)rhs)->str);
}
int main(int argc, char **argv) {
__label__ sfoo;
__label__ sbar;
__label__ sbaz;
if (argc != 2) return 1;
foo jmp[] = {
{"bar", &&sbar},
{"baz", &&sbaz},
{"foo", &&sfoo}
};
foo tmp = {argv[1], NULL};
if (foo *res = (foo*)bsearch(&tmp, jmp, 3, sizeof(*jmp), foocmp))
goto *res->lbl;
printf("no match\n"); return 1;
sfoo: printf("foo matched\n"); return 0;
sbar: printf("bar matched\n"); return 0;
sbaz: printf("baz matched\n"); return 0;
}
>>54472953
I hope no one actually deploy this in their products
>>54472953
>GNU Extensions
farkin dropped m8
whats the min requirement level for employable status ?
Hi /dpt/, does anyone here have experience with Matplotlib, or more specifically, pyplot, in Python3? I'm doing an assignment for university and I'm having trouble with making a bar chart where the categories line up properly, as shown in the image. I actually suspect it might be something to do with numpy's arrange method. I can provide code on request.
>>54472807
this, my projects ARE the prototypes
whats the most sensible way of splitting a CSV file in C++? id normally split once on newline and for each line again on ',', but it seems C++ has no string split method. i cant use any libraries other than the ones that come with MSVC++ 2013
>>54473163
really low for most companies
hardest part is getting an interview since you need to stand out among the other 300+ people
When copying a file with C++, how do I handle special characters like n with a tilde and what not.
I get
>Vijñāna
to
>Vijรฑฤna
Which is even worse because its rendered as A+A
>>54474061
probably an encoding issue, try using utf-8/16 instead of ascii
How do I split a lookup table across 2+ lines?
Currently, I have a single string literal that's 97 characters long and I'd like to split it in half for readability.
is this sensible?//just assume these are good
fstream finPlaces(fileNamePlaces);
fstream finLinks(fileNameLinks);
//compose vector of places
vector<vector<string>> output;
const int buffersize = 255;
while (!finPlaces.eof()) {
//get line
stringstream ss;
char lineBuffer[buffersize];
finPlaces.getline(lineBuffer, buffersize);
ss << lineBuffer;
//compose place vector
vector<string> line;
while (!ss.eof()) {
char wordBuffer[buffersize];
ss.getline(wordBuffer, buffersize, ',');
line.push_back(wordBuffer);
}
output.push_back(line);
}
>>54474171
you can use strings instead of char[]
also some other stuff.string line;
while (getline(finPlaces, line)) {
stringstream ss{line};
vector<string> lines;
while (getline(ss, line, ','))
lines.emplace_back(move(line));
output.emplace_back(move(lines));
}
>>54474454
could you explain the changes youve made, senpai?
>>54474171
>is this sensible?
>C++
No.
>>54474469
i know man, but an assignment is an assignment, even in a language with no proper fucking string splitting method or function out of the box
>>54474487
Fucked up the whitespace.
>>54474166
Assuming C
char str[] = "abcdefghijklm"
"nopqrstuvwxyz";[/code]
>>54474171string line;
while (getline(finPlaces, line)) { // store line in `line`, returns false if eof or some other error.
stringstream ss{line}; // initialize streamstream with said line
vector<string> lines;
while (getline(ss, line, ',')) // same as above getline but with , separator
lines.emplace_back(move(line)); // move line to end of lines vector
output.emplace_back(move(lines)); // move lines to end of output vector.
}
>>54474468
>>54474509
whoops
Can someone give me a hand with this? It should be fairly straightforward but I'm struggling.int degrees = 32;
double minutes = 9.35;
How do I combine these variables to get something like 32.0935? It should also return 32.1035 if minutes was set to 10.35 for example
>>54474533
its C# btw
>>54474533double val = degrees + minutes / 100
>>54474509
oh rather, streams have anoperator boolwhich returns false if there is an error.
>>54474542
thank you, i knew it was something simple
>>54471233
Lisp.
>>54471233
depends
>>54471365
>>54471287
java
How do you catch errors the command prompt throws.
So if system(stuff) fails how do I catch the error.
>>54469966
Lightweight QT5-based SQL Manager.
Progress has been slow lately.
>>54474509
does that terminate on eof though?
>>54474632
if you're calling a process, and it fails then it'll return an abnormal exit code and based on that exit code you can know what error it encounters https://en.wikipedia.org/wiki/Exit_status
>>54474650
Look awesome!
>>54474653
ya. trying to read a stream when its at eof sets its fail bit, which makes it return false when converted to a bool.
>>54474650
Looks really fucking slick. What lang?
>>54474726
Dude said QT5, so C++.
>>54474650
That looks really slick senpai.
>>54474739
>QT5 automatically means C++
It's 2015, fella.
>>54474650
Q U T E
U
T
E
>>54474751
muh aliens
>>54474751
Tbh, if you're using a binding, you can probably find something more efficient in the language of your choice.
So I made a really cool program that does the stuff I want. But how do I give it an icon. Furthermore I changed the associated files to open with this program and I want to change their icons as well.
Is this easily done or is it an os dependent programming thing.
Anyone here an expert in computer destoyeering?
>>54474788
Probably, but still, it's worth asking.
>>54474786
Everybody thinks Heaven's Gate were crazy cultists, but they were probably right.
>>54472894
Not really.
There are smarter ways to do things like string switches.
>>54472894
why is that a bad thing
if/else look uglier anyway
>>54474810
>Everybody thinks Heaven's Gate were crazy cultists, but they were probably right.
About what? The earth being recycled or them ascending to hale bopp to hang out with ayy lmaos?
>>54474798
should add its in visual studio for c++
>>54474862
>them ascending to hale bopp to hang out with ayy lmaos?
This part. We are now living in purgatory. I wanted to go on the secret hale-bopp space ship, but I was too young to know.
Wherefore art our ayylmao overlords? I pray their return before I've shuffle'd off this mortal coil.
>>54474891
I see you a lot around these threads, who are you? What do you do?
>>54474952
He's just some filthy racemixer from /o/. You shouldn't take anything he says seriously.
>>54474952
>who are you?
Professional racemixer.
>What do you do?
Design memelangs by stealing ideas from Clojure.
>>54474810
>Everybody thinks Heaven's Gate were crazy cultists, but they were probably right.
Superior 90's cult incoming.
>>54474997
I don't discriminate.
Okay, so I have two laptops. Both running AMD graphics cards. One running OpenGL 3.1.11653 with GLSL 3.30 and one running OpenGL 3.1.13416 and GLSL 4.40. The shaders I created on the 3.30 laptop won't run on the 4.40 laptop. Can I get some suggestions? I'm not good with portability.
Pic related is one of the shaders. As I said it works on the 3.30 but not on the 4.40. The application itself runs but nothing renders so I am more than certain it is a problem with the shaders. Am I using something that was removed or changed or some shit between those two verions?
>>54475122
since when are float literals supposed to have the f? try removing the f like 1.0 instead of 1.0f. and you can use glGetShaderInfoLog or shdr.bkcore.com
>>54475171
I'll give it a shot.
>>54474650
It's in C++.
Hoping to have it stable in about a month.
After that, I want to add tabbing for the table explorer and queries.
Will post here when it's done.
Dicking around with SVMs in python for an uni project.
Glad python has a shit ton of libraries for this kind of stuff
Quick what's your title on your business card? Can't choose between "Guru" or "Ninja"
continue testing
>>54475237
>what's your title on your business card?
Software Engineer & Jewish Racemixing Propaganda Expert
>>54475280
> Racemixing Propaganda Expert
> Jewish
superfluous
>>54475237
>his job title isn't Software Magus
Stay pleb.
>>54475280
I'd hire you for having balls.
>>54475698
The fact that you'd hire someone that tripfags on 4chan is probably part of the reason you'll never be in the position to hire anyone.
>>54475698
Don't be so sure of that. I'm only an expert on the propaganda because I fell for it.
There is no cure.
wat
ignoring the stupid warning ive created, what on earth is causeing these errors?static vector<vector<string>> ComposePlacesList(fstream &finPlaces)
{
/*
* iterates through CSV til EOF, composing vector of vectors as it goes along
*/
//compose vector of places
vector<vector<string>> output;
const int buffersize = 255;
while (!finPlaces.eof()) {
//get line
stringstream ss;
char lineBuffer[buffersize];
finPlaces.getline(lineBuffer, buffersize);
ss << lineBuffer;
//compose place vector
vector<string> line;
while (!ss.eof()) {
char wordBuffer[buffersize];
ss.getline(wordBuffer, buffersize, ',');
line.push_back(wordBuffer);
}
output.push_back(line);
}
return output;
}
static vector<Node *> BuildPlaces(vector<vector<string>> placesData)
{
vector<Node *> nodeList;
for each(vector<string> ni in placesData) {
nodeList.push_back(new Node(ni[0], stoi(ni[1]), stoi(ni[2]), stoi(ni[3])));
}
return nodeList;
}
calling functionbool Navigation::BuildNetwork(string fileNamePlaces, string fileNameLinks)
{
fstream finPlaces(fileNamePlaces);
fstream finLinks(fileNameLinks);
if (finPlaces.fail() || finLinks.fail()) return false;
// Add code here
// todo: refactor into a BuildNodeFactory
vector<vector<string>> placesData = BuildNodeFactory::ComposePlacesList(finPlaces);
vector<Node *> places = BuildNodeFactory::BuildPlaces(placesData);
return false;
}
>>54475122
Target ONE OpenGL version (3.1 for example), you can set the opengl version during context creation.
Then write all your shaders in the corresponding shader language.
They should work even if you have a newer version opengl. As long as you create a opengl 3.1 context.
Also don't use if statements in shaders if you don't have to.
>>54475938
This is a prime example of why c++ is shit and you should stick to C
>>54475951
i know man, but deadlines and shit
>>54475938
"for each" isn't written like that in C++.
And you need to qualify your static functions:
ComposePlacesList should be
BuildNodeFactory::ComposePlacesList
in your first snippet, if it's a static method of BuildNodeFactory.
lrn2c++
>>54475938
Also, if BuildNodeFactory is actually a namespace, then the static keyword shouldn't be there, since it won't be linkable.
Actually, the static keyword should be only in the class declaration, remove it from the definition.
>>54475944
I'm kind of noob when it comes to portability.
So do I just set major to 4?glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR,3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR,1);
glfwWindowHint(GLFW_OPENGL_PROFILE,GLFW_OPENGL_ANY_PROFILE);
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT,GL_FALSE);
>>54475944
you still need to get the shader code right, implementations vary a lot, and some can allow things that are not part of the standard, so if it works on your machine it might fail on other machines
>>54476008
>>54475992
sorry, ive been up a while and im being retarded
i basically just want a factory class
>>54476018
Try setting GLFW_OPENGL_PROFILE to GLFW_OPENGL_COMPAT_PROFILE
A core profile removes all pre 3.3 stuff.
Though opengl should create a compatibility profile by default iirc but like >>54476043 said, implementations might vary.
Also, Do you output errors when you compile and link your shaders?
>>54475951
>stick to C
Where string manipulation is even more onerous.
>>54476081
Not if you know what you're doing.
>>54476091
>Says the person who took a dump on C++ for being confusing
Not if you le know what your doiong.
>>54476099
>confusing
But C++ legitimately is a fucking mess. I'm saying this as a lifelong C++ programmer who switched to C for personal projects after years of C++.
C strings might indeed be a little more error prone if you're not paying attention, but everything is still straightforward and easy to understand.
A string type in C would indeed be on top of my C wishlist, but it's not worth using C++ for imho.
>>54476125
>A string type in C would indeed be on top of my C wishlist
Yeah, that's probably never going to happen, at least in standard C. It doesn't really 'fit' with the rest of the language, and the C standard committee tries to avoid duplicated functionality.
>>54476164
I know
>>54471302
Porteus
>>54476055
Okay I tried that as well as changing all the operators to straight up assignments rather than +/- assignments. Also the infolog is returning 0. For all intents and purposes this shit should work, but it doesn't.
Also I made it with MinGW on Windows 7 and am trying to get it to work on 8. Earlier applications I made work on the Windows 8 machine but have bare bones shaders that basically do nothing but straight up render what is passed to them.
>>54474650
>>54475208
Looks really nice.
That being said, I'd never trust a 3rd-party SQL manager unless it was already super vetted, like SQL Yog.
I'm curious to see how yours works as far as GUI goes. Is each tab a separate connection?
If so, why is there only one query tab per connection?
>>54476125
>everything is still straightforward and easy to understand.
Sure, that's why things have to be deprecated every once in a while when someone realizes they're awful.
Enjoy your strtok, I guess.
>>54474805
>babby's first fork bomb
>doesn't affect *nix
1/10, see me after class.
>>54476209
Honestly I have no clue. The only thing I can think of is that it doesn't support older opengl versions which would be EXTREMELY odd.
You could try an opengl 3.3 context and glsl 330 shaders.
Why are you going for opengl 3.1 anyway? It's an odd version to support anyway. People usually either support 2.1, 3.3 or a later version if they need certain features.
>>54476273
Those are just the version that are on these two machines.
>>54476315
No, you say you have glsl 3.3 on one machine. That corresponds with opengl 3.3
Meaning you can support at least opengl 3.3.
cocks
>>54476257
>Sure, that's why things have to be deprecated every once in a while when someone realizes they're awful.
Everybody knew that gets() was awful the entire time. They just had to standardise it because it was common at the time.
C string handling is much nicer if you allow yourself to use non-standard functions (particularly those from POSIX), but even then, it's not terribly difficult to implement good C string handling yourself,
>>54474891
>Wherefore art our ayylmao overlords?
If you were attempting to mimic Juliet's quote in R&J, 'Wherefore' is actually used as 'Why?'
As in, "Why are you Romeo?", lamenting the fact that he was a Montague.
>>54475938
What is this code supposed to accomplish?
My hunch says you're just retrieving data from a CSV, but surely it's not that complicated in C++, right?
>>54476333
Not according to glGetString.OPENGL VERSION: 3.1.11653 Compatibility Profile Context
COMPANY: ATI Technologies Inc.
RENDERER: ATI Mobility Radeon HD 4200 Series
GLSL VERSION: 3.30
>>54476339
ive been up for 25 hours and i skipped most of my lab work, it aint hard, im just bordering on braindead and going off what i can remember from lectures
>>54476354
Because you set GLFW_CONTEXT_VERSION_MINOR to 1.
If you specify nothing you get the highest version available on you machine.
Try setting GLFW_CONTEXT_VERSION_MINOR to 3.
>>54469966
Math expression parser.
Nim seems like everything I want in a programming language. Is it too obscure to be of any real use or is learning it worth it.
>Year of the God Emperor of Mankind MMXVI
>still no support for enums in SQL
/dpt/-chan, daisuki~
Ask your much beloved programming literate anything (IAMA).
>>54475951
>>54476091
reproduce this in C#include <iostream>
using namespace std;
string cat(string a, string b)
{
return a + b;
}
int main()
{
cout << cat("123","456") << endl;
return 0;
}
https://ideone.com/YeF8H8
>>54476459
Just a warning Nim unstable as fuck and has a ton of gotchas.
>>54476491
Thanks man.
>>54476385
Is that what you're doing though?
Just reading data from a CSV?
I know you're in a C++ class, but that's a one-liner in C#.var data = ReadAllLines(@"C:\temp\Faggotry.csv").Select(row => row.Split(','));
I'm curious if the C++ solution is much simpler.
>>54476480
By reproduce, I assume you mean write a program which exhibits the same external behaviour.#include <stdio.h>
int main()
{
puts("123456");
}
>>54469966
Implementing file system(ext2 subset) for a simple self-made OS.
>>54476525
yes
i know, however C++ hates convenience, so i have to parse that shit manually it seems
>>54476531
Try the webdevs.
>>>/g/wdg
>>54476563
Oh, thanks. I missed that thread.
>>54476550
Do this, then.#include <iostream>
using namespace std;
string cat(string a, string b)
{
return a + b;
}
int main(int argc, char **argv)
{
if (argc == 3)
cout << cat(argv[1], argv[2]) << endl;
}
>>54476575
>A valid solution is offered
>Reject it because you're a fucking idiot who didn't phrase the question properly
You're one of the worst posters in this thread.
Who const nazi here?
>>54476477
How would that work?
>>54476563.boardBanner {
position: fixed;
}
>>54476600
Heil!
>>54476592#include <stdio.h>
int main(int argc, char *argv[])
{
if (argc == 3)
printf("%s%s\n", argv[1], argv[2]);
}
I don't know why you're bothering with your pointless cat function.
>>54476597
>Interpret question however you want
>YOU DIDN'T FRASE IT CORRECTLY, HERE IS SOMETHING THAT DOES SOMETHING ELSE ENTIRELY BUT PRODUCES THE SAME RESULT THEREFORE IT'S THA SAME
>>54476616
>BUT PRODUCES THE SAME RESULT THEREFORE IT'S THA SAME
Yes?
>>54476600
I just can't forgive that const isn't default.
You should signal mutability, not the other way around.
>>54476477
>enums in SQL
?
https://play.google.com/store/apps/details?id=eu.depa.captionr
Mine
>>54476600
I literally never use const
>>54476625
You're right. Okay I'll make a more efficient program in C++.#include<iostream>
using namespace std;
int main()
{
cout<<"123456";
}
There you go. It doesn't do what the original program did but who gives a shit, it produces the same result. I win.
>>54476625
Do you not know the difference between a process and state function?
>>54476629
Given that C++ is old as shit, I'm just grateful they added it.
>>54476650
>it produces the same result.
It's missing the newline.
>I win
Win what? Was there supposed to be some sort of competition?
>>54476480
// assumes valid c strings and that buf if big enough
void cat(char *buf, char *s0, char *s1)
{
char tmp;
size_t ind = 0;
while(tmp = *s0)
*(buf + ind++) = tmp;
while(tmp = *s1)
*(buf + ind++) = tmp;
*(buf + ind) = '\0';
}
int main(void)
{
char s0[4] = "123";
char s1[4] = "456";
char buf[7];
cat(buf, s0, s1);
puts(buf);
}
>>54476669
The aim of the original program wasn't to just produce "123456" by any means you fucking sped.
>>54476597
i never said anything about output, i asked him to "reproduce this" where "this" is the code.
>>54476480#include <stdio.h>
main(){return puts("123456");}
>>54476612
>formatted printing for a simple format
Disgusting.
But you make a point, I shouldn't have based off his example.
The obvious thing is that I can't ask you to reproduce a program, since you can just extract its external behavior and reproduce it.
rewrite instead the cat function with char * instead of string, note that the parameters are mutable copies, you can use the stdlib of course.
>>54476678
>>54476693
If I am going to reimplement a program, why do I have to stick to the horrible design decisions in the original? All that matters is that the output is the same.
>>54476699
Mine is shorter. I win.() => "12345\n"
>>54476722
>>formatted printing for a simple format
>Disgusting.
Format strings is way fucking better than meme++ streams. There is a reason why pretty much every language besides C++ uses format strings.
>>54476729
>12345
>>54476673
lel, wtf
This thread made me realize that I will never again willingly choose to program in C or C++.
What is the API for fuuka archives like rbt.asia?
>>54476629
>You should signal mutability
>You should literally prefix all of your declarations with "mutab" except for a few of them.
>>54476740
Printf is an equal part of c++ alongside streams.
>>54476812
If the vast majority of your state is frequently changing, you are doing it oh so wrong.
>>54476480
<code>
#include <string.h> /* memcpy() */
#include <stdio.h> /* printf() */
#include <stdint.h> /* uint*_t */
#include <stdlib.h> /* malloc() */
char *cat( const char *a, const char *b )
{
uint64_t len_a = strlen( a );
uint64_t len_b = strlen( b );
char *ret = malloc( len_a + len_b + 1 );
memcpy( ret, a, len_a );
memcpy( ret+len_a, b, len_b );
ret[ len_a + len_b ] = '\0';
return ret;
}
int main()
{
printf("%s\n", cat("123", "456") );
return 0;
}
</code>
>>54476747
:^)
/g/ what are your thoughts on Firebase for mobile apps (beyond all the troll and meme replies)?
>>54476837
Nice code tags, nerd.
>>54476722
Lets add an obscure C feature.#include <stdio.h>
#include <string.h>
void cat(const char *s1, const char *s2, char out[static strlen(s1) + strlen(s2) + 1])
{
while (*s1)
*out++ = *s1++;
while (*s2)
*out++ = *s2++;
*out = '\0';
}
int main()
{
char s1[] = "123", s2[] = "456";
char buf[strlen(s1) + strlen(s2) + 1];
cat(s1, s2, buf);
puts(buf);
}
>>54476824
C++ users encourage you not to use it, despite the fact that the C stdio is clearly better.
>>54476848
I've been seriously considering a Firebase + FireSharp + Xamarin solution for a while.
It's certainly an easy way to let someone else deal with all of the little 'gotchas' of DB I/O.
>>54476854
>gnu extension
>obscure c feature
>>54476854
not equivalent.
C++ strings are movable, your solution doesn't exhibit this behavior, since your string is allocated on the stack.
>>54476878
my potential setup is
NativeScript on Node.js + Firebase
was learning Java then heard of NS and now checking it out. thinking NS + FB = smooth dual/tri/quad deployment.
what is still unclear to me is whether i need to write in js or angular2 or both.
>>54476889
>gnu extension
It's not a GNU extension.
http://www.open-std.org/jtc1/sc22/WG14/www/docs/n1570.pdf
>6.7.6.2 Array declarators
>Page 131
It's right there in the grammar. I can't really be bothered finding the semantics though.
>>54476900
>since your string is allocated on the stack
My string can be allocated wherever it wants to be.
User-supplied buffers are a much better idea than handing a new one back. It's far less restricting.
My version is better because it CAN have automatic lifetime, while yours can't.
>>54476937
touché
>>54476854warning: ISO C90 does not support ‘static’ or type qualifiers in parameter array declarators [-pedantic]
>>54476673
>>54476837
>>54476854
those are really shitty compared to c++, you have to manage the lengths of the strings by yourself, you have to manage the output size or rely on dynamic memory, you have to parse the strings, ... the complexity of the code is definitively much higher than with c++.
>>54476971
use c11 gramps.
>>54476971
Mate, the current standard is C11. Get with the fucking times.
>>54476982
>you have to manage the lengths of the strings by yourself
>you have to manage the output size
Not hard. Also, the function doesn't give a fuck about the string lengths, only that the output is big enough.
>rely on dynamic memory
No? My code doesn't use dynamic memory. Also, what do you think std::string uses?
>you have to parse the strings
There is literally no parsing going on in my code.
>the complexity of the code is definitively much higher than with c++
A fucking array copy is hardly 'complex'.
Here is a slightly nicer version for you then.void cat(const char *s1, const char *s2, char out[static strlen(s1) + strlen(s2) + 1])
{
sprintf(out, "%s%s", s1, s2);
}
I have now hidden the complexity behind a function.
>>54477031
>use c11 gramps.
>>54477034
>Mate, the current standard is C11. Get with the fucking times.
your code is not portable. period.
>>54477049
>your code is not portable. period.
It's portable to any C11 compiler. My program doesn't rely on any implementation defined behaviour.
Your shitty C89 code isn't portable to my strict C11 compiler.
>>54477049
Not even trying to program portable code faggot.
>>54477065
>Not even trying to program portable code faggot.
cry more you fucking webdev
>>54477060
>strict C11 compiler
pajeet, shouldnt you be in the windows10 or nvidia thread right now?
>>54477092
That's C code and it does not run on browser you fucking retard.
>>54477101
You're literally spouting memes at this point.
What does C11 have to do with any of those things?
my /g/entooman friend is working on an msys2 cmatrix, if this has been done before please let me know
>>54477111
C11 was invented by M$
>>54477124
(You)
>>54477110
really? wow
>>54477124
MSVC does not even support C99.
>>54477034
>No? My code doesn't use dynamic memory. Also, what do you think std::string uses?
the implementation doesn't matter, for the user, std::string's memory is automatically managed. in C, you have to manage the scopes by yourself.
>>54477034
>I have now hidden the complexity behind a function.
except that's not a function but a procedure (doesn't return anything = not evaluable = not an expression).
composition of expressions is much easier with c++ than with c (eg:string res = cat(cat("a", "b"), cat("c", "d"))).
please, don't use C anymore.
>>54477236
>the implementation doesn't matter
It does though. You need to understand what you're using, so you don't go and do a whole bunch of inefficient shit.
>in C, you have to manage the scopes by yourself
So? It's not hard. Explicit resource management allows you to do it more efficiently.
>doesn't return anything
sprintf does return something. I just choose not to use it.
>cat(cat("a", "b"), cat("c", "d"))
[/code]sprintf(buf, "%s%s%s%s", s1, s2, s3, s4);[/code]
Your code makes 3 new allocations. Mine makes 0.
>composition of expressions
Not important. My code has the advantage of being able to be allocated anywhere. Yours can only return a new allocation.
>>54476592
>save code as bugger.cxx
>clang++ bugger.cxx
>valgrind a.out
==9994== Memcheck, a memory error detector
==9994== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==9994== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info
==9994== Command: ./a.out
==9994==
123456
==9994==
==9994== HEAP SUMMARY:
==9994== in use at exit: 72,704 bytes in 1 blocks
==9994== total heap usage: 1 allocs, 0 frees, 72,704 bytes allocated
==9994==
==9994== LEAK SUMMARY:
==9994== definitely lost: 0 bytes in 0 blocks
==9994== indirectly lost: 0 bytes in 0 blocks
==9994== possibly lost: 0 bytes in 0 blocks
==9994== still reachable: 72,704 bytes in 1 blocks
==9994== suppressed: 0 bytes in 0 blocks
==9994== Rerun with --leak-check=full to see details of leaked memory
==9994==
==9994== For counts of detected and suppressed errors, rerun with: -v
==9994== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
>g++ bugger.cxx
>valgrind a.out
>same result
can you do this in c++ without allocating ~70kB of memory?
I'm falling for the IntelliJ meme. Does this mean I can't use Spring or Gradle on my projects if I install the Community Edition?
>>54477373
That's not the c++ code's fault. Test withint main() { return 0; }. You still get that 72 KB, likly some prereload library valgrind uses.
>>54477446
What was the paying scheme again?
>>54477464
>likly some prereload library valgrind uses
Valgrind only records shit that the program does. The memory is probably related to memestreams.
>>54477446
rather than bother waiting for a response here, why not just pirate the Ultimate Edition and get it over with
>>54477496
on a program with nothing but main+return 0:valgrind --leak-check=full --show-leak-kinds=all ./simple
==18462== 72,704 bytes in 1 blocks are still reachable in loss record 1 of 1
==18462== at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==18462== by 0x4EC3EFF: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21)
==18462== by 0x40104E9: call_init.part.0 (dl-init.c:72)
==18462== by 0x40105FA: call_init (dl-init.c:30)
==18462== by 0x40105FA: _dl_init (dl-init.c:120)
==18462== by 0x4000CF9: ??? (in /lib/x86_64-linux-gnu/ld-2.23.so)
>at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
I think you're wrong.
>>54477527
Pirating is bad bruh
>>54477446
First of all, on your screenshot it says you can use gradle with community just fine.
Second: https://www.reddit.com/r/java/comments/2qo2rn/spring_with_intellij_community_edition/
>>54477530
>vgpreload_memcheck-amd64-linux.so
That's just the file where valgind defines it own version of malloc (using LD_PRELOAD).
The line right below that is
>==18462== by 0x4EC3EFF: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21)
>>54477565
I meant Grails
>>54469966
Could you please stop posting this annoying OP picture?
>>54477530
are you fucking stupid?
>>54476678
i dont understand, how do i write to this? it looks initialised to me, but i cant seem to access it from within the class, it tells me its undefined//header
private:
ofstream m_outFile;
//constructor
Navigation::Navigation() : m_outFile("Output.txt")
{
}
>>54477669
fuck, didnt mean to quote >>54476678
why is reading code more difficult than writing code
>>54477784
If the code is well written it's not too hard. And it get's a lot easier with experience.
>>54477784
Because people overlook one of the most important things when writing code, for he heck of makkin it werk.
As a famous person said, I'm not good with names, code should be written for humans to read, and only incidentally for computers to execute.
Code should be easy to debug and easy to mantain, and not just work. But you'll have a great time exlaining to your boss that you need to add 10% to clean your code and some 20% mopre to write the tests.
Paradoxiacally it will be harder for your manager to fire you if you're the only one who can put their hands in a messy codebase.
tradeoffs, tradeoffs....
>>54477784
people are terrible at writing code
>>54477784
It's not if you're part of [insert masterrace name here].
>>54477784
I have the exact opposite.
How can reading a book be more difficult than writing a book?
>>54476480printf("123" "456" "\n");
>>54478138
no coma?
>>54478159
yes
>>54476854
holy fucking shit what is this atrocity
>>54469988
Does this work? What would i["]<i;++i){--i;}"] give you?
>>54471663
>assignment due in <10 minutes
>haven't even figured out what a computer is
>estimated time to produce is 10 fortnights
>dont feel like fucking doing anything
>>54478447
it is i'th character of "]<i;++i){--i;}" array. a[i] and i[a] is samething in C. OP does "]<i;++i){--i;}"[i]. loop iterates until null character
>>54469966
Hey /g/, not sure if i should have posted this in the stupid questions thread but i'm here now.
Doing an assignment in C#
How would I make this search method detect say matching characters instead of having to type the whole thing?.
I would normally just use some kind of substring but that method is too specific because the input changes constantly.
This is probably simple but i really can't fucking figure this out.for (int I = 0; I <= 99; I++)
{
if (Records[I].RecipientName == Response2)
>>54478504
Holy shit
I never knew that until just now. That's the most insane bit of C syntax I've ever seen hahahah
Well done, anon. You taught me another way I can fuck with people using obfuscated C/C++ code
I've got another VBA issue; I figured out how to implement the "attachment based on user selection" bit but in the same step I've also messed up; when the program composes the email, it reassigns the original contents of the selection to the filepath of the attachment because I have:List1.List(0) = "[filepath]"
List1.List(1) = "[filepath]"
List1.List(2) = "[filepath]"
' et cetera
How can I change this so the list items stay as they are by default but retain their association with their attachments?
Still torn between Java and C++. I already know C and Python for basic data struc and algorithm shit. But for real world applications, I still don't know what to use. I probably should learn both I have to dedicate some time for the first one
>>54478815
you can use both for real world programs. It completely depends on the kind of work you think you'll end up doing.
>>54478848
Actually I just want to be a systems programmer
>>54478865
That's a little broad. I would say learn C++. It's pretty widely used and everything else is pretty easy to learn after it.
Maybe that's just a personal preference. I find Java kind of depressing.
hey buds, new to programming here (c++). would some kind soul help me with "lists"?
i'm trying to create a book list where the user can write the title of multiple book sand store it.
also, how do you search for certain words. i want to make a search function, too, but have no idea how.
thankful for any help whatsoever.
>>54478893
I heard C++ is kind of a pain to learn. I think I might go play with Java a little bit
>>54478907
It is. There's no harm is learning both at the same time, switching from one to the other. Stuff you learn in one will improve your skills in the other.
>>54478923
Yea I'll do that I guess since I also want to do GL stuff that isn't Java
>>54478959
OpenGL? There's OpenGL bindings for Java.
>>54478978
No I don't want to work with Swing. I'd rather with Windows UIs
>>54479002
You sound very confused. You should probably stop programming.
>>54479002
Considered C#?
>>54479027
I'd like to be close to the metal when learning with GL
>>54479065
You mean OpenGL? What's GL?
I'm having a hard time understanding pointers in C++, and got killmyself/10 on my midterm.
Given this main:int main ()
{
cout << number() << endl;
}
This method prints a memory address:int *number()
{
int a = 50;
return &a;
}
Makes sense to me, & points at the memory address. Although I have no idea what the deference pointer in the method signature means.
This method prints the number 50:int &number()
{
int *a = new int (50);
return *a;
}
Once again, makes sense. Deference operator can be read as the value pointed at by a, which is 50. However, once again, I don't know what the & is doing in the method name.
This one gives an error:int &number()
{
int a = 50;
return &a;
}
I don't know why this is. I'd expect it to return the memory address.
Sorry if it's not appropriate to ask hw kind of questions in here, but any help would be neat.
>>54479071
whatever graphics library is available
>>54479002
>derp
you don't use UI frameworks like that for opengl, you just get a (full screen) rendering surface
use something like
http://jogamp.org/jogl/www/
or whatever
How do you make an API and how do you test them?
>>54479091
int a = 50;
return &a;
this is wrong because you are returning an address on stack and it is undefined behavior to access that address when it goes outside of scope.int &number()
{
int a = 50;
return &a;
}
this returns a reference to int (int&) it is similar to pointers. google c++ references. they are used like values but works like pointers.
What is the best tutorial for multi-threading in C++?
>>54479132
OpenGL and swing are very different things.
You sound like someone who does not even know basics on programming. you really should on learning languages at this point. If you are new and start with C++ and opengl, you will be lost
>>54479266
No I meant to say I'm not comfortable working with Swing since you'll use it to display the graphics if I know correctly.
>>54479295
>since you'll use it to display the graphics if I know correctly.
not sure. It's just one of many ways to draw to the screen.
>>54479244
Sorry, I'm confused. In both instances, are you referring to the same method?
>>54479295
no no no
you don't have to use swing at all for opengl
see https://www.opengl.org/wiki/Language_bindings#Java
>>54479336
Waitm what do you use for the Windows and stuff then?
>>54478475
yup
>>54479374
magic
>>54479374
OpenGL works on windows.
>>54479324
on the first one I was referring toint *number()
{
int a = 50;
return &a;
}
This is wrong. Accessing the pointer returned by this function is undefined behavior. It is likely that value on that address will be overridden when you call another function. You shouldn't return address on stack.int &number()
{
int *a = new int (50);
return *a;
}
This is correct. number returns int&, which is an int reference. since int *a is allocated dynamically, it won't be invalid when function returns and a reference to &a will be valid.int &number()
{
int a = 50;
return &a;
}
this is a compile error because you are returning an int pointer but function returns int&. It would probably compile if you used return a but again that would be UD when a goes out of scope.
As I said, read about what are references and what are pointers. How they are used and what are the differences.
>>54479391
No i meant windows and menus
>>54479412
OpenGL runs inside windows. You sound very confused.
>>54479374
Here are some popular GUI libraries.
https://en.wikipedia.org/wiki/List_of_platform-independent_GUI_libraries
new thread when?
>>54478569
Cmon guys, please bite just this once.
I have been up far too long and just want to get this done.if (Response2 == Records[I].RecipientName)
if (Response2.Substring(1) == Records[I].RecipientName.Substring(1))
if (Response2.Substring(2) == Records[I].RecipientName.Substring(2))
if (Response2.Substring(3) == Records[I].RecipientName.Substring(3))
I tried using a markov chain type thing but am getting exceptions, if i use something like this but catch the exception would it work?
>>54479431
So Java applications dont need swing to draw OpenGL shit? They just include windows on their own?
>>54479410
>reference to &a will be valid.
I meant *a
>>54479459
You should probably stop posting. You sound like a retard
>>54479459
Yes anon. Swing is just a UI library. There's many Ui libraries for Java.
>>54478569
>>54479452
I'm not too clear on what you're trying to do here.
Can you give example input + output?
>>54479521
Sure.
The user would input a first and last name which is then stored into an array.
Then in the search method I have been able to execute if and only if the input matches the stored array exactly with this
Recipient name = The exact stored name
Response2 = user input (No shit I know)
[code if (Records[I].RecipientName == Response2) [/code]
What I am trying to do now is set it up so that it will work say if you only put in the first name, the problem is the length of the names changes every time so setting exact sub string parameters is difficult.
Any ideas?
>>54479594
Just useContains().if (Records[i].RecipentName.Contains(Response2))
Also, you could use LINQ here instead of that for loop.foreach(var name in Records.Select(x => x.RecipientName))
{
if (x.Contains(Response2))
{
//do thing
}
}
or...foreach(var record in Records)
{
if (record.RecipentName.Contains(Response2))
{
//do thing
}
}
How do I add my own custom autocomplete templates in atom? cant find shit on the web about this
>>54479091int a = 50;
Both methods with this line have the same potential problem, otheranon is trying to point it out, but it's not directly pointer related so maybe let's put that aside.
The useful rule of thumb you're missing IMHO is this: in C++, declaration syntax reflects usage. It's true that &a can be used to create an int* and vice versa, but this is effectively not usage. Instead, think of it from outside of the number function: you're not concerned with how the value was generated, you're concerned with what you will do with it and the type gives you a hint. If it's a pointer, say double*, you know that if you apply the dereference (*) operator, it will lead you to a double. Array synrax and function pointer have tge same property btw. If you see an int&, it's a bit more twisted, but it's consistent, see next post.
>>54479594
>>54479652
Also, it looks like you may benefit from grabbing all of the records with a matching name.
You could do something like this:var matchingRecords = Records.Where(x => x.RecipientName.Contains(Response2));
Now you have an enumerable with all of the matching Record objects based on the user input. Not sure if you're trying to compare to a specific record every time.
>>54479663
>atom
So say I want to save a file directory chosen by the user. Should I create a text doc or something to keep track. Like whats the accepted way of tracking things like this.
>>54479652
>>54479685
I really feel like an asshole, thanks for the spoonfeed there.
That should work perfectly.
>>54479689
You can use a config file, which is basically a text file.
On Windows, you'd generally store this under User->AppData.
You could also utilize (read: abuse) a registry hive to store all of your settings, but that's a pain in the dick to make cross-platform to *Nix systems.
Hell, Chrome uses a bastardized SQLite file for history and the like.
The sky is the limit, anon.
>>54479715
It's alright anon.
Don't be afraid to suck that LINQ dick every now and then.
It makes dealing with objects trivial, because you can enumerate straight to their properties.
PROTIP: If you ever find yourself nesting IF statements with an incrementing thing, you're probably doing something horribly wrong. It's good that you recognized that instead of trucking through.
>>54479687
i like the theme, don't really mind anything else
>system() is evil
Why the fuck is that. How the hell are you supposed to use the command prompt without system. How am I supposed to open other exes with parameters.
>>54479769
Because it's not the same on all platforms.
Your library/program/whatever immediately is forever locked down to that OS.
>>54479783
>hooked
>>54479754
vim has literally any theme you can think of. Why not use that instead?
Hey /g/entlemen,
I'm a retarded seagull and I don't know how to code. Can someone please help me make this shit down here, the thing where it makes the shit average into a function instead?
#include <iostream>
using namespace std;
int main(){
int n, i;
float num[100], sum=0.0, average;
cout << "Enter the numbers of data: ";
cin >> n;
while (n>100 || n<=0)
{
cout << "Error! number should in range of (1 to 100)." << endl;
cout << "Enter the number again: ";
cin >> n;
}
for(i=0; i<n; ++i)
{
cout << i+1 << ". Enter number: ";
cin >> num[i];
sum+=num[i];
}
average=sum/n;
cout << "Average = " << average;
return 0;
}
thx
>>54479783
What do you mean its not the same on all platforms?
cmd programs all generally work the same.
>>54479769
I'm trying to learn here.
One example someone explained verbally is that the system called program is the same privilege as the caller.
For example, ApplicationA is ran as superuser and does a system call to open ApplicationB. ApplicationB is now superuser level and is poorly written. Now your OS is wrecked because ApplicationB was THAT poorly written. Even though you trusted A, you have to also be able to trust anything A touches with system().
Is this accurate?
>>54479810
>vim
all those hotkeys make me sick
also windblows
I'm not where to start on this project:
The firm I work for uses a Sybase SQL Anywhere database. My job, among other things, is to report off this data (using SQL queries etc) and report it up to management.
I want to create a website that can run a few predetermined queries and display the info so that management can glance at some of the information while out of the office. My problem is that I have no idea how to get a website to interact with the local database.
Any ideas of how to start?
>>54479769
its not system() that's evil, its using the command prompt that is evil
>>54479817
You can't average numbers in C++
>>54479864
So how do you run external executables without system();
>>54479671
References (int&) work like already dereferenced pointers. You don't have to dereference them to access what they point to, it's already there so you can read and write to it. Still, what they point to has to be addressable, which means you can always use the addressof (&) operator on them, and it'll give you a pointer. References are handy when you want to mimic constructs like array[i] = x, assuming you're in control of the [] operator: you can't produce an int, since it would be a copy of the ith field in array which, when modified, won't modify the field, and you can't return an int* since the caller doesn't dereference. Here, reference types have this property of correlating most closely with what you can and can't assign to. See for yourself:int *p;
int n;
n = 1; // ok, logical.
int &r1 = n; // makes it so that &r1 == &n and r1 == 1. Note that references can't be made to point to something else after they are created.
*p = 2; // ok
int &r2 = *p; // makes it so that &r2 == p
4 = 3; // doesn't compile. 4 isn't a place we can put a value into, it's only a value.
int &r3 = 3; // doesn't either for the same reason.
2 + 2 = n; // worse obviously, doesb't compile
int &r4 = 2 + 2; // same
>>54479817
>make an average
>c++
lmao you do realize the C language of families was explicitly designed to make averaging impossible, right?
oh wait you're baiting me
well played
>>54479913
NEW THREAD
NEW THREAD
NEW THREAD
>>54479913
>>54479897
Usage of addressof implies kludginess. Don't do it. If you need to get the address for any purpose, either the library you're using has shit bindings or you should pass in a pointer rather than an address (btw your const things work the exact same)
>>54479931
there are lots of reasons to use pointers. pointers can be null, are mutable and backward compatible.