• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 07:01
CEST 13:01
KST 20:01
  • 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
TL.net Map Contest #22 - Voting & Ladder Map Selection4Code S Season 2 (2026) - RO8 Preview5[ASL21] Finals Preview: Two Legacies21Code S Season 2 (2026) - RO12 Preview2herO wins GSL Code S Season 1 (2026)7
Community News
[BSL22] Non-Korean Championship from 13 to 28 June0Weekly Cups (May 25-31): Clem doubles, 2v2 circuit heads toward finale0StarCraft II 5.0.16 PTR Patch Notes may 26th151Weekly Cups (May 18-24): MaxPax wins doubles0Crank Gathers Season 4: BW vs SC2 Team League6
StarCraft 2
General
My starcraft 2 changes Glyco Honey Review 2026: Real Customer Experiences SCFusion - WoL, HotS & LotV Build Order Optimizer TL.net Map Contest #22 - Voting & Ladder Map Selection TL Poll: How do you feel about the 5.0.16 PTR balance changes?
Tourneys
Maestros of The Game 2 announcement and schedule ! Crank Gathers Season 4: BW vs SC2 Team League GSL Code S Season 2 (2026) Sparkling Tuna Cup - Weekly Open Tournament RSL Revival: Season 5 - Qualifiers and Main Event
Strategy
[G] Having the right mentality to improve
Custom Maps
[D]RTS in all its shapes and glory <3
External Content
The PondCast: SC2 News & Results Mutation # 528 Infection Detected Welcome to the External Content forum Mutation # 527 Hell Train
Brood War
General
Tesagi Viewer - A new era of replay watching 14k games analyzed: Cross Spawn Nexus first good? FlaSh's ASL S21 Finals Review BGH Auto Balance -> http://bghmmr.eu/ VPN experiences
Tourneys
[ASL21] Grand Finals [BSL22] Grand Finals - Sunday 21:00 CEST [Megathread] Daily Proleagues Escore Tournament StarCraft Season 2
Strategy
Why doesn't anyone use restoration? Any training maps people recommend? Muta micro map competition [G] Hydra ZvZ: An Introduction
Other Games
General Games
Nintendo Switch Thread Stormgate/Frost Giant Megathread Warcraft III: The Frozen Throne Path of Exile ZeroSpace Megathread
Dota 2
Looking for a Dota Mentor Official 'what is Dota anymore' discussion
League of Legends
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
Vanilla Mini Mafia Mafia Game Mode Feedback/Ideas TL Mafia Community Thread Five o'clock TL Mafia
Community
General
US Politics Mega-thread Trading/Investing Thread Russo-Ukrainian War Thread How cold is too cold to be outdoors? Dating: How's your luck?
Fan Clubs
The herO Fan Club!
Media & Entertainment
Movie Discussion! [Manga] One Piece Anime Discussion Thread
Sports
2024 - 2026 Football Thread McBoner: A hockey love story TeamLiquid Health and Fitness Initiative For 2023 Formula 1 Discussion
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread Facing Challenges in Mobile App Development
TL Community
The Automated Ban List
Blogs
Gauntlet SC2: A Retrospectiv…
Ctone23
Esportsmanship: How to NOT B…
TrAiDoS
Why RTS gamers make better f…
gosubay
ASL S21 English Commentary…
namkraft
StarCraft improvement
iopq
Customize Sidebar...

Website Feedback

Closed Threads



Active: 5490 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
Poland17756 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
Hyrule19217 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
Poland17756 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
Replay Cast
09:00
SEL Masters #6
Solar vs Classic
LiquipediaDiscussion
The PiG Daily
21:30
GSL Ro8 Group B Replay Cast
Maru vs SHIN
Rogue vs Zoun
LiquipediaDiscussion
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
SortOf 135
BRAT_OK 1
StarCraft: Brood War
Calm 10250
firebathero 527
Horang2 341
BeSt 246
Britney 232
Soma 227
Larva 217
EffOrt 165
Leta 148
Zeus 124
[ Show more ]
Last 124
Hyun 118
Light 104
ZerO 77
scan(afreeca) 76
Rush 64
910 52
Mind 34
yabsab 21
Mong 18
sorry 15
Sacsri 11
Barracks 8
Liquid`Ret 4
Dota 2
Gorgc3171
XcaliburYe105
Dendi42
Counter-Strike
fl0m3103
byalli597
zeus211
Super Smash Bros
Mew2King69
Heroes of the Storm
Khaldor85
Other Games
singsing2715
B2W.Neo746
Sick162
Pyrionflax162
KnowMe109
ZerO(Twitch)12
MindelVK11
Lowko8
OptimusSC27
Organizations
StarCraft: Brood War
lovetv 13
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
[ Show 12 non-featured ]
StarCraft 2
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
League of Legends
• Nemesis2072
• Jankos1416
Upcoming Events
uThermal 2v2 Circuit
3h 59m
Grudge Match
4h 59m
FlaShFTW vs A.Alm
OSC
9h 59m
MaxPax vs YoungYakov
Krystianer vs Shameless
GgMaChine vs Creature
LetaleX vs MiniZergUA
ReBellioN vs TBD
ArT vs HiGhDrA
Nicoract vs Azura
GSL
20h 59m
herO vs Rogue
Maru vs Cure
Patches Events
1d 1h
uThermal 2v2 Circuit
1d 3h
BSL
1d 7h
Bonyth vs Dewalt
OSC
1d 12h
Monday Night Weeklies
2 days
Replay Cast
2 days
[ Show More ]
Sparkling Tuna Cup
2 days
Replay Cast
3 days
Kung Fu Cup
3 days
Maestros of the Game
4 days
Classic vs Lambo
Clem vs Maru
Replay Cast
4 days
The PondCast
4 days
Replay Cast
5 days
Replay Cast
6 days
CranKy Ducklings
6 days
Liquipedia Results

Completed

KK 2v2 League Season 1
RSL Revival: Season 5
Heroes Pulsing #1

Ongoing

BSL Season 22
IPSL Spring 2026
KCM Race Survival 2026 Season 2
Acropolis #4
CSCL: Masked Kings S4
YSL S3
SCTL 2026 Spring
WardiTV Spring 2026
Maestros of the Game 2
uThermal 2v2 2026 Main Event
2026 GSL S2
Murky Cup 2026
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
IEM Rio 2026
PGL Bucharest 2026
Stake Ranked Episode 1
BLAST Open Spring 2026

Upcoming

BSL 22 Non-Korean Championship
CSLAN 4
Blizzard Classic Cup 2026
Kung Fu Cup 2026 Grand Finals
CranK Gathers Season 4: BW vs SC2 Team League
HSC XXIX
Heroes Pulsing #3
Heroes Pulsing #2
Esports World Cup 2026
BLAST Bounty Summer 2026
BLAST Bounty Summer Qual
Stake Ranked Episode 3
XSE Pro League 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.