• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 13:25
CEST 19:25
KST 02:25
  • 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
Serral wins HomeStory Cup 2914Serral wins Maestros of the Game 243ByuL, and the Limitations of Standard Play3Team Liquid Map Contest #22: Results and Winners7Code S Season 2 (2026): RO4 and Finals Preview12
Community News
Balance hotfix patch 5.0.16b (July 16)26Reynor: GSL Loss Wasn't About Preparation Format16[IPSL] Spring 2026 Grand Finals - This Weekend!5Weekly Cups (July 6 - 12): Protoss strike back12BSL Season 22 Full Overview & Conclusion8
StarCraft 2
General
Balance hotfix patch 5.0.16b (July 16) [D] Wireframe Casting Removed Clem: "I don't have that much hope in Blizzard" Reynor: GSL Loss Wasn't About Preparation Format Is the larve respawn broken?
Tourneys
Master Swan Open (Global Bronze-Master 2) WardiTV Summer Cup 2026 GSL CK #5 Race War RSL Revival: Season 6 - Qualifiers and Main Event HomeStory Cup 29
Strategy
[G] Having the right mentality to improve
Custom Maps
New Map Maker - Looking for Advice - Love or Hate Work In Progress Melee Maps [D]RTS in all its shapes and glory <3
External Content
The PondCast: SC2 News & Results Mutation # 534 Burning Evacuation Mutation # 533 Die Together Mutation # 532 Nuclear Family
Brood War
General
BW General Discussion Recent recommended BW games Recommended FPV games (post-KeSPA) Etiquete rules in Asl? Pros Debate: Zerg Unfairly Nerfed? (ASL S22 map)
Tourneys
Escore Tournament - Season 3 Small VOD Thread 2.0 [IPSL] Spring 2026 Grand Finals - This Weekend! [Megathread] Daily Proleagues
Strategy
Fighting Spirit mining rates Simple Questions, Simple Answers Creating a full chart of Zerg builds Relatively freeroll strategies
Other Games
General Games
General RTS Discussion Thread Path of Exile Nintendo Switch Thread Beyond All Reason Stormgate/Frost Giant 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
TL Mafia
TL Mafia Power Rank NeO.D_StephenKing vs This Guy From 1 Million Dance TL Mafia Community Thread Vanilla Mini Mafia
Community
General
US Politics Mega-thread The Games Industry And ATVI Russo-Ukrainian War Thread UK Politics Mega-thread YouTube Thread
Fan Clubs
The IdrA Fan Club The HerO Fan Club!
Media & Entertainment
Movie Discussion! Anime Discussion Thread [Req][Books] Good Fantasy/SciFi books Series you have seen recently...
Sports
2024 - 2026 Football Thread MLB/Baseball 2023 McBoner: A hockey love story Tennis[sport] Formula 1 Discussion
World Cup 2022
Tech Support
Simple Questions Simple Answers FPS when play League Of Legend on laptop How to clean a TTe Thermaltake keyboard?
TL Community
Northern Ireland Global Starcraft The Automated Ban List
Blogs
Poker (part 2)
Nebuchad
The Experiences We Want and …
TrAiDoS
An Exploration of th…
waywardstrategy
Gauntlet SC2: A Retrospectiv…
Ctone23
ramps on octagon
StaticNine
Funny Nicknames
LUCKY_NOOB
Evil Gacha Games and the…
ffswowsucks
Customize Sidebar...

Website Feedback

Closed Threads



Active: 7824 users

The Big Programming Thread - Page 7

Forum Index > General Forum
Post a Reply
Prev 1 5 6 7 8 9 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.
LuckyLuke43
Profile Joined May 2010
Norway169 Posts
Last Edited: 2010-07-11 07:12:32
July 11 2010 07:12 GMT
#121
On July 11 2010 13:59 Divinek wrote:
Show nested quote +
On July 11 2010 13:41 LuckyLuke43 wrote:
Hehe, I'm probably gonna get kicked out of this whole thread but.. When I was like 12, me and a friend decided to learn how to make homepages! HTML was 'the shit' back then - atleast that was the only thing we'd heard of ;P. So we started with that, and I knew some basic shit(I could make a webpage with buttons and links and whatnot; yaaaay) by the end of that whole phase. Anyways, I kinda drifted from the whole programming thing(scripting, we called it, haha), but my friend continued. Some months later, my friend showed me on his computer how far he'd come. He had studied Java(I think?), and was now done with webpages - that was too boring!. Instead he was doing programs. He did calculators etc. Then some months after that, he had learned how to use C++, and was now doing all sorts of games and cool apps;P like Snake(the game).

