• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 08:34
CEST 14:34
KST 21:34
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
[ASL21] Ro24 Preview Pt2: News Flash10[ASL21] Ro24 Preview Pt1: New Chaos0Team Liquid Map Contest #22 - Presented by Monster Energy18ByuL: The Forgotten Master of ZvT30Behind the Blue - Team Liquid History Book20
Community News
Weekly Cups (May 30-Apr 5): herO, Clem, SHIN win0[BSL22] RO32 Group Stage1Weekly Cups (March 23-29): herO takes triple6Aligulac acquired by REPLAYMAN.com/Stego Research8Weekly Cups (March 16-22): herO doubles, Cure surprises3
StarCraft 2
General
Weekly Cups (May 30-Apr 5): herO, Clem, SHIN win Rongyi Cup S3 - Preview & Info Team Liquid Map Contest #22 - Presented by Monster Energy Blizzard Classic Cup @ BlizzCon 2026 - $100k prize pool What mix of new & old maps do you want in the next ladder pool? (SC2)
Tourneys
Sparkling Tuna Cup - Weekly Open Tournament RSL Season 4 announced for March-April StarCraft Evolution League (SC Evo Biweekly) WardiTV Mondays World University TeamLeague (500$+) | Signups Open
Strategy
Custom Maps
[M] (2) Frigid Storage Publishing has been re-enabled! [Feb 24th 2026]
External Content
The PondCast: SC2 News & Results Mutation # 520 Moving Fees Mutation # 519 Inner Power Mutation # 518 Radiation Zone
Brood War
General
so ive been playing broodwar for a week straight. ASL21 General Discussion [BSL22] RO32 Group Stage Gypsy to Korea Pros React To: JaeDong vs Queen
Tourneys
[Megathread] Daily Proleagues [ASL21] Ro24 Group F Escore Tournament StarCraft Season 2 [ASL21] Ro24 Group E
Strategy
What's the deal with APM & what's its true value Fighting Spirit mining rates Simple Questions, Simple Answers
Other Games
General Games
Stormgate/Frost Giant Megathread Starcraft Tabletop Miniature Game Nintendo Switch Thread General RTS Discussion Thread Darkest Dungeon
Dota 2
The Story of Wings Gaming Official 'what is Dota anymore' discussion
League of Legends
G2 just beat GenG in First stand
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Deck construction bug Heroes of StarCraft mini-set
TL Mafia
Mafia Game Mode Feedback/Ideas TL Mafia Community Thread Five o'clock TL Mafia
Community
General
US Politics Mega-thread The Chess Thread Russo-Ukrainian War Thread NASA and the Private Sector Things Aren’t Peaceful in Palestine
Fan Clubs
The IdrA Fan Club
Media & Entertainment
[Manga] One Piece [Req][Books] Good Fantasy/SciFi books Movie Discussion!
Sports
2024 - 2026 Football Thread Formula 1 Discussion Cricket [SPORT] Tokyo Olympics 2021 Thread General nutrition recommendations
World Cup 2022
Tech Support
[G] How to Block Livestream Ads
TL Community
The Automated Ban List
Blogs
Loot Boxes—Emotions, And Why…
TrAiDoS
Broowar part 2
qwaykee
Funny Nicknames
LUCKY_NOOB
Iranian anarchists: organize…
XenOsky
FS++
Kraekkling
ASL S21 English Commentary…
namkraft
Electronics
mantequilla
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1998 users

The Big Programming Thread - Page 582

Forum Index > General Forum
Post a Reply
Prev 1 580 581 582 583 584 1032 Next
Thread Rules
1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution.
2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20)
3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible.
4. Use [code] tags to format code blocks.
Incognoto
Profile Blog Joined May 2010
France10239 Posts
February 08 2015 12:53 GMT
#11621
On February 08 2015 21:29 Cynry wrote:
Your main function returns an int, so you got to return an int to end it. What you return (so long as it is an int) and what it means is up to you, although I guess there are some convention. For me, -1 is an error occured, 0 nothing was done, 1 is all good.

Don't your compiler tells you about using if (x1 = x2) ? Fairly sure mine does (gcc with flags -Werror etc to show all errors).
if ((x1 = x2)) would work, not with a single pair of parenthesis.


if((x1=x2)) didn't work either, I really need "==", I don't know why.

