• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 00:11
CEST 06:11
KST 13:11
  • 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
[ASL19] Finals Recap: Standing Tall10HomeStory Cup 27 - Info & Preview18Classic wins Code S Season 2 (2025)16Code S RO4 & Finals Preview: herO, Rogue, Classic, GuMiho0TL Team Map Contest #5: Presented by Monster Energy6
Community News
Weekly Cups (June 30 - July 6): Classic Doubles2[BSL20] Non-Korean Championship 4x BSL + 4x China9Flash Announces Hiatus From ASL66Weekly Cups (June 23-29): Reynor in world title form?14FEL Cracov 2025 (July 27) - $8000 live event22
StarCraft 2
General
The GOAT ranking of GOAT rankings The SCII GOAT: A statistical Evaluation Weekly Cups (June 23-29): Reynor in world title form? Weekly Cups (June 30 - July 6): Classic Doubles Program: SC2 / XSplit / OBS Scene Switcher
Tourneys
RSL: Revival, a new crowdfunded tournament series FEL Cracov 2025 (July 27) - $8000 live event Sparkling Tuna Cup - Weekly Open Tournament WardiTV Mondays Korean Starcraft League Week 77
Strategy
How did i lose this ZvP, whats the proper response Simple Questions Simple Answers
Custom Maps
[UMS] Zillion Zerglings
External Content
Mutation # 481 Fear and Lava Mutation # 480 Moths to the Flame Mutation # 479 Worn Out Welcome Mutation # 478 Instant Karma
Brood War
General
BGH Auto Balance -> http://bghmmr.eu/ ASL20 Preliminary Maps [ASL19] Finals Recap: Standing Tall SC uni coach streams logging into betting site Flash Announces Hiatus From ASL
Tourneys
[BSL20] Non-Korean Championship 4x BSL + 4x China [BSL20] Grand Finals - Sunday 20:00 CET CSL Xiamen International Invitational The Casual Games of the Week Thread
Strategy
Simple Questions, Simple Answers I am doing this better than progamers do.
Other Games
General Games
Nintendo Switch Thread Stormgate/Frost Giant Megathread Path of Exile What do you want from future RTS games? Beyond All Reason
Dota 2
Official 'what is Dota anymore' discussion
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Heroes of StarCraft mini-set
TL Mafia
TL Mafia Community Thread Vanilla Mini Mafia
Community
General
US Politics Mega-thread Summer Games Done Quick 2025! Russo-Ukrainian War Thread Stop Killing Games - European Citizens Initiative Summer Games Done Quick 2024!
Fan Clubs
SKT1 Classic Fan Club! Maru Fan Club
Media & Entertainment
Anime Discussion Thread [Manga] One Piece [\m/] Heavy Metal Thread
Sports
Formula 1 Discussion 2024 - 2025 Football Thread NBA General Discussion TeamLiquid Health and Fitness Initiative For 2023 NHL Playoffs 2024
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
The Automated Ban List
Blogs
momentary artworks from des…
tankgirl
Culture Clash in Video Games…
TrAiDoS
from making sc maps to makin…
Husyelt
StarCraft improvement
iopq
Customize Sidebar...

Website Feedback

Closed Threads



Active: 637 users

The Big Programming Thread - Page 581

Forum Index > General Forum
Post a Reply
Prev 1 579 580 581 582 583 1031 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.
Shield
Profile Blog Joined August 2009
Bulgaria4824 Posts
Last Edited: 2015-02-08 02:13:03
February 08 2015 02:11 GMT
#11601
On February 08 2015 06:40 Cyx. wrote:
Show nested quote +
On February 08 2015 06:26 Ropid wrote:
I meant when you do something in C, you think about the data structure you need, then when you use it you write code that works on that, like you might manually move pointers around to insert elements in your linked list or whatnot instead of hiding that, while in C++ you'll probably use something neat that hides that perfectly. That allows you to not have to think about what's going on with those pointers and the heap and whatnot, meaning C++ helps you stay at a high-level if you want.