Fun little story I wanted to share

Anyways, I'm a _TOTAL_ newbie, I have no knowledge at all about programming. Where should I start? I've looked at some code, and I understand nAdA. C++ might aswell be korean characters. Any ideas? Should I start with HTML like my friend did and slowly evolve?


starting with java or c++ is perfectly fine, any language really isnt that hard. You certainly dont have to start with html if that doesnt interest you most.

You can find tons and tons of online tutorials for the stuff, plus the links in the op are really nice


Sounds good. I already hit up some stuff on youtube. Some guy did like 6 tutorials on basic C++, and I did 'em all. Sadly, after watching and doing all 6, I felt like I just had copy/pasted his work, without actually learning why, what, where or how ;P Thanks tho, I think I'm gonna try and study this some in the near future Programming is fun! Even if it's just on a mindblowingly newbie level, tee-hee.
Our deepest fear is not that we are inadequate. Our deepest fear is that we are powerful beyond measure.
haduken
Profile Blog Joined April 2003
Australia8267 Posts
July 11 2010 08:03 GMT
#122
Get QtCreator and Qt4 if you are on Linux.

Or get Visual C# express if you are on Windows.

The newbie stuff is incredibly boring after you understand all the basics. Better just get stuck into it and make some thing in winform e.g. a usage tracker for your isp etc or an Alarm clock.

Both shouldn't be too hard.
Rillanon.au
spinesheath
Profile Blog Joined June 2009
Germany8679 Posts
July 11 2010 08:11 GMT
#123
If you're starting with C++ and don't have OOP practice yet, here's a few tips from someone who didn't go the easy way (because I didn't know better):

All the online tutorials I found so far don't really teach you C++. They teach you C style coding in C++ and a few things about classes. Those tutorials might help you learn the syntax, but you will lack a deeper understanding of the language. That's a decent way to start, but it's not enough. You should not stop at that point.
Once you feel confident with the syntax (i.e. you only have to look up syntax every now and then), read this for some pointers to which subjects you should read about (that FAQ also has a lot of good information in it though you don't have to understand it all if you're new to C++). If you really want to get good at C++ I suggest that you get a few books on it. For casual use that won't be necessary. Knowledge from other languages can be carried over too.

Two things about C++ that I would consider very important and that aren't taught in most tutorials:

1) Don't use C-Style casts:
char c ;
// C style no.1
int a = (int)c;

// C style no.2
int b = int(c);

Use C++ casts instead:
char c ;
// C++
int a = static_cast<int>(x);

// there also is:
// reinterpret_cast<T>(x)
// const_cast<T>(x)

The reason behind this is that casting in general should be avoided, and clearly visible when it's actually done. The C++ casts are ugly so you don't even want to use them, and they are much more visible than a pair of brackets. You should read up on those later on when you can't avoid casting.

2) Read about the STL (standard template library) and use it. It'll make your life so much easier. You can code some stuff that is part of the STL as coding practice, but for other code you should use the STL classes most of the time.
If you have a good reason to disagree with the above, please tell me. Thank you.
RageOverdose
Profile Blog Joined December 2009
United States690 Posts
July 11 2010 08:47 GMT
#124
I think this thread is like some sort of crazy savior or something. It makes me wish it wasn't 4:40AM and I need sleep.

Basically, I'm going into my 3rd year of Computer Science, and I'm moving a bit slower than I should. While I'm getting a good grasp on OOP, I'm just not getting the algorithms part of it, and Computer Organization (where we started to go over lower level details such as data paths) confused the hell out of me. I still have my textbook though, and I may go back into reading it.