@Blisse, I'm doing this entirely for fun. I'm just messing around with programming to understand the concepts, maybe write a few programs for fun. Industrial engineering has nothing to do with coding at all, just wanted to answer ropid. Would you recommend learning C over C++ at first, or should I just stick to messing around with C++ right now? I think I'll just stick to C++ until I understand enough about coding to figure out why C might be interesting.

From the little I understand (because a lot of what I've been reading is gibberish to me :p), it seems that C++ is more or less a lot like C, it's just that some of the extra steps that you'd have to do in C (e.g. allocating variables to memory) are done for you in C++. I've already found out that an un-initialized variable in C++ can lead to explosive results.

So return 0 (or any number afaik) signifies that int main() ran successfully. Where do you check? in the console?
maru lover forever
spinesheath
Profile Blog Joined June 2009
Germany8679 Posts
February 08 2015 12:58 GMT
#11622
On February 08 2015 21:03 Incognoto wrote:
The reason I started with C++ over C or Java was that C++ seemed to be the powerful, no bullshit language. However I'm now in doubt (especially when reading the post just above mine).

The whole "no bullshit" thing is bullshit, though. I started with C++ and went really deep on the details of the language. There's not a whole lot of magic going on in C++, maybe save for multiple inheritance. Templates can be very complex, but at the end of the day they are only replaced with regular C++ code while compiling. You can do stupid stuff like convoluted inheritance hierarchies with all kinds of stupid overrides of virtual methods and what not, but you can do the same stuff in C, it just looks different. C also is full of abstractions.

Now I'm coding in C# and I'm perfectly fine because I just plain don't need to know how everything translates into machine code. The only thing I miss from time to time is templates, because generics just are nowhere near as powerful as templates, so you have to use reflection here and there instead. So what I am missing is more powerful means of abstraction, not closeness to machine code.

The idea that you need to know how programs work at machine level to be a great programmer is just nonsense. Assembly isn't the lowest you can go, machine code isn't the lowest either. You could try to learn the microcode that is run on your CPU, you could learn how that translates into signals and what not. None of that will make you a better programmer by itself. What you really need to understand is how abstractions work in programming. But ultimately you always rely on some abstractions to do what they promise to do.

I personally don't recommend C++ to start with, as it's a language with many pitfalls for the newbie, and I know from experience that there is plenty of awful resources out there on the internet that will teach you just the worst ways of using C++. But in general one language is as good of a starting point as another as long as you learn it properly.
If you have a good reason to disagree with the above, please tell me. Thank you.
Blisse
Profile Blog Joined July 2010
Canada3710 Posts
Last Edited: 2015-02-08 13:21:36
February 08 2015 13:20 GMT
#11623
On February 08 2015 21:53 Incognoto wrote:
Show nested quote +
On February 08 2015 21:29 Cynry wrote:
Your main function returns an int, so you got to return an int to end it. What you return (so long as it is an int) and what it means is up to you, although I guess there are some convention. For me, -1 is an error occured, 0 nothing was done, 1 is all good.

Don't your compiler tells you about using if (x1 = x2) ? Fairly sure mine does (gcc with flags -Werror etc to show all errors).
if ((x1 = x2)) would work, not with a single pair of parenthesis.


if((x1=x2)) didn't work either, I really need "==", I don't know why.

@Blisse, I'm doing this entirely for fun. I'm just messing around with programming to understand the concepts, maybe write a few programs for fun. Industrial engineering has nothing to do with coding at all, just wanted to answer ropid. Would you recommend learning C over C++ at first, or should I just stick to messing around with C++ right now? I think I'll just stick to C++ until I understand enough about coding to figure out why C might be interesting.

From the little I understand (because a lot of what I've been reading is gibberish to me :p), it seems that C++ is more or less a lot like C, it's just that some of the extra steps that you'd have to do in C (e.g. allocating variables to memory) are done for you in C++. I've already found out that an un-initialized variable in C++ can lead to explosive results.

So return 0 (or any number afaik) signifies that int main() ran successfully. Where do you check? in the console?


= parses into assignment, meaning x1=x2 means set x1 to the value of x2 (i'm skipping the details). in C/C++, everything returns a value whether you like it or not, x1=x2 returns x1, which isn't 0, which is cast to true, so the if statement is entered.
== parses into equality, meaning x1==x2 returns a boolean true/false, is the value of x1 equal to x2, which is what you want.

for fun i would totally prefer a higher level language (like visual c# or java) because c/c++ doesn't allow you to do really fun stuff unless you want to learn a whole bunch of extensions and processes which take away from the "fun" of coding. but c/c++ are definitely where you should start if you want to learn.

yes, you can check in the console whether it returned error. try returning 1 and seeing what you get as a result. i believe it should say "returned with status code...." or something like that but i might be mixing up things.
There is no one like you in the universe.
sabas123
Profile Blog Joined December 2010
Netherlands3122 Posts
February 08 2015 13:25 GMT
#11624
On February 08 2015 21:58 spinesheath wrote:
Show nested quote +
On February 08 2015 21:03 Incognoto wrote:
The reason I started with C++ over C or Java was that C++ seemed to be the powerful, no bullshit language. However I'm now in doubt (especially when reading the post just above mine).

The whole "no bullshit" thing is bullshit, though. I started with C++ and went really deep on the details of the language. There's not a whole lot of magic going on in C++, maybe save for multiple inheritance. Templates can be very complex, but at the end of the day they are only replaced with regular C++ code while compiling. You can do stupid stuff like convoluted inheritance hierarchies with all kinds of stupid overrides of virtual methods and what not, but you can do the same stuff in C, it just looks different. C also is full of abstractions.

I think the reason why C in my opinion is a "no bullshit" langauge is because of 2 things.

1. It shows you all the pitfalls you should realisticly expect when abstractation fails.

2.It shows you how to the same shit on a lower level, which is more time consuming but more mutatable at the same time.
The harder it becomes, the more you should focus on the basics.
Dumbledore
Profile Joined April 2011
Sweden725 Posts
February 08 2015 13:40 GMT
#11625
On February 08 2015 20:59 Cynry wrote:
Show nested quote +
On February 08 2015 20:27 Dumbledore wrote:
In OP there is a quote comparing programming languages depending on how close they are to the machine.
It says:
"
Machine Lang
Assembly
C
C++/Java/C#
..."
This is utterly missleading and incorrect. C++ is a superset of C, it is compiled directly to native code (unless you do some gross CLR, which you can in C aswell). It is no further from the machine than C is. You can use every single C feature in it. C# and Java are highly abstract languages. They dont compile to native code. The applications run in what is called a "virtual machine" (no not the vmware kind), actively translating instructions and such. You lose a lot of capabilities using those languages such as being able to communicate directly to hardware. Comparing C++ to those 2 is missleading, wrong and insulting to any serious C++ programmer. The list should say "C/C++". Please fix OP.


Uneducated question :
As much as I agree with how you part C++ from Java and C#, are C and C++ really on the same "level" ? I was under the impression that one could write a C++ program without knowing what's going on with memory for exemple, whereas you can't really do that in C (I think). So it'd still be a level of abstraction higher. Wrong ?

Show nested quote +

one million years dungeon!

Whaaat ? :D


Level in this context means the relation to the machine, and C and C++ has the same. Which is why I felt annoyed that this thread is tricking people that C is closer to it. (A few posts up a guy is saying he will drop C++ for C cos its "closer").

In C++ memory management is just as crucial as in C. In C++11 Smart pointers were introduced, aka unique_ptr and shared_ptr, these allow for some kind of "automatic" memory management and should "always" be used. This will help your application use RAII (Resource Acqusition Is Initialisation). There are some differences between how you should manage memory in C and C++. In C for allocating and deallocating you should use malloc and free allover the place. In C++ malloc is now considered bad practise. You want to use "new", "delete" and smart pointers.

C++ offers smart pointers as a bonus, its not forced use. But yeah the level of c c++ is the same
Have a nice day ;)
Ropid
Profile Joined March 2009
Germany3557 Posts
February 08 2015 14:22 GMT
#11626
@incognoto:

What you can do right now is look at the debugger that's built into Visual Studio (if everything's there in the free version). You can make it go line by line through your tiny test program. You can look at what's happening to all variables. There's a "stack" where that stuff is saved on. Try creating a new function out of your "finding the determinant" line and you might intuitively understand how that works with the stack, variables and return values. You can take a look at the assembler code that your functions translated into. That might be interesting. You can probably guess what's going on if it's about integers (I don't know how floating point code looks like in assembler and I worry you shouldn't look at that, should instead do stuff with integers).

If you google "kernighan ritchie the c programming language", you'll find a pdf of the book from the C inventors. The way it's written, it doesn't talk about anything irrelevant really, just describes everything. For pointers and how dynamic memory allocation works, there's good explanations with sketches and stuff (but I don't think it has the same for the local stuff on the stack).

When you write "a = b" in something like C, that translates into "read something from memory address b and then store that into memory address a". That's why "==" is something different. When you write "a == b", that translates into "read something from memory address a and then compare that to what's at memory address b".

All of this is "imperative". There are programming languages that work differently. There are languages where when you write "a = b", you just declare to the compiler that wherever you use b, it's the same as a. The line itself does not translate into any instructions for the machine. It instead changes how the compiler will see the rest of your program.

There's a webpage "Project Euler" here: https://projecteuler.net/problems. It's a collection of simple questions where you're supposed to calculate something. You could do some of those in C. When you do that, you're thinking in a pretty different way than what you do in those other languages and those will feel weird.

Two of those weird languages that are actually in use were developed in France. There's OCaml and there's Coq. OCaml seems somewhat normal and Coq seems to be something about logic and proofs. There might be research groups in your faculty and courses that use one of those two?
"My goal is to replace my soul with coffee and become immortal."
nunez
Profile Blog Joined February 2011
Norway4003 Posts
February 08 2015 14:40 GMT
#11627
On February 08 2015 21:58 spinesheath wrote:
Show nested quote +
On February 08 2015 21:03 Incognoto wrote:
The reason I started with C++ over C or Java was that C++ seemed to be the powerful, no bullshit language. However I'm now in doubt (especially when reading the post just above mine).

The whole "no bullshit" thing is bullshit, though. I started with C++ and went really deep on the details of the language. There's not a whole lot of magic going on in C++, maybe save for multiple inheritance. Templates can be very complex, but at the end of the day they are only replaced with regular C++ code while compiling. You can do stupid stuff like convoluted inheritance hierarchies with all kinds of stupid overrides of virtual methods and what not, but you can do the same stuff in C, it just looks different. C also is full of abstractions.

Now I'm coding in C# and I'm perfectly fine because I just plain don't need to know how everything translates into machine code. The only thing I miss from time to time is templates, because generics just are nowhere near as powerful as templates, so you have to use reflection here and there instead. So what I am missing is more powerful means of abstraction, not closeness to machine code.

The idea that you need to know how programs work at machine level to be a great programmer is just nonsense. Assembly isn't the lowest you can go, machine code isn't the lowest either. You could try to learn the microcode that is run on your CPU, you could learn how that translates into signals and what not. None of that will make you a better programmer by itself. What you really need to understand is how abstractions work in programming. But ultimately you always rely on some abstractions to do what they promise to do.

I personally don't recommend C++ to start with, as it's a language with many pitfalls for the newbie, and I know from experience that there is plenty of awful resources out there on the internet that will teach you just the worst ways of using C++. But in general one language is as good of a starting point as another as long as you learn it properly.

+(++*(std::make_unique<int>(0)));
conspired against by a confederacy of dunces.
Rollin
Profile Joined March 2011
Australia1552 Posts
Last Edited: 2015-02-08 14:51:26
February 08 2015 14:49 GMT
#11628
On February 08 2015 21:32 Blisse wrote:
C++ can do everything C can.


Variable length arrays exist in c99 but not c++.
Throw off those chains of reason, and your prison disappears. | Check your posting frequency timeline: http://www.teamliquid.net/mytlnet/post_activity_img.php
Manit0u
Profile Blog Joined August 2004
Poland17713 Posts
February 08 2015 15:25 GMT
#11629
On February 08 2015 22:20 Blisse wrote:
Show nested quote +
On February 08 2015 21:53 Incognoto wrote:
So return 0 (or any number afaik) signifies that int main() ran successfully. Where do you check? in the console?


yes, you can check in the console whether it returned error. try returning 1 and seeing what you get as a result. i believe it should say "returned with status code...." or something like that but i might be mixing up things.


Actually if the C function returns 0 it means success, anything else means that something went wrong. You can use this to handle errors.


if (!input) {
return 1; // no input specified
}

if (fopen("myfile", "r") == NULL) {
return 2; // could not read file, for more details see strerror(errno) if <errno.h> is included
}

return 0; // all is well
Time is precious. Waste it wisely.
Djagulingu
Profile Blog Joined December 2010
Germany3605 Posts
February 08 2015 15:40 GMT
#11630
I have this particular question in my mind: I'm building this web application which, in server side, uses nodejs to get constant stream of data from a 3rd party API and store it in my NoSQL database. I have finished developing the server side and now I'll move on with the client side. I'm wondering what I should use for the front end. I'm stuck between:

1- Front end with EmberJS and having a JSON API for database connectivity (or whatever Ember offers for that)
2- Same thing as #1, just replace EmberJS with AngularJS
3- Use Express and eliminate the need for JSON API for DB connectivity.

What are the pros and cons of each one?
"windows bash is a steaming heap of shit" tofucake
tofucake
Profile Blog Joined October 2009
Hyrule19200 Posts
February 08 2015 15:44 GMT
#11631
On February 08 2015 20:27 Dumbledore wrote:
In OP there is a quote comparing programming languages depending on how close they are to the machine.
It says:
"
Machine Lang
Assembly
C
C++/Java/C#
..."
This is utterly missleading and incorrect. C++ is a superset of C, it is compiled directly to native code (unless you do some gross CLR, which you can in C aswell). It is no further from the machine than C is. You can use every single C feature in it. C# and Java are highly abstract languages. They dont compile to native code. The applications run in what is called a "virtual machine" (no not the vmware kind), actively translating instructions and such. You lose a lot of capabilities using those languages such as being able to communicate directly to hardware. Comparing C++ to those 2 is missleading, wrong and insulting to any serious C++ programmer. The list should say "C/C++". Please fix OP.

I'm not changing a quote from someone else from 3 years ago because you don't like it. It's really not insulting at all unless someone decides they want to be nitpicky. It's a very basic list meant to get a point across, not a specific and universal classification of C++.

And I'm well aware of how these languages work and I'm fairly sure donut is too.
Liquipediaasante sana squash banana
Dumbledore
Profile Joined April 2011
Sweden725 Posts
February 08 2015 16:11 GMT
#11632
On February 08 2015 23:49 Rollin wrote:
Show nested quote +
On February 08 2015 21:32 Blisse wrote:
C++ can do everything C can.


Variable length arrays exist in c99 but not c++.


You got me there. However you could always use dynamic arrays in C++ or std::vector.
VL Arrays were taken out of the C++ Standard fot good reasons though. e.g. sizeof() wont always work at compile time, New syntax needed for multi dimensional VL Arrays that are passed as arguments. And other stack problems it can possibly introduce.
Have a nice day ;)
Manit0u
Profile Blog Joined August 2004
Poland17713 Posts
Last Edited: 2015-02-08 16:38:35
February 08 2015 16:37 GMT
#11633
On February 09 2015 00:40 Djagulingu wrote:
I have this particular question in my mind: I'm building this web application which, in server side, uses nodejs to get constant stream of data from a 3rd party API and store it in my NoSQL database. I have finished developing the server side and now I'll move on with the client side. I'm wondering what I should use for the front end. I'm stuck between:

1- Front end with EmberJS and having a JSON API for database connectivity (or whatever Ember offers for that)
2- Same thing as #1, just replace EmberJS with AngularJS
3- Use Express and eliminate the need for JSON API for DB connectivity.

What are the pros and cons of each one?


You could always try some full stack framework, like MEAN. It uses NoSQL (Mongo), Express, Angular and Node so you could have it all in one neat package.
Time is precious. Waste it wisely.
Djagulingu
Profile Blog Joined December 2010
Germany3605 Posts
Last Edited: 2015-02-08 18:28:06
February 08 2015 18:27 GMT
#11634
On February 09 2015 01:37 Manit0u wrote:
Show nested quote +
On February 09 2015 00:40 Djagulingu wrote:
I have this particular question in my mind: I'm building this web application which, in server side, uses nodejs to get constant stream of data from a 3rd party API and store it in my NoSQL database. I have finished developing the server side and now I'll move on with the client side. I'm wondering what I should use for the front end. I'm stuck between:

1- Front end with EmberJS and having a JSON API for database connectivity (or whatever Ember offers for that)
2- Same thing as #1, just replace EmberJS with AngularJS
3- Use Express and eliminate the need for JSON API for DB connectivity.

What are the pros and cons of each one?


You could always try some full stack framework, like MEAN. It uses NoSQL (Mongo), Express, Angular and Node so you could have it all in one neat package.

I actually want to use couchbase as the nosql database because it is lotsnlots of times faster when it comes to write operations per second and that is what my server is going to do (think of it like some guy who picks up a single paper from an endless pile of papers, stamp it and put it in another pile and thus i don't want my pile to randomly crash).
"windows bash is a steaming heap of shit" tofucake
AKnopf
Profile Blog Joined March 2011
Germany259 Posts
February 08 2015 20:24 GMT
#11635
On February 08 2015 21:58 spinesheath wrote:
Show nested quote +
On February 08 2015 21:03 Incognoto wrote:
The reason I started with C++ over C or Java was that C++ seemed to be the powerful, no bullshit language. However I'm now in doubt (especially when reading the post just above mine).

The whole "no bullshit" thing is bullshit, though. I started with C++ and went really deep on the details of the language. There's not a whole lot of magic going on in C++, maybe save for multiple inheritance. Templates can be very complex, but at the end of the day they are only replaced with regular C++ code while compiling. You can do stupid stuff like convoluted inheritance hierarchies with all kinds of stupid overrides of virtual methods and what not, but you can do the same stuff in C, it just looks different. C also is full of abstractions.

Now I'm coding in C# and I'm perfectly fine because I just plain don't need to know how everything translates into machine code. The only thing I miss from time to time is templates, because generics just are nowhere near as powerful as templates, so you have to use reflection here and there instead. So what I am missing is more powerful means of abstraction, not closeness to machine code.

The idea that you need to know how programs work at machine level to be a great programmer is just nonsense. Assembly isn't the lowest you can go, machine code isn't the lowest either. You could try to learn the microcode that is run on your CPU, you could learn how that translates into signals and what not. None of that will make you a better programmer by itself. What you really need to understand is how abstractions work in programming. But ultimately you always rely on some abstractions to do what they promise to do.

I personally don't recommend C++ to start with, as it's a language with many pitfalls for the newbie, and I know from experience that there is plenty of awful resources out there on the internet that will teach you just the worst ways of using C++. But in general one language is as good of a starting point as another as long as you learn it properly.

As a rubyist I can only kiss you for this comment. C is a fine language, but it's not the holy grail of programming as so many people propagate. At the end it's always a matter of what level of abstraction is best for the kind of program you want to write. Also: While it is true, that you can do lots of run-time and memory optimizations in C, it's also true that most applications don't need to be optimized - at least not in that way.
The world - its a funny place
Shield
Profile Blog Joined August 2009
Bulgaria4824 Posts
February 08 2015 23:33 GMT
#11636
On February 08 2015 21:03 Incognoto wrote:
the discussion which took place on the last two pages was really interesting, thanks for that.

@Ropid, I'm doing a master's degree in industrial engineering. Coding in VBA seems to have almost no link whatsoever to the rest of what we do, so I'm not really sure what the fuck we're doing. I decided to pick up C++ for fun, completely on my own.

So far I've written just one program, in C++, using visual C++. It will solve a basic univariate quadratic function. It was fun to do, I did it reading the first few pages of learncpp.com and using google whenever I couldn't get something to work (disregard the weird comments I used while writing):

+ Show Spoiler +

#include "stdafx.h" // Uncomment this line if using Visual Studio
#include <iostream>

int main()
{
//telling the user what's up
std::cout << "Dear Sir, regarding your recent enquiry as to me, the Computer, helping you do" << std::endl;
std::cout << "your math homework, I have decided that I shall give you all the aid which you" << std::endl;
std::cout << "shall need in order to successfully solve the math problem which has "<< std::endl;
std::cout << "been bestowed upon you." << std::endl;
std::cout << "I believe that indeed, you were given a polynomial equation to solve." << std::endl;
std::cout << std::endl;

//initializing the first variables that the user will enter
float a=0;
float b=0;
float c=0;

//the user will enter the variables for each value, whilst being treated like a gentleman:
std::cout << "Let us begin. Good Sir, please enter the first coefficient: "<< std::endl;
std::cin >> a;

std::cout << "Good Sir, please enter the second coefficient: "<< std::endl;
std::cin >> b;

std::cout << "Good Sir, please enter the third coefficient: "<< std::endl;
std::cin >> c;

std::cout << std::endl;


//finding da determinant:
float d=0;
d=((pow(b,2))-4*a*c);


std::cout << d << std::endl;
//checking if determinant is negative:
if(d<0)
{
std::cout << "The determinant being negative, there is no solution." << std::endl;
}
else
{


//defining solutions and doing da maths:
float x1=0;
float x2=0;

x1=(-b+sqrt(d))/(2*a);
x2=(-b-sqrt(d))/(2*a);

//portraying the result, which depends on the value of determinant:
if(x1==x2)
{
std::cout << "The only solution to the equation is: " << x1 << std::endl;
}
else
{
std::cout << "The first solution to your problem would be: " << x1 << std::endl;
std::cout << "This is the second result: " << x2 << std::endl;
}

}

//ending message
std::cout << std::endl;
std::cout << "My regards have been sent. Press enter to cheerio."<< std::endl;


//preventing the retarded console from shutting down on its own
std::cin.clear();
std::cin.ignore(255, '\n');
std::cin.get();

return 0;
}



Having read the OP, I might drop C++ for now and concentrate on Assembly or C, since apparently those languages are closer to the actual machine. Learning those would make me understand programming on a more "fundamental" level. Not entirely sure.

This is mostly just a hobby I'm starting, really for fun. However it seems that coding can be dangerous if self taught. For example, in my program:

if(x1==x2)


Originally, I wrote " if(x1=x2) " and what the program would do is always give me two solutions which were equal. I find it somewhat alarming that the condition I set for an "if loop" would actually transform x2 instead. Using a bit of google, I found that a work if loop in another program just used "==" instead of "="; when I edited my line with that, it ended up working.

I find this similar to playing with fire for some reason, like learning to code this way might have me ignoring really fundamental concepts or something.

The reason I started with C++ over C or Java was that C++ seemed to be the powerful, no bullshit language. However I'm now in doubt (especially when reading the post just above mine).


PS: everyone uses "return 0;" but I still don't know why the hell it's there. To return 0 to the machine so it knows that the program finished? Why would we need to do that? If the program works, it works, if it doesn't, it doesn't. The machine doesn't care, it's just there to execute codes.

Or it it?


You may use this to hold console open:

system("PAUSE")
Blisse
Profile Blog Joined July 2010
Canada3710 Posts
Last Edited: 2015-02-09 03:22:45
February 09 2015 03:06 GMT
#11637
On February 09 2015 00:25 Manit0u wrote:
Show nested quote +
On February 08 2015 22:20 Blisse wrote:
On February 08 2015 21:53 Incognoto wrote:
So return 0 (or any number afaik) signifies that int main() ran successfully. Where do you check? in the console?


yes, you can check in the console whether it returned error. try returning 1 and seeing what you get as a result. i believe it should say "returned with status code...." or something like that but i might be mixing up things.


Actually if the C function returns 0 it means success, anything else means that something went wrong. You can use this to handle errors.


if (!input) {
return 1; // no input specified
}

if (fopen("myfile", "r") == NULL) {
return 2; // could not read file, for more details see strerror(errno) if <errno.h> is included
}

return 0; // all is well


not sure where we were in disagreement

edit: nvm i didnt see the stuff in incognoto's parentheses
There is no one like you in the universe.
Deleted User 3420
Profile Blog Joined May 2003
24492 Posts
Last Edited: 2015-02-09 04:23:51
February 09 2015 04:22 GMT
#11638
java question

If I pass a reference to another instance as an argument, can I make it so that all of the methods in the new instance will recognize the fields in that reference? like for example a string in the original instance, I can print it from within the constructor of the new instance, but if I try to print it from a method that is called in that constructor, it won't work unless I pass it on as a parameter to that method as well. but that seems really redundant if I am going to be using a bunch of methods... having to put the reference as a parameter over and over. does anyone understand what I am talking about?
Blitzkrieg0
Profile Blog Joined August 2010
United States13132 Posts
Last Edited: 2015-02-09 04:41:25
February 09 2015 04:38 GMT
#11639
It sounds like you need inheritance, but I'm not 100% sure what you're asking.
I'll always be your shadow and veil your eyes from states of ain soph aur.
Deleted User 3420
Profile Blog Joined May 2003
24492 Posts
February 09 2015 04:50 GMT
#11640

class1{ String mystring="blah" }

class2 {
class1 x = new class1
class3 y = new class3(x)}

class3{

class3(class1 thing){
System.out.print(thing.mystring);
method();
}

method(){
System.out.print(thing.mystring);
}}


hopefully the code is good here. I made it as simple as possible.
in this example I believe that mystring would print out as "blah" the first time, but the 2nd time method will not see thing anymore. so it won't print out mystring, it would just have an error. I am wondering if there is an easy way to make method and any other methods in class3 to see thing.
Prev 1 580 581 582 583 584 1032 Next
Please log in or register to reply.
Live Events Refresh
Sparkling Tuna Cup
10:00
Weekly #126
Classic vs ByuNLIVE!
herO vs TBD
CranKy Ducklings223
TKL 185
IndyStarCraft 176
LiquipediaDiscussion
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
Lowko377
TKL 182
IndyStarCraft 159
SortOf 135
ProTech118
StarCraft: Brood War
Sea 13291
Calm 6605
Horang2 3726
Bisu 2001
Jaedong 1348
EffOrt 535
Aegong 483
Shuttle 482
Killer 447
Stork 382
[ Show more ]
Hyuk 308
Larva 286
Mini 274
Light 213
Soma 198
actioN 168
Snow 148
ggaemo 142
ZerO 136
Soulkey 127
hero 97
Rush 76
Hm[arnc] 45
Sharp 42
Mind 41
sSak 40
HiyA 38
JYJ 37
sorry 36
Backho 36
Shinee 30
[sc1f]eonzerg 28
Free 27
soO 20
Terrorterran 18
ajuk12(nOOB) 18
Sacsri 17
Movie 16
zelot 15
Noble 14
GoRush 12
Icarus 6
Dota 2
qojqva514
Pyrionflax328
Gorgc109
Counter-Strike
olofmeister4749
fl0m2352
Other Games
singsing1913
Liquid`RaSZi893
B2W.Neo577
XcaliburYe364
crisheroes233
hiko197
XaKoH 148
RotterdaM142
Mew2King72
QueenE60
ArmadaUGS26
ZerO(Twitch)10
Organizations
Counter-Strike
PGL10266
StarCraft: Brood War
UltimateBattle 955
Other Games
BasetradeTV665
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 14 non-featured ]
StarCraft 2
• HappyZerGling 92
• CranKy Ducklings SOOP4
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• iopq 2
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Dota 2
• WagamamaTV52
Upcoming Events
PiGosaur Cup
11h 26m
Replay Cast
20h 26m
Kung Fu Cup
23h 26m
Replay Cast
1d 11h
The PondCast
1d 21h
CranKy Ducklings
2 days
WardiTV Team League
2 days
Replay Cast
3 days
CranKy Ducklings
3 days
WardiTV Team League
3 days
[ Show More ]
uThermal 2v2 Circuit
4 days
BSL
4 days
Sparkling Tuna Cup
4 days
WardiTV Team League
4 days
BSL
5 days
Replay Cast
5 days
Replay Cast
5 days
Wardi Open
5 days
Liquipedia Results

Completed

CSL Elite League 2026
RSL Revival: Season 4
NationLESS Cup

Ongoing

BSL Season 22
ASL Season 21
CSL 2026 SPRING (S20)
StarCraft2 Community Team League 2026 Spring
Nations Cup 2026
PGL Bucharest 2026
Stake Ranked Episode 1
BLAST Open Spring 2026
ESL Pro League S23 Finals
ESL Pro League S23 Stage 1&2
PGL Cluj-Napoca 2026
IEM Kraków 2026
BLAST Bounty Winter 2026

Upcoming

Escore Tournament S2: W2
IPSL Spring 2026
Escore Tournament S2: W3
Acropolis #4
BSL 22 Non-Korean Championship
CSLAN 4
Kung Fu Cup 2026 Grand Finals
HSC XXIX
uThermal 2v2 2026 Main Event
uThermal 2v2 Last Chance Qualifiers 2026
RSL Revival: Season 5
IEM Cologne Major 2026
Stake Ranked Episode 2
CS Asia Championships 2026
Asian Champions League 2026
IEM Atlanta 2026
PGL Astana 2026
BLAST Rivals Spring 2026
CCT Season 3 Global Finals
IEM Rio 2026
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2026 TLnet. All Rights Reserved.