Then there's also OOP and using C++ libraries in general compared to C, which should all be simpler to use and hide stuff better and help a lot to stay thinking at a high-level.


@nunez: example:

std::string a = "hello";
std::string b = "world";
std::cout << a + b << std::endl;


char a[] = "hello";
char b[] = "world";
char *c = malloc(strlen(a) + strlen(b) + 1);

strcpy(c, a);
strcat(c, b);

printf("%s\n", c);


One of these things is clear about the actual code being executed to concatenate two strings, while one is pretending it's not even happening at all

Not that I don't like C++ - I learned to program in C++ and it's still my favourite language - but it definitely hides things from you a lot of the time.

Also, yeah there are web dev libs for C++, but do you *actually* think they're going to compare with PHP, a language literally *designed* for web dev?



Bad example. When you add two strings, C++ does what you expect. How is that 'hiding'? What more do you expect from a plus sign?

Edit: Don't you have memory leak too? You don't delete after malloc. :D
Cyx.
Profile Joined November 2010
Canada806 Posts
February 08 2015 02:14 GMT
#11602
On February 08 2015 11:11 darkness wrote:
Show nested quote +
On February 08 2015 06:40 Cyx. wrote:
On February 08 2015 06:26 Ropid wrote:
I meant when you do something in C, you think about the data structure you need, then when you use it you write code that works on that, like you might manually move pointers around to insert elements in your linked list or whatnot instead of hiding that, while in C++ you'll probably use something neat that hides that perfectly. That allows you to not have to think about what's going on with those pointers and the heap and whatnot, meaning C++ helps you stay at a high-level if you want.

Then there's also OOP and using C++ libraries in general compared to C, which should all be simpler to use and hide stuff better and help a lot to stay thinking at a high-level.


@nunez: example:

std::string a = "hello";
std::string b = "world";
std::cout << a + b << std::endl;


char a[] = "hello";
char b[] = "world";
char *c = malloc(strlen(a) + strlen(b) + 1);

strcpy(c, a);
strcat(c, b);

printf("%s\n", c);


One of these things is clear about the actual code being executed to concatenate two strings, while one is pretending it's not even happening at all

Not that I don't like C++ - I learned to program in C++ and it's still my favourite language - but it definitely hides things from you a lot of the time.

Also, yeah there are web dev libs for C++, but do you *actually* think they're going to compare with PHP, a language literally *designed* for web dev?



Bad example. When you add two strings, C++ does what you expect. How is that 'hiding'? What more do you expect from a plus sign?

Edit: Don't you have memory leak too? You don't delete after malloc. :D


C++ hides the fact that memory allocation and function calls are necessary at all... and also the fact that you need to delete
Shield
Profile Blog Joined August 2009
Bulgaria4824 Posts
Last Edited: 2015-02-08 02:19:55
February 08 2015 02:18 GMT
#11603
On February 08 2015 11:14 Cyx. wrote:
Show nested quote +
On February 08 2015 11:11 darkness wrote:
On February 08 2015 06:40 Cyx. wrote:
On February 08 2015 06:26 Ropid wrote:
I meant when you do something in C, you think about the data structure you need, then when you use it you write code that works on that, like you might manually move pointers around to insert elements in your linked list or whatnot instead of hiding that, while in C++ you'll probably use something neat that hides that perfectly. That allows you to not have to think about what's going on with those pointers and the heap and whatnot, meaning C++ helps you stay at a high-level if you want.

Then there's also OOP and using C++ libraries in general compared to C, which should all be simpler to use and hide stuff better and help a lot to stay thinking at a high-level.


@nunez: example:

std::string a = "hello";
std::string b = "world";
std::cout << a + b << std::endl;


char a[] = "hello";
char b[] = "world";
char *c = malloc(strlen(a) + strlen(b) + 1);

strcpy(c, a);
strcat(c, b);

printf("%s\n", c);


One of these things is clear about the actual code being executed to concatenate two strings, while one is pretending it's not even happening at all

Not that I don't like C++ - I learned to program in C++ and it's still my favourite language - but it definitely hides things from you a lot of the time.