This thread is kind of inspirational. I think I need to just sit down and write some stuff, which I don't do often but I want to, I just lack motivation. It was my goal to work on some game design this summer, but I feel like I shouldn't go so far yet. Any basic ideas for smaller scale projects that are higher level? My only language experience is C#, Objective C, Java, JavaScript, some MIPS assembly, and Python and I'm not the best at coming up with my own ideas. If anyone can just throw ideas my way, I'd appreciate it. I have a couple in mind I'll try here soon, such as a calculator (more than just addition, subtraction, multiplication, division, etc.) and maybe sorting programs.
LuckyLuke43
Profile Joined May 2010
Norway169 Posts
Last Edited: 2010-07-11 09:34:46
July 11 2010 09:15 GMT
#125
On July 11 2010 17:11 spinesheath wrote:
If you're starting with C++ and don't have OOP practice yet, here's a few tips from someone who didn't go the easy way (because I didn't know better):

All the online tutorials I found so far don't really teach you C++. They teach you C style coding in C++ and a few things about classes. Those tutorials might help you learn the syntax, but you will lack a deeper understanding of the language. That's a decent way to start, but it's not enough. You should not stop at that point.
Once you feel confident with the syntax (i.e. you only have to look up syntax every now and then), read this for some pointers to which subjects you should read about (that FAQ also has a lot of good information in it though you don't have to understand it all if you're new to C++). If you really want to get good at C++ I suggest that you get a few books on it. For casual use that won't be necessary. Knowledge from other languages can be carried over too.

Two things about C++ that I would consider very important and that aren't taught in most tutorials:

1) Don't use C-Style casts:
char c ;
// C style no.1
int a = (int)c;

// C style no.2
int b = int(c);

Use C++ casts instead:
char c ;
// C++
int a = static_cast<int>(x);

// there also is:
// reinterpret_cast<T>(x)
// const_cast<T>(x)

The reason behind this is that casting in general should be avoided, and clearly visible when it's actually done. The C++ casts are ugly so you don't even want to use them, and they are much more visible than a pair of brackets. You should read up on those later on when you can't avoid casting.

2) Read about the STL (standard template library) and use it. It'll make your life so much easier. You can code some stuff that is part of the STL as coding practice, but for other code you should use the STL classes most of the time.


Thanks, I'll look into that!

Also, I found a "Learning C++" that some guy wrote: http://www.isotton.com/devel/docs/lcpp/
I've around 30pages until now, and I just got my first 4 assignments, but I've been sitting here for 30 minutes trying to figure out how the hell to do #1 lol.

+ Show Spoiler +


1. Write a program asking for an integer number and saying whether it is
positive or not. (Zero is not positive).
       This is what I've come up with so far, lol:

#include <iostream>
using namespace std;

int main() {

cout << "Tell me a number, and I will tell you if it is positive or not!\n";

int choice;
cin >> choice;

system("PAUSE"); // I finally got the damn window to STAY up and not instaclose lol
}



The thing I don't really get is WHAT is the damn integer number? Okay so an integer number is basically just any number without a decimal, got it. Still I have no idea how to go about this one *sigh*

EDIT: I think I got it!! *in spoiler tag below*

+ Show Spoiler +

#include <iostream>
using namespace std;

int main() {

cout << "Tell me a number, and I will tell you if it is positive or negative!\n";

int number;
cin >> number;

if (number > 0)
cout << "The number you have chosen is positive.\n";
else
cout << "The number you have chosen is not positive.\n;


system("PAUSE");
}




Sidenote: I'm using Dev-C++ right now, but I don't really like how it forces me to set up my code in a certain way. It doesn't look as organized as it could, in my eyes. *fume*
Our deepest fear is not that we are inadequate. Our deepest fear is that we are powerful beyond measure.
dvide
Profile Joined March 2010
United Kingdom287 Posts
July 11 2010 09:40 GMT
#126
On July 11 2010 18:15 LuckyLuke43 wrote:
Sidenote: I'm using Dev-C++ right now, but I don't really like how it forces me to set up my code in a certain way. It doesn't look as organized as it could, in my eyes. *fume*

I think you'd be better off with Code::Blocks, or if you're on Windows I would just use Visual C++ 2010 Express.
Adeny
Profile Blog Joined January 2009
Norway1233 Posts
July 11 2010 09:56 GMT
#127
On July 11 2010 09:19 tofucake wrote:
I've done plenty with sockets in just about every language I've worked with. Anyway, what's your aim? Writing a website that does fancy loading without reloading is totally different from writing, say, a Battle.net bot.


Well, let's say I want to be able to pull data from websites, to find the temperature for today, or something to that effect. Or mayhaps build a bot, that would probably be fun. I'm talking about interacting with the websites, not building fancy websites in php/java/etc.
Adeny
Profile Blog Joined January 2009
Norway1233 Posts
Last Edited: 2010-07-11 10:52:09
July 11 2010 10:11 GMT
#128
On July 11 2010 18:15 LuckyLuke43 wrote:
Show nested quote +
On July 11 2010 17:11 spinesheath wrote:
If you're starting with C++ and don't have OOP practice yet, here's a few tips from someone who didn't go the easy way (because I didn't know better):

All the online tutorials I found so far don't really teach you C++. They teach you C style coding in C++ and a few things about classes. Those tutorials might help you learn the syntax, but you will lack a deeper understanding of the language. That's a decent way to start, but it's not enough. You should not stop at that point.
Once you feel confident with the syntax (i.e. you only have to look up syntax every now and then), read this for some pointers to which subjects you should read about (that FAQ also has a lot of good information in it though you don't have to understand it all if you're new to C++). If you really want to get good at C++ I suggest that you get a few books on it. For casual use that won't be necessary. Knowledge from other languages can be carried over too.

Two things about C++ that I would consider very important and that aren't taught in most tutorials:

1) Don't use C-Style casts:
char c ;
// C style no.1
int a = (int)c;

// C style no.2
int b = int(c);

Use C++ casts instead:
char c ;
// C++
int a = static_cast<int>(x);

// there also is:
// reinterpret_cast<T>(x)
// const_cast<T>(x)

The reason behind this is that casting in general should be avoided, and clearly visible when it's actually done. The C++ casts are ugly so you don't even want to use them, and they are much more visible than a pair of brackets. You should read up on those later on when you can't avoid casting.

2) Read about the STL (standard template library) and use it. It'll make your life so much easier. You can code some stuff that is part of the STL as coding practice, but for other code you should use the STL classes most of the time.


Thanks, I'll look into that!

Also, I found a "Learning C++" that some guy wrote: http://www.isotton.com/devel/docs/lcpp/
I've around 30pages until now, and I just got my first 4 assignments, but I've been sitting here for 30 minutes trying to figure out how the hell to do #1 lol.

+ Show Spoiler +


1. Write a program asking for an integer number and saying whether it is
positive or not. (Zero is not positive).
       This is what I've come up with so far, lol:

#include <iostream>
using namespace std;

int main() {

cout << "Tell me a number, and I will tell you if it is positive or not!\n";

int choice;
cin >> choice;

system("PAUSE"); // I finally got the damn window to STAY up and not instaclose lol
}



The thing I don't really get is WHAT is the damn integer number? Okay so an integer number is basically just any number without a decimal, got it. Still I have no idea how to go about this one *sigh*

EDIT: I think I got it!! *in spoiler tag below*

+ Show Spoiler +

#include <iostream>
using namespace std;

int main() {

cout << "Tell me a number, and I will tell you if it is positive or negative!\n";

int number;
cin >> number;

if (number > 0)
cout << "The number you have chosen is positive.\n";
else
cout << "The number you have chosen is not positive.\n;


system("PAUSE");
}




Sidenote: I'm using Dev-C++ right now, but I don't really like how it forces me to set up my code in a certain way. It doesn't look as organized as it could, in my eyes. *fume*



Some notes: First of all, for the love of coding, download MS VC++ 2010. Dev-C++ is horribly outdated. Now for some things on your code:

system("PAUSE"); is bad practice. Everything system() is usually regarded as bad practice, it's windows only and very slow, and can cause all kinds of hell, you don't need to know exactly why, and neither do I. So some alternatives:


#include <iostream>
using namespace std;
cout << "Press any key to continue.";
cin.get();

#include <conio.h>
using namespace std;
cout << "Press any key to continue.";
_getch();


Out of these two I believe the first one is more commonly used. Oh and you could also run the program from command line.

Now about coding style, there are 2 common ways to use the curly brackets;


int main() {
return 0;
}

int main()
{
return 0;
}


Chances are your code just uses one style because it's all from the same author, but be aware of both of them. I personally find the second option a lot more easier on the eye... Or something.

For your if statement, while it works, you should try to always use curly brackets. Example:


Let's say you have this:

if (number > 0)
cout << "The number you have chosen is positive.\n";
else
cout << "The number you have chosen is not positive.\n;

Now let's say you want to do something additionally to just printing if it's > or < 0, like counting every time it's a positive number.

if (number > 0)
cout << "The number you have chosen is positive.\n";
counter++;
else
cout << "The number you have chosen is not positive.\n;