Also, yeah there are web dev libs for C++, but do you *actually* think they're going to compare with PHP, a language literally *designed* for web dev?



Bad example. When you add two strings, C++ does what you expect. How is that 'hiding'? What more do you expect from a plus sign?

Edit: Don't you have memory leak too? You don't delete after malloc. :D


C++ hides the fact that memory allocation and function calls are necessary at all... and also the fact that you need to delete


And why would you be concerned what happens internally (e.g. string allocates stuff in constructor and deletes in destructor)? All you know is that your string examples are stack objects, hence they're deleted when they go out of scope. As simple as that. It's the same in Java/C#/etc except you rely on the Garbage Collector.
Cyx.
Profile Joined November 2010
Canada806 Posts
February 08 2015 02:21 GMT
#11604
On February 08 2015 11:18 darkness wrote:
Show nested quote +
On February 08 2015 11:14 Cyx. wrote:
On February 08 2015 11:11 darkness wrote:
On February 08 2015 06:40 Cyx. wrote:
On February 08 2015 06:26 Ropid wrote:
I meant when you do something in C, you think about the data structure you need, then when you use it you write code that works on that, like you might manually move pointers around to insert elements in your linked list or whatnot instead of hiding that, while in C++ you'll probably use something neat that hides that perfectly. That allows you to not have to think about what's going on with those pointers and the heap and whatnot, meaning C++ helps you stay at a high-level if you want.

Then there's also OOP and using C++ libraries in general compared to C, which should all be simpler to use and hide stuff better and help a lot to stay thinking at a high-level.


@nunez: example:

std::string a = "hello";
std::string b = "world";
std::cout << a + b << std::endl;


char a[] = "hello";
char b[] = "world";
char *c = malloc(strlen(a) + strlen(b) + 1);

strcpy(c, a);
strcat(c, b);

printf("%s\n", c);


One of these things is clear about the actual code being executed to concatenate two strings, while one is pretending it's not even happening at all

Not that I don't like C++ - I learned to program in C++ and it's still my favourite language - but it definitely hides things from you a lot of the time.

Also, yeah there are web dev libs for C++, but do you *actually* think they're going to compare with PHP, a language literally *designed* for web dev?



Bad example. When you add two strings, C++ does what you expect. How is that 'hiding'? What more do you expect from a plus sign?

Edit: Don't you have memory leak too? You don't delete after malloc. :D


C++ hides the fact that memory allocation and function calls are necessary at all... and also the fact that you need to delete


And why would you be concerned what happens internally? All you know is that your string examples are stack objects, hence they're deleted when they go out of scope. As simple as that. It's the same in Java/C#/etc except you rely on the Garbage Collector.


Well, I mean, I didn't say it was a bad thing... I like C++ But it does allow you to hide many things which C exposes, by design.
Rollin
Profile Joined March 2011
Australia1552 Posts
February 08 2015 04:49 GMT
#11605
On February 08 2015 06:40 Cyx. wrote:
Show nested quote +
On February 08 2015 06:26 Ropid wrote:
I meant when you do something in C, you think about the data structure you need, then when you use it you write code that works on that, like you might manually move pointers around to insert elements in your linked list or whatnot instead of hiding that, while in C++ you'll probably use something neat that hides that perfectly. That allows you to not have to think about what's going on with those pointers and the heap and whatnot, meaning C++ helps you stay at a high-level if you want.

Then there's also OOP and using C++ libraries in general compared to C, which should all be simpler to use and hide stuff better and help a lot to stay thinking at a high-level.


@nunez: example:

std::string a = "hello";
std::string b = "world";
std::cout << a + b << std::endl;


char a[] = "hello";
char b[] = "world";
char *c = malloc(strlen(a) + strlen(b) + 1);

strcpy(c, a);
strcat(c, b);

printf("%s\n", c);


One of these things is clear about the actual code being executed to concatenate two strings, while one is pretending it's not even happening at all

Not that I don't like C++ - I learned to program in C++ and it's still my favourite language - but it definitely hides things from you a lot of the time.

Also, yeah there are web dev libs for C++, but do you *actually* think they're going to compare with PHP, a language literally *designed* for web dev?

The two are not equivalent. The c++ example has two strings on the stack, and you print the two variables in the same line. The c example makes two strings on the stack, then concatenates them one the heap as one variable and prints that.

Equivalent to you C++ example the C one would be:
char a[] = "hello";
char b[] = "world";
printf("%s%s", a, b);
which would print helloworld like the c++ example with stack variables.
Throw off those chains of reason, and your prison disappears. | Check your posting frequency timeline: http://www.teamliquid.net/mytlnet/post_activity_img.php
nunez
Profile Blog Joined February 2011
Norway4003 Posts
Last Edited: 2015-02-08 07:36:05
February 08 2015 06:45 GMT
#11606
the C++ equivalent of the C example is the C example.

functions are a tool for abstraction that is readily accessible in both C++ and C,
you can add as many layers as you like in either language. that a layer of abstraction
can be used to hide details is common knowledge...

destructors, constructors and non-builtin operators are function calls.
the C++-ISO standard explicitly state the circumstances under which
they are called, as well as semantics of the stdlib calls.

it's not given that the std::string example does any allocations, or deletes.
you would hope that small string optimization is used and that no
allocations are made. this is an implementation detail, if you wanted
to assert what is really happening, you would have to look at the function
definition, like with any other function.

"it's all greek to me" is not an accusation against greek.
conspired against by a confederacy of dunces.
nunez
Profile Blog Joined February 2011
Norway4003 Posts
Last Edited: 2015-02-08 07:49:53
February 08 2015 07:46 GMT
#11607
i mean, the semantics of applying the addition operator on two strings might be shrouded in ignorance,
but it is explicitly stated in the standard for all to see! if you want to assert a particular implentation
you would have to check the operator definition in the standard library you are using, but that is no different
from any other function call in any other standard library call, whether that be C or C++.
conspired against by a confederacy of dunces.
spinesheath
Profile Blog Joined June 2009
Germany8679 Posts
February 08 2015 09:06 GMT
#11608
But clearly in the case of strcat it is - just from the name of the function - intuitively apparent to the beginner that it
1) concatenates 2 strings
2) it takes an array large enough to fit both strings
3) the first string already has to be in the array

Hint: none of these is actually intuitively apparent. strcat is a concatenation of 2 abbreviations. Hell, it could mean "strong cat". In the C++ case you actually have 2 string objects, and you place a + between them. What could that do? String concatenation in C++ isn't any less obvious than in C, it just uses a special function name and is written in infix form (if you have a problem with that, you probably should stay away from functional programming). And it requires a lot less preconditions to be met.
If you have a good reason to disagree with the above, please tell me. Thank you.
nunez
Profile Blog Joined February 2011
Norway4003 Posts
Last Edited: 2015-02-08 09:09:35
February 08 2015 09:08 GMT
#11609
help please.

i need a word with the following meaning:
a statement that is not an expression.
all i got is: NonExpression... NExpression... Nexpression...

for now i'm going with Nexpression.
conspired against by a confederacy of dunces.
Blisse
Profile Blog Joined July 2010
Canada3710 Posts
Last Edited: 2015-02-08 10:25:27
February 08 2015 10:06 GMT
#11610
Statements can be considered the opposite of expressions. An expression returns a value, a statement does not. The idea in functional languages is that everything is an expression, nothing is a statement.

But generally speaking I don't think there's a word for !expression ahah, technically everything can be an expression, can you give examples of !expressions?
There is no one like you in the universe.
nunez
Profile Blog Joined February 2011
Norway4003 Posts
Last Edited: 2015-02-08 10:41:46
February 08 2015 10:18 GMT
#11611
i should have specified it's given that expressions are included in the set of statements.
i was praying for a more elegant descriptor than NotExpression for describing the complement of expressions in statements.

what speaks for it is the symmetry in length between Not,Lhs,Rhs, and the apparent lack of alternatives...
NotExpression, LhsExpression, RhsExpression.