RUH ROH, now the counter isn't actually included inside the if, you'll probably get a compile error(?) because the else isn't directly after the if, what you have in fact got is

if (number > 0)
cout << "The number you have chosen is positive.\n";

counter++;
else
cout << "The number you have chosen is not positive.\n;


While you probably knew this, it's still better practice to always use curly brackets. While it's not a concern for you right now, you want your code to be as readable as possible to other coders. Also it makes it easier to expand on your code.

And lastly, remember to return your main function like this return(0); at the very end of it. I believe it doesn't matter because the compiler actually takes care of it for you, but I could be wrong. Just do it anyways, better practice.

Goddamn this post is long.
rocketboy77
Profile Joined July 2010
171 Posts
July 11 2010 10:20 GMT
#129
On July 11 2010 19:11 Adeny wrote:And lastly, remember to return your main function like this return(0); at the very end of it. I believe it doesn't matter because the compiler actually takes care of it for you, but I could be wrong. Just do it anyways, better practice.

It's not necessary, but it doesn't hurt either. You also don't need the brackets, but again, it's a style choice.
LuckyLuke43
Profile Joined May 2010
Norway169 Posts
July 11 2010 10:23 GMT
#130

Some notes: First of all, for the love of coding, download MS VC++ 2010. Dev-C++ is horribly outdated.


It's almost downloaded! ;D;D Sry, I have no idea what's outdated and not, I'm a total newbie in the full sense of the word!


Now for some things on your code:

system("PAUSE"); is bad practice. Everything system() is usually regarded as bad practice, it's windows only and very slow, and can cause all kinds of hell, you don't need to know exactly why, and neither do I.


I actually had no idea.. thanks, I will get rid of this nonsense at once! *rawr*



#include <iostream.h>
using namespace std;
cout << "Press any key to continue."
cin.get()

#include <conio.h>
using namespace std;
cout << "Press any key to continue."
_getch();


Out of these two I believe the first one is more commonly used. Oh and you could also run the program from command line.

Now about coding style, there are 2 common ways to use the curly brackets;


int main() {
return 0;
}

int main()
{
return 0;
}


Chances are your code just uses one style because it's all from the same author, but be aware of both of them. I personally find the second option a lot more easier on the eye... Or something.

For your if statement, while it works, you should try to always use curly brackets. Example:


Let's say you have this:

if (number > 0)
cout << "The number you have chosen is positive.\n";
else
cout << "The number you have chosen is not positive.\n;

Now let's say you want to do something additionally to just printing if it's > or < 0, like counting every time it's a positive number.

if (number > 0)
cout << "The number you have chosen is positive.\n";
counter++;
else
cout << "The number you have chosen is not positive.\n;

RUH ROH, now the counter isn't actually included inside the if, you'll probably get a compile error(?) because the else isn't directly after the if, what you have in fact got is

if (number > 0)
cout << "The number you have chosen is positive.\n";

counter++;
else
cout << "The number you have chosen is not positive.\n;


While you probably knew this, it's still better practice to always use curly brackets. While it's not a concern for you right now, you want your code to be as readable as possible to other coders. Also it makes it easier to expand on your code.

And lastly, remember to return your main function like this return(0); at the very end of it. I believe it doesn't matter because the compiler actually takes care of it for you, but I could be wrong. Just do it anyways, better practice.

Goddamn this post is long.


Don't worry about it being long, it's well appreciated!
[Indent] About these things tho, they mean nothing to me at the moment... however, after I'm done with this 'c++ for dummies' thingy, I'll def get back to this post and try to implement it in my coding! - Thanks alot for the help.

Oh yes, and I noticed the brackets and the return right after posting *blush*. also, I've been using -> return 0;
is return (0); better or does it not matter?

Once again thanks<3
Our deepest fear is not that we are inadequate. Our deepest fear is that we are powerful beyond measure.
Adeny
Profile Blog Joined January 2009
Norway1233 Posts
July 11 2010 10:25 GMT
#131
Oops, my appoligies, I meant return 0; as you didn't have that originally. My bad!
LuckyLuke43
Profile Joined May 2010
Norway169 Posts
July 11 2010 10:44 GMT
#132
Ha! owned *tickle*

Btw I finished assigment 1. Second assignment is much worse lol.

2. Modify the previous program so that it says whether the number is positive,
negative or zero. - EEEEEK =((

Will this work?



if (choice > 0)
{
cout << "The number you have chosen is positive.\n";
}

else if (choice < 0)
{
cout << "The number you have chosen is negative\n";
}

else
{
cout << "The number you have chosen is zero.\n";
}



or something like that..
I'm guessing no, but ;P
Our deepest fear is not that we are inadequate. Our deepest fear is that we are powerful beyond measure.
Adeny
Profile Blog Joined January 2009
Norway1233 Posts
July 11 2010 10:54 GMT
#133
That looks exactly right. Also I accidently said #include <iostream.h> further up, it's obviously supposed to be #include <iostream>. Typos, typos everywhere.
haduken
Profile Blog Joined April 2003
Australia8267 Posts
Last Edited: 2010-07-11 11:20:13
July 11 2010 10:55 GMT
#134
\n is a character literal, for the sake of platform sanity.

use cout << YourString << endl; format

fixed..

Rillanon.au
Adeny
Profile Blog Joined January 2009
Norway1233 Posts
July 11 2010 10:57 GMT
#135
For the sake of my curiosity, which platform doesn't accept \n? I haven't come across one yet.
LuckyLuke43
Profile Joined May 2010
Norway169 Posts
July 11 2010 11:02 GMT
#136
On July 11 2010 19:54 Adeny wrote:
That looks exactly right. Also I accidently said #include <iostream.h> further up, it's obviously supposed to be #include <iostream>. Typos, typos everywhere.


Awesome! Now I just have to find out how the heck to compile from MS visual lol. Yeah I was wondering about the .h thingy. Might've been essential for all I knew tho

On July 11 2010 19:55 haduken wrote:
\n is a character literal, for the sake of platform sanity.

use cout << YourString << endl format;



Oh god. Okay, the first person that tried to help me said do it like this:
cout << "blabla" << endl;

Then someone came along and went:
nono, see it's like this -> cout << "blabla\n";

And now this! eeek.

Okay. So.

cout << MyString << endl format;
or
cout << MyString << endl;
?
Our deepest fear is not that we are inadequate. Our deepest fear is that we are powerful beyond measure.
dvide
Profile Joined March 2010
United Kingdom287 Posts
Last Edited: 2010-07-11 11:05:05
July 11 2010 11:04 GMT
#137
On July 11 2010 19:55 haduken wrote:
\n is a character literal, for the sake of platform sanity.

use cout << YourString << endl format;


Actually '\n' is portable in C++, it will become the platform's equivalent new line character(s). So that's not the purpose of std::endl.

std::endl is for inserting a newline and flushing the stream's buffer, which isn't necessarily what you always want to do. For instance, if you're writing to a buffered file stream then arbitrarily flushing on every new line might take a lot longer than allowing it to buffer naturally. If the file is a debugger's log then you might want to flush more often in case your program crashes before it gets a chance to flush the log stream, but then it's probably best to use an unbuffered stream anyway.
Adeny
Profile Blog Joined January 2009
Norway1233 Posts
July 11 2010 11:07 GMT
#138
That would be yet another typo LuckyLuke. There's no endl format; what he meant was endl; format. For now I don't think you should really bother about the difference between \n and endl.
LuckyLuke43
Profile Joined May 2010
Norway169 Posts
July 11 2010 11:16 GMT
#139
On July 11 2010 20:07 Adeny wrote:
That would be yet another typo LuckyLuke. There's no endl format; what he meant was endl; format. For now I don't think you should really bother about the difference between \n and endl.


Yeah, I agree *blush*. When I get to a higher level of skill/knowledge, I'm guessing I will look back and go: "jesus freakin' christ I can't believe I actually asked 3(!!) times about that... *facepalm*" lol.
Our deepest fear is not that we are inadequate. Our deepest fear is that we are powerful beyond measure.
haduken
Profile Blog Joined April 2003
Australia8267 Posts
Last Edited: 2010-07-11 11:21:17
July 11 2010 11:18 GMT
#140
On July 11 2010 20:04 dvide wrote:
Show nested quote +
On July 11 2010 19:55 haduken wrote:
\n is a character literal, for the sake of platform sanity.

use cout << YourString << endl format;


Actually '\n' is portable in C++, it will become the platform's equivalent new line character(s). So that's not the purpose of std::endl.

std::endl is for inserting a newline and flushing the stream's buffer, which isn't necessarily what you always want to do. For instance, if you're writing to a buffered file stream then arbitrarily flushing on every new line might take a lot longer than allowing it to buffer naturally. If the file is a debugger's log then you might want to flush more often in case your program crashes before it gets a chance to flush the log stream, but then it's probably best to use an unbuffered stream anyway.


I thought that would depend on the particular compiler. (It's being a while, so I will give you the benefit of the doubt). I remembered my Lecturer going on about \n being mapped to different ASCII codes on different platforms...

I certainly had trouble with Windows files feed with \n in codes and reading them in Linux and vice versa but that was pretty raw C.
Rillanon.au
Prev 1 5 6 7 8 9 1032 Next
Please log in or register to reply.
Live Events Refresh
Big Brain Bouts
16:00
#122
SHIN vs Elazer
Percival vs Nicoract
Reynor vs Lambo
RotterdaM908
Liquipedia
Epic.LAN
13:00
Epic.LAN 48 Group Stage
epiclan55
Liquipedia
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
RotterdaM 908
UpATreeSC 118
Livibee 72
mouzHeroMarine 67
BRAT_OK 53
RushiSC 35
MindelVK 11
StarCraft: Brood War
Calm 4187
GuemChi 2001
Rain 1872
EffOrt 730
Mini 674
BeSt 418
ZerO 243
Rush 225
Larva 201
firebathero 142
[ Show more ]
ggaemo 131
Dewaltoss 112
hero 79
Sharp 56
soO 47
Free 42
Sexy 38
sorry 32
Terrorterran 25
Hm[arnc] 21
Rock 19
NaDa 15
ajuk12(nOOB) 11
Dota 2
qojqva3737
Fuzer 82
Counter-Strike
fl0m1526
ScreaM1326
byalli858
allub367
Heroes of the Storm
Khaldor166
Trikslyr63
Other Games
singsing2002
Beastyqt532
B2W.Neo413
XaKoH 178
ToD98
QueenE62
ZerO(Twitch)16
Organizations
Other Games
gamesdonequick2294
StarCraft 2
TaKeTV419
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
[ Show 15 non-featured ]
StarCraft 2
• intothetv
• AfreecaTV YouTube
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• Michael_bg 8
• 80smullet 5
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
League of Legends
• TFBlade1215
Other Games
• imaqtpie472
• Shiphtur403
Upcoming Events
Replay Cast
6h 35m
RSL Revival
15h 35m
Clem vs Lambo
Scarlett vs Cure
CranKy Ducklings
16h 35m
Epic.LAN
19h 35m
IPSL
22h 35m
Dragon vs Hawk
RSL Revival
1d 15h
Classic vs Trap
herO vs SHIN
Sparkling Tuna Cup
1d 16h
OSC
1d 19h
IPSL
1d 22h
Bonyth vs Ret
WardiTV Weekly
2 days
[ Show More ]
Monday Night Weeklies
2 days
PiGosaur Cup
4 days
The PondCast
4 days
Replay Cast
5 days
CrankTV Team League
5 days
Replay Cast
6 days
CrankTV Team League
6 days
Liquipedia Results

Completed

Proleague 2026-07-13
HSC XXIX
Eternal Conflict S2 E2

Ongoing

IPSL Spring 2026
Acropolis #4
YSL S3
CSL 2026 Summer (S21)
KCM Race Survival 2026 Season 3
Escore Tournament S3: W3
RSL Revival: Season 6
CranK Gathers Season 4: BW vs SC2 Team League
SCTL 2026 Spring
Stake Ranked Episode 3
XSE Pro League 2026
IEM Cologne Major 2026
Stake Ranked Episode 2
CS Asia Championships 2026
Asian Champions League 2026
IEM Atlanta 2026
PGL Astana 2026

Upcoming

ASL S22 SEASON OPEN Day 1
Escore Tournament S3: W4
ASL S22 SEASON OPEN Day 2
Escore Tournament S3: W5
CSLAN 4
Blizzard Classic Cup 2026
HSC XXX
SC4ALL II: StarCraft II
Kung Fu Cup 2026 Grand Finals
Light Tournament 2026
Eternal Conflict S2 Finale
Eternal Conflict S2 E3
Logitech G Connect 2026
StarSeries Fall 2026
FISSURE Playground #5
BLAST Open Fall 2026
Esports World Cup 2026
BLAST Bounty Summer 2026
BLAST Bounty Summer Qual
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.