what speaks against it is that it's a negation (not an elegant way of expressing something, hehehe) and ambiguity with respect to the logical negation operator or 'not-operator'.

defining Statements and Expressions as separate, like you suggest Blisse, seems like a superior solution. however i'd need a word for the union of the two. Symbol could suffice.

i am leaning towards the latter solution atm. i will go have a coffee, then decide.
conspired against by a confederacy of dunces.
Cynry
Profile Blog Joined August 2010
810 Posts
February 08 2015 11:13 GMT
#11612
Inexpression ?
nunez
Profile Blog Joined February 2011
Norway4003 Posts
February 08 2015 11:21 GMT
#11613
one million years dungeon!

i decided to go with blisses suggestion.
conspired against by a confederacy of dunces.
Dumbledore
Profile Joined April 2011
Sweden725 Posts
February 08 2015 11:27 GMT
#11614
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.
Have a nice day ;)
sabas123
Profile Blog Joined December 2010
Netherlands3122 Posts
February 08 2015 11:48 GMT
#11615
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.

The op can't edit a post that is older than 2 months iirc.

The harder it becomes, the more you should focus on the basics.
Blisse
Profile Blog Joined July 2010
Canada3710 Posts
February 08 2015 11:55 GMT
#11616
On February 08 2015 20:21 nunez wrote:
one million years dungeon!

i decided to go with blisses suggestion.


3 minute coffee run, that's fast o_O

yeah i was rereading some notes and binging some compiler/lexer/parser terminologies and couldn't find anything that fit !expression other than like, declaration (which could be an expression that returned void...). i guess depends a bit on how you could define expression o;
There is no one like you in the universe.
Cynry
Profile Blog Joined August 2010
810 Posts
Last Edited: 2015-02-08 12:00:41
February 08 2015 11:59 GMT
#11617
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 ?


one million years dungeon!

Whaaat ? :D
Incognoto
Profile Blog Joined May 2010
France10239 Posts
Last Edited: 2015-02-08 12:06:44
February 08 2015 12:03 GMT
#11618
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?
maru lover forever
Cynry
Profile Blog Joined August 2010
810 Posts
February 08 2015 12:29 GMT
#11619
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.
Blisse
Profile Blog Joined July 2010
Canada3710 Posts
Last Edited: 2015-02-08 13:13:37
February 08 2015 12:32 GMT
#11620
C++ can do everything C can. C++ just has some lower level abstractions than C# and Java and co. to structure C code in different ways so you don't have to rewrite code that should already exist for you. The "==" example is just you having to learn that you need to be extremely explicit when talking to a compiler, not so much ignoring fundamental concepts, but very much so playing with fire in that you can't approximate your code to the result (= assignment is not the same as == comparison in this language) and expect it to work :p This will happen regardless of the language you use.

C is the no bullshit language. Once you understand C there's little to be surprised about when you read new C code (except poor coding style). That's why people love C.

C++ is the no bullshit language with for the most part clear (besides heavy use of templates), available shortcuts if you want, but otherwise you can just write valid C and it mostly compiles in C++.


You return 0 in main() to signify success. If I'm calling your executable from somewhere else and I need to know if it worked or failed, checking if it returned 0 is a standard sign of success. You're forced to do it because main is declared as "int main" because returning an int is a standard for C++ return codes (http://en.wikipedia.org/wiki/Exit_status).

Industrial engineering doesn't have much to do with programming so learning C/C++ is a wasted endeavor if you're doing it because of your degree. Learning about coding and how programming works is important because you gain an understanding of the processes involved with coding, and you'll need that if you need to create/optimize software systems. I would learn C though because C skills are probably the most transferable across the industry - if you don't understand a high level concept in another language, asking someone to explain the equivalent in C is usually possible. However, I would say C++ would be a more effective use of time coding because learning C is actually a learning experience and will take time before you get anywhere complex, versus other languages. Learning ASM has no potential unless you work on really really really cheap hardware (which usually still runs C at least) or processors (which still run Verilog I think), or you want to debug code that you only had binaries for. These aren't typically in a Industrial Engineer's job descriptions (may vary), so they're probably not of maximal value to you.
There is no one like you in the universe.
Prev 1 579 580 581 582 583 1031 Next
Please log in or register to reply.
Live Events Refresh
Next event in 5h 49m
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
RuFF_SC2 182
ProTech59
StarCraft: Brood War
GuemChi 1080
Leta 419
MaD[AoV]41
PianO 38
Bale 15
Icarus 9
Dota 2
monkeys_forever810
League of Legends
JimRising 789
Counter-Strike
Stewie2K246
Super Smash Bros
Mew2King216
Other Games
summit1g10181
WinterStarcraft345
Maynarde153
SortOf102
NeuroSwarm59
Organizations
Other Games
gamesdonequick43598
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 15 non-featured ]
StarCraft 2
• Berry_CruncH324
• practicex 28
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
League of Legends
• Lourlo679
Other Games
• Scarra2306
• Shiphtur270
Upcoming Events
Sparkling Tuna Cup
5h 49m
WardiTV European League
11h 49m
MaNa vs sebesdes
Mixu vs Fjant
ByuN vs HeRoMaRinE
ShoWTimE vs goblin
Gerald vs Babymarine
Krystianer vs YoungYakov
PiGosaur Monday
19h 49m
The PondCast
1d 5h
WardiTV European League
1d 7h
Jumy vs NightPhoenix
Percival vs Nicoract
ArT vs HiGhDrA
MaxPax vs Harstem
Scarlett vs Shameless
SKillous vs uThermal
uThermal 2v2 Circuit
1d 11h
Replay Cast
1d 19h
RSL Revival
2 days
ByuN vs SHIN
Clem vs Reynor
Replay Cast
2 days
RSL Revival
3 days
Classic vs Cure
[ Show More ]
FEL
3 days
RSL Revival
4 days
FEL
4 days
FEL
4 days
CSO Cup
4 days
BSL20 Non-Korean Champi…
4 days
Bonyth vs QiaoGege
Dewalt vs Fengzi
Hawk vs Zhanhun
Sziky vs Mihu
Mihu vs QiaoGege
Zhanhun vs Sziky
Fengzi vs Hawk
Sparkling Tuna Cup
5 days
RSL Revival
5 days
FEL
5 days
BSL20 Non-Korean Champi…
5 days
Bonyth vs Dewalt
QiaoGege vs Dewalt
Hawk vs Bonyth
Sziky vs Fengzi
Mihu vs Zhanhun
QiaoGege vs Zhanhun
Fengzi vs Mihu
Liquipedia Results

Completed

BSL Season 20
HSC XXVII
Heroes 10 EU

Ongoing

JPL Season 2
BSL 2v2 Season 3
Acropolis #3
KCM Race Survival 2025 Season 2
CSL 17: 2025 SUMMER
Copa Latinoamericana 4
Jiahua Invitational
Championship of Russia 2025
RSL Revival: Season 1
Murky Cup #2
BLAST.tv Austin Major 2025
ESL Impact League Season 7
IEM Dallas 2025
PGL Astana 2025
Asian Champions League '25
BLAST Rivals Spring 2025
MESA Nomadic Masters
CCT Season 2 Global Finals
IEM Melbourne 2025

Upcoming

2025 ACS Season 2: Qualifier
CSLPRO Last Chance 2025
CSL Xiamen Invitational
2025 ACS Season 2
CSLPRO Chat StarLAN 3
K-Championship
uThermal 2v2 Main Event
SEL Season 2 Championship
FEL Cracov 2025
Esports World Cup 2025
StarSeries Fall 2025
FISSURE Playground #2
BLAST Open Fall 2025
BLAST Open Fall Qual
Esports World Cup 2025
BLAST Bounty Fall 2025
BLAST Bounty Fall Qual
IEM Cologne 2025
FISSURE Playground #1
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 © 2025 TLnet. All Rights Reserved.