• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 11:08
CEST 17:08
KST 00:08
  • 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
ZeroSpace Early Access is Now Live!8Weekly Cups (July 13-19): Terran & Protoss rise; Zerg falters2Balance hotfix patch 5.0.16b (July 16)72Reynor: GSL Loss Wasn't About Preparation Format16[IPSL] Spring 2026 Grand Finals - This Weekend!18
StarCraft 2
General
Balance hotfix patch 5.0.16b (July 16) Weekly Cups (July 13-19): Terran & Protoss rise; Zerg falters How would you feel about frequent/monthly balance patches for SC2? Clem: "I don't have that much hope in Blizzard" [D] Wireframe Casting Removed
Tourneys
RSL Revival: Season 6 - Qualifiers and Main Event Master Swan Open (Global Bronze-Master 2) WardiTV Summer Cup 2026 GSL CK #5 Race War 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
Mutation # 535 Assembly of Vengeance The PondCast: SC2 News & Results Mutation # 534 Burning Evacuation Mutation # 533 Die Together
Brood War
General
HORROR STARCRAFT MOVIE BGH Auto Balance -> http://bghmmr.eu/ How Famous was FlaSh before his Debut? BW General Discussion screpdb: new Starcraft reporting tool
Tourneys
[Megathread] Daily Proleagues [IPSL] Spring 2026 Grand Finals - This Weekend! Escore Tournament - Season 3 Small VOD Thread 2.0
Strategy
Simple Questions, Simple Answers PvT advise for noobs Fighting Spirit mining rates Creating a full chart of Zerg builds
Other Games
General Games
ZeroSpace Early Access is Now Live! ZeroSpace at Steam NextFest - Last free demo Path of Exile Nintendo Switch Thread 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 Russo-Ukrainian War Thread How to buy a book - shipping from Korea to Europe The Games Industry And ATVI UK Politics Mega-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 TeamLiquid Health and Fitness Initiative For 2023 Formula 1 Discussion MLB/Baseball 2023 McBoner: A hockey love story
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread Simple Questions Simple Answers FPS when play League Of Legend on laptop
TL Community
Northern Ireland Global Starcraft The Automated Ban List
Blogs
Hello guys!
LIN1s
Role of Gaming on Mental Hea…
TrAiDoS
ASL S22 English Commentary…
namkraft
Poker (part 2)
Nebuchad
An Exploration of th…
waywardstrategy
ramps on octagon
StaticNine
Customize Sidebar...

Website Feedback

Closed Threads



Active: 4981 users

The Big Programming Thread - Page 847

Forum Index > General Forum
Post a Reply
Prev 1 845 846 847 848 849 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.
Acrofales
Profile Joined August 2010
Spain18381 Posts
February 18 2017 08:29 GMT
#16921
On February 18 2017 16:40 Hanh wrote:
Show nested quote +
On February 18 2017 16:12 Acrofales wrote:
Re Hahn: it's not true that (1) is a weaker or stronger version of (2). They say completely different things about the set. The original statement says there is no minimum element. (1) says there is a minimum element. (2) says nothing about minima, but instead says there is no maximum element. For instance, (1) is true for the set [0, 1,2], but (2) is not (and neither is the original statement).


OK, but you misquoted me. I wasn't referring to these statements.

Travis:
Show nested quote +

there exists x, such that for all y

and

for all y, there exists x


Me:
Show nested quote +

Not sure what you mean by that, the 1st statement is stronger than the 2nd. (1) is false but (2) is true.


Do you disagree with me?



Still do. They just mean something completely different.

For all dragons, there exists a fairy (that rides it). This is a true statement in our world, because there are no dragons. And thus all of them are indeed ridden by fairies.

There exists a dragon for which all fairies ride it. This is a false statement in our world, because this requires the existence of a dragon.

However:
For all natural numbers x there exists a natural number y != x such that x < y is false. As above, choose x=0 and you have a counterexample.

There is a natural number x, such that for all natural numbers y != x, x < y is true. The natural number for which this holds is x=0.

It's hard to describe this formally without referring to models, but presumably you can piece the rest together yourself? If not I'll give the proof using models this evening. Now I'm going skiing
Hanh
Profile Joined June 2016
146 Posts
Last Edited: 2017-02-18 09:11:57
February 18 2017 09:11 GMT
#16922
Look at the variables.


there exists x, such that for all y

and

for all y, there exists x


They are flipped in the second statement.

For any predicate P(x, y) for which,

If [there is a x for which for all y, P(x, y) is true] then [for all y, there is a x for which P(x, y) is true].

In the first case x cannot depend on y. In the second case it can.




Prillan
Profile Joined August 2011
Sweden350 Posts
February 18 2017 09:27 GMT
#16923
On February 18 2017 18:11 Hanh wrote:
Look at the variables.

Show nested quote +

there exists x, such that for all y

and

for all y, there exists x


They are flipped in the second statement.

For any predicate P(x, y) for which,

If [there is a x for which for all y, P(x, y) is true] then [for all y, there is a x for which P(x, y) is true].

In the first case x cannot depend on y. In the second case it can.


Just wanted to say that this is correct.

(a) exists x. forall y. P(x, y) => (b) forall y. exists x. P(x, y)

Thus, (a) is stronger than (b). It seems Acrofales didn't notice the flipped order of the variables in the quantifications.
TheBB's sidekick, aligulac.com | "Reality is frequently inaccurate." - Douglas Adams
Askelad
Profile Joined October 2016
France20 Posts
Last Edited: 2017-02-18 17:59:15
February 18 2017 11:45 GMT
#16924
.
Blitzkrieg0
Profile Blog Joined August 2010
United States13132 Posts
Last Edited: 2017-02-18 15:46:28
February 18 2017 15:24 GMT
#16925
On February 18 2017 14:29 dsyxelic wrote:
Show nested quote +
On February 18 2017 10:49 Blitzkrieg0 wrote:
Which node are you actually deleting is probably where you're running into issues.

When you delete the final node in the list your pointer is at position p. p.next is the final node in the list and it's p.next.next value is null. When you set the node at position p's next value to null you're removing the last node in the list as expected and not causing a problem.

HEAD -> [1] -> [2] -> [3] -> [4] -> [5] -> [6] -> [7] -> null


So if I need to delete 7, I want to traverse the list until p.next == 7. p will be at 6. Then I set p.next equal to p.next.next. The resulting list:

HEAD -> [1] -> [2] -> [3] -> [4] -> [5] -> [6] -> null



Consider the difference between delete(value) and delete(pointer). In the latter you've already done the search which is causing the discrepancy. The delete(value) function runs in O(n) time because you must traverse the list to find the node. However, the function signature looks like you're telling it to delete a pointer after you've traversed the list making it a O(1) deletion time. There is no search in the pseudo code.

Same example, but with delete(pointer):
function delete(6)
p=position
p.next = p.next.next


p.next.next is null. Set p.next equal to null and node 7 is removed in constant time.


Hi, thanks for this.
So I guess my confusion comes from my 'end' function not really being the true end of the list.

For example on my list x: 1 -> 2 -> 3 -> 4



I think it makes more sense to have everything based on the idea that you're returning p, but the value p.next is the actual result you're looking for. As long as all your function calls follow this pattern then the data structure makes sense. However, if you like the way you've set it up then it isn't wrong either. This is where documentation becomes important.

Does your list x look like:

A:
 HEAD -> [1] -> [2] -> [3] -> [4] -> null 

B:
 [1] -> [2] -> [3] -> [4] -> null 


Note in the A case that HEAD is a pointer to an empty node that does not contain any data. You'll still have an edge case at the front when you're making a new list, but you're only going to make the list once. You're always going to have these edge cases when you're implementing the data structure. It's more about implementing them in a way that causes the fewest amount of problems.

When the list is empty HEAD is null. When the list is created you create two nodes, the head node and add head.next as the first node. If you do end() on this you return HEAD and have head.next as the end of the list. If you then delete this pointer as per my previous post it will delete the correct node.

Alternately you can always have a list that is pointed to by HEAD. If HEAD.next is null then your list is empty and you need to insert as a special case.

When you're implementing data structures how the code actually works behind the scenes is irrelevant. You have certain methods exposed that are documented to do what they say they do. It is up to the user to utilize them properly.
I'll always be your shadow and veil your eyes from states of ain soph aur.
Buckyman
Profile Joined May 2014
1364 Posts
Last Edited: 2017-02-18 17:18:28
February 18 2017 17:18 GMT
#16926
On February 18 2017 14:29 dsyxelic wrote:

seems fine? though I'm curious how python's default list is so much faster in every way possible


Most python implementations store their lists in a partly full array. Removing an element from the end is as quick as decreasing the 'size' variable, except that if you remove a lot of them it'll copy the remaining list into a smaller array.
Deleted User 3420
Profile Blog Joined May 2003
24492 Posts
Last Edited: 2017-02-18 18:52:49
February 18 2017 18:50 GMT
#16927
Anyone want to tell me what they think of this C code? I feel like it's pretty well written. To the point. Normally I end up making these small exercises way more convoluted than they need to be. (inb4 i find out it's shit)

the specifications are to take the prototype and implement the function. the function takes the source string and copies it to the results string with leading and trailing whitespace removed. it then records how many spaces were removed into number_of_spaces. You return -1 if there was nothing to copy over.

code:

+ Show Spoiler +


int remove_spaces(const char *source, char *result, int *num_spaces_removed) {
int i = 0;
int j = strlen(source) - 1;
int k = 0;
int z = 0;

if(source == NULL || j == -1) {
return -1;
}


while(source[i]) {
if(source[i] == ' ') {
i++;
continue;
}
break;
}


while(1) {
if(source[j] == ' ') {
j--;
continue;
}
break;
}

for(k=i; k < (j+1); k++) {
printf("%d %d\n", k, j);
result[z] = source[k];
z++;
}

result[z] = '\0';

*num_spaces_removed = (strlen(source) - strlen(result));


return 0;
}


Biolunar
Profile Joined February 2012
Germany224 Posts
February 18 2017 19:12 GMT
#16928
On February 19 2017 03:50 travis wrote:
Anyone want to tell me what they think of this C code? I feel like it's pretty well written. To the point. Normally I end up making these small exercises way more convoluted than they need to be. (inb4 i find out it's shit)

the specifications are to take the prototype and implement the function. the function takes the source string and copies it to the results string with leading and trailing whitespace removed. it then records how many spaces were removed into number_of_spaces. You return -1 if there was nothing to copy over.

code:

+ Show Spoiler +


int remove_spaces(const char *source, char *result, int *num_spaces_removed) {
int i = 0;
int j = strlen(source) - 1;
int k = 0;
int z = 0;

if(source == NULL || j == -1) {
return -1;
}


while(source[i] {
if(source[i] == ' ') {
i++;
continue;
}
break;
}


while(1) {
if(source[j] == ' ') {
j--;
continue;
}
break;
}

for(k=i; k < (j+1); k++) {
printf("%d %d\n", k, j);
result[z] = source[k];
z++;
}

result[z] = '\0';

*num_spaces_removed = (strlen(source) - strlen(result));


return 0;
}


Whoever gave you that prototype is a C rookie.
int *num_spaces_removed
Really? That screams for buggy code on all major 64 bit platforms. Why is that you may ask:
int j = strlen(source) - 1;

if the source string has lenght 0 (i.e. source = ""),
strlen(source) - 1
will wrap around because strlen returns a size_t. So you are basicly asigning SIZE_MAX to j. Please set your compiler warnings higher! The compiler will complain about this line because you are truncating a size_t to an int. Remember: object sizes must be of type size_t!

Other than that I have no clue to what your function is trying to achive. The first two loops are completly unecessary. Just loop once and copy every character from source to dest and skip spaces. You need just two counting variables for both strings.
What is best? To crush the Zerg, see them driven before you, and hear the lamentations of the Protoss.
Deleted User 3420
Profile Blog Joined May 2003
24492 Posts
Last Edited: 2017-02-18 19:22:27
February 18 2017 19:22 GMT
#16929
interesting about strlen(source) - 1

As for just looping and copying all non-spaces, that doesn't work because we are not skipping spaces that are inbetween non-space characters. We are only removing trailing and leading whitespace.
Biolunar
Profile Joined February 2012
Germany224 Posts
Last Edited: 2017-02-18 19:31:25
February 18 2017 19:30 GMT
#16930
On February 19 2017 04:22 travis wrote:
interesting about strlen(source) - 1

As for just looping and copying all non-spaces, that doesn't work because we are not skipping spaces that are inbetween non-space characters. We are only removing trailing and leading whitespace.

One loop is still enough. Skip the first spaces until you reach a non space character. Use an index (e.g. size_t end) to remember when you copied the last non space character. Once you are done copying, set source[end] to 0 to cut off the last spaces.
That is part of the reason why that prototype sucks. There is no parameter to specify how large the dest buffer is…
What is best? To crush the Zerg, see them driven before you, and hear the lamentations of the Protoss.
Acrofales
Profile Joined August 2010
Spain18381 Posts
February 18 2017 19:56 GMT
#16931
On February 18 2017 18:11 Hanh wrote:
Look at the variables.

Show nested quote +

there exists x, such that for all y

and

for all y, there exists x


They are flipped in the second statement.

For any predicate P(x, y) for which,

If [there is a x for which for all y, P(x, y) is true] then [for all y, there is a x for which P(x, y) is true].

In the first case x cannot depend on y. In the second case it can.






Okay, I see it now. So for starters, and this is more at travis than at you: quantified variables are quantified variables. For all I cared, you could use "cupcake" as your variable name. If the order of your variables are important, make it explicit.

But either way, the claim is still wrong. For the sake of simplicity, I have written it out here:

(1) \exists x \forall y P(x, y)
is stronger than
(2) \forall x \exists y P(y, x)

This is also not true. All we need to do is find a P and a model m such that m \models (1), but m \not\models (2). Right.

Or if you prefer it in your form of implication (2) \rightarrow (1) is false if (1) is false while (2) ist true (which boils down to essentially the same thing, but is less formal.

Here's a simple counter example:

Let X = {a, b} and Y = {a}
R = {(a, a)}

Now:
\forall x \in X \exists y \in Y such that (y, x) \in R

This is false. Counter example: x=b

However:
\exists x \in X \forall y \in Y such that (x, y) \in R
This is true, because it is true for x=a.

Therefore, unless you also make some requirements of the domains of your variables and probably some properties of P, this is definitely not true.

There is an interesting relationship between the two statements. I'm not sure whether your lemma might be true if we restrict x and y to be from the same set. I didn't immediately see a counterexample (but also haven't looked very hard, or tried to construct a proof).

But the sweeping statement you made is still false even when you clarify the switched variables.

+ Show Spoiler +
Thankfully. Would be rather embarrassing for me to be wrong on something like this
Deleted User 3420
Profile Blog Joined May 2003
24492 Posts
February 18 2017 19:57 GMT
#16932
On February 19 2017 04:30 Biolunar wrote:
Show nested quote +
On February 19 2017 04:22 travis wrote:
interesting about strlen(source) - 1

As for just looping and copying all non-spaces, that doesn't work because we are not skipping spaces that are inbetween non-space characters. We are only removing trailing and leading whitespace.

One loop is still enough. Skip the first spaces until you reach a non space character. Use an index (e.g. size_t end) to remember when you copied the last non space character. Once you are done copying, set source[end] to 0 to cut off the last spaces.
That is part of the reason why that prototype sucks. There is no parameter to specify how large the dest buffer is…


I actually thought about this way. I thought mine was better(easier, at least). Maybe it's not.
dsyxelic
Profile Joined May 2010
United States1417 Posts
February 18 2017 20:04 GMT
#16933
On February 19 2017 00:24 Blitzkrieg0 wrote:
Show nested quote +
On February 18 2017 14:29 dsyxelic wrote:
On February 18 2017 10:49 Blitzkrieg0 wrote:
Which node are you actually deleting is probably where you're running into issues.

When you delete the final node in the list your pointer is at position p. p.next is the final node in the list and it's p.next.next value is null. When you set the node at position p's next value to null you're removing the last node in the list as expected and not causing a problem.

HEAD -> [1] -> [2] -> [3] -> [4] -> [5] -> [6] -> [7] -> null


So if I need to delete 7, I want to traverse the list until p.next == 7. p will be at 6. Then I set p.next equal to p.next.next. The resulting list:

HEAD -> [1] -> [2] -> [3] -> [4] -> [5] -> [6] -> null



Consider the difference between delete(value) and delete(pointer). In the latter you've already done the search which is causing the discrepancy. The delete(value) function runs in O(n) time because you must traverse the list to find the node. However, the function signature looks like you're telling it to delete a pointer after you've traversed the list making it a O(1) deletion time. There is no search in the pseudo code.

Same example, but with delete(pointer):
function delete(6)
p=position
p.next = p.next.next


p.next.next is null. Set p.next equal to null and node 7 is removed in constant time.


Hi, thanks for this.
So I guess my confusion comes from my 'end' function not really being the true end of the list.

For example on my list x: 1 -> 2 -> 3 -> 4



I think it makes more sense to have everything based on the idea that you're returning p, but the value p.next is the actual result you're looking for. As long as all your function calls follow this pattern then the data structure makes sense. However, if you like the way you've set it up then it isn't wrong either. This is where documentation becomes important.

Does your list x look like:

A:
 HEAD -> [1] -> [2] -> [3] -> [4] -> null 

B:
 [1] -> [2] -> [3] -> [4] -> null 


Note in the A case that HEAD is a pointer to an empty node that does not contain any data. You'll still have an edge case at the front when you're making a new list, but you're only going to make the list once. You're always going to have these edge cases when you're implementing the data structure. It's more about implementing them in a way that causes the fewest amount of problems.

When the list is empty HEAD is null. When the list is created you create two nodes, the head node and add head.next as the first node. If you do end() on this you return HEAD and have head.next as the end of the list. If you then delete this pointer as per my previous post it will delete the correct node.

Alternately you can always have a list that is pointed to by HEAD. If HEAD.next is null then your list is empty and you need to insert as a special case.

When you're implementing data structures how the code actually works behind the scenes is irrelevant. You have certain methods exposed that are documented to do what they say they do. It is up to the user to utilize them properly.


Mine looks like B.

I did not know that (bolded part), that's definitely good to know. I implemented in a way that p gives the actual result besides end(). I guess ideally I would have everything consistent but again, the book we're using did it with p giving the actual result and apparently didn't account for deletion from the back.

Thanks though you were a lot of help.
TL/SKT
Deleted User 3420
Profile Blog Joined May 2003
24492 Posts
Last Edited: 2017-02-18 20:12:23
February 18 2017 20:11 GMT
#16934
sometimes I read stuff in this thread and I am amazed at just how smart you guys are. how much varied stuff you guys know and how precise you are at it. and I wonder to myself "how are these guys not able to work anywhere they want on the cutting edge with this much ability". but then again, maybe you are?

But anyways I read it and am just constantly reminded of how much effort I will have to put in to actually be exceptional in this field, when this is how high the bar is set.
spinesheath
Profile Blog Joined June 2009
Germany8679 Posts
Last Edited: 2017-02-18 20:31:09
February 18 2017 20:28 GMT
#16935
On February 19 2017 05:11 travis wrote:
sometimes I read stuff in this thread and I am amazed at just how smart you guys are. how much varied stuff you guys know and how precise you are at it. and I wonder to myself "how are these guys not able to work anywhere they want on the cutting edge with this much ability". but then again, maybe you are?

But anyways I read it and am just constantly reminded of how much effort I will have to put in to actually be exceptional in this field, when this is how high the bar is set.

You see a dozen or more people showing off their knowledge in their respective fields of expertise. You especially don't see people answering with an unhelpful and slightly embarassing "I don't know". You don't need to be exceptionally smart to be good at a couple of things. With actual job experience you also learn a couple of things in detail, often the hard way. That kind of stuff tends to burn itself into your mind.

But yes, this software as a job is not something where you learn stuff once and then stop putting in effort.
If you have a good reason to disagree with the above, please tell me. Thank you.
spinesheath
Profile Blog Joined June 2009
Germany8679 Posts
Last Edited: 2017-02-18 20:30:53
February 18 2017 20:30 GMT
#16936
Gee why do I keep using quote instead of edit...
If you have a good reason to disagree with the above, please tell me. Thank you.
slmw
Profile Blog Joined October 2010
Finland233 Posts
February 18 2017 20:38 GMT
#16937
On February 19 2017 04:57 travis wrote:
Show nested quote +
On February 19 2017 04:30 Biolunar wrote:
On February 19 2017 04:22 travis wrote:
interesting about strlen(source) - 1

As for just looping and copying all non-spaces, that doesn't work because we are not skipping spaces that are inbetween non-space characters. We are only removing trailing and leading whitespace.

One loop is still enough. Skip the first spaces until you reach a non space character. Use an index (e.g. size_t end) to remember when you copied the last non space character. Once you are done copying, set source[end] to 0 to cut off the last spaces.
That is part of the reason why that prototype sucks. There is no parameter to specify how large the dest buffer is…


I actually thought about this way. I thought mine was better(easier, at least). Maybe it's not.


I think with C you need to put a lot of effort into making your code as simple as possible, since the language offers very little help. Fewer moving parts should make the code a lot easier to read. Try to cut as many extra lines of code as long as it also makes the code somewhat more readable. A common pattern in string handling is to simply loop until str[i]==0, instead of using strlen to avoid extra passes. Another common trick is to use a[i++] = b[j++] for copying a string.

With a single pass the code becomes quite a bit shorter:

int i = 0, j = 0, end_pos = 0;
for(i=0;source[i]!=0;i++) {
bool space = source[i]==' ';
if(j || !space ) {
if(!space) end_pos = j+1;
result[j++] = source[i];
}
}
result[end_pos] = 0;
*num_spaces_removed = i-end_pos;
return (i-end_pos) == 0 ? -1 : 0;


You can do two passes in a similar manner:
int j = 0, last_char = -1, len = 0;
for(len=0;source[len]!=0;len++) if(source[len]!=' ') last_char = len;
for(int i=0;i<=last_char;i++) {
if(j || source[i] != ' ') {
result[j++] = source[i];
}
}
result[j] = 0;
*num_spaces_removed = len-j;
return (len-j) == 0 ? -1 : 0;


A lot of this is of course subjective, verbose code might be easier to read for some people. At least after doing a lot of string processing in pure C this style should become easier to read.


Deleted User 3420
Profile Blog Joined May 2003
24492 Posts
February 18 2017 20:52 GMT
#16938
slmw could you explain


bool space = source[i]==' ';


is "bool" in a certain library in C? I was under the impression C doesn't have a boolean type.

What is the syntax here?

bool name = [ statement ] ?
it's syntax is weird to me
Acrofales
Profile Joined August 2010
Spain18381 Posts
February 18 2017 21:04 GMT
#16939
C99 has bools.

as for the use, it's

bool name = <something boolean>

could be

bool stopyet = false;
<do stuff>
stopyet = true;
if (stopyet) {
exit(0);
}


or as slmw wrote, some statement that evaluates to true/false. I would put it between brackets,though. I hate depending on non-obvious precedence between operators for my code to work. Does C parser parse that as:

(bool space = source[i]) == ' '; //gibberish
or
bool space = (source[i] == ' '); //what you want: assigns the outcome of the comparison to your newly declared bool.

If assignment were to have a higher precedence than comparison, C parser would give you the former, which at best wouldn't compile (haven't tested). But that's just personal preference for the style, perhaps if I was more familiar with C, I wouldn't be bothered by it.
tofucake
Profile Blog Joined October 2009
Hyrule19228 Posts
February 18 2017 21:52 GMT
#16940
On February 19 2017 05:30 spinesheath wrote:
Gee why do I keep using quote instead of edit...

It gets even more annoying when you can edit any post...
Liquipediaasante sana squash banana
Prev 1 845 846 847 848 849 1032 Next
Please log in or register to reply.
Live Events Refresh
WardiTV Summer Champion…
12:05
Summer Cup Group B
WardiTV834
TKL 156
LiquipediaDiscussion
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
ByuN 352
ProTech88
SHIN 72
RushiSC 14
trigger 4
StarCraft: Brood War
Calm 6751
Bisu 2845
Shuttle 2321
Jaedong 1254
Soma 821
Light 394
Larva 346
Hyuk 332
Stork 316
firebathero 288
[ Show more ]
Mini 239
actioN 224
Snow 197
Soulkey 195
hero 194
ggaemo 163
Rush 133
Dewaltoss 131
Mong 121
Hyun 93
Sharp 93
Pusan 73
JYJ 44
soO 42
sorry 36
Free 35
910 30
ToSsGirL 29
Movie 28
Bale 22
Barracks 18
Sacsri 16
Sexy 15
Hm[arnc] 14
Rock 14
Terrorterran 14
IntoTheRainbow 13
Noble 12
GoRush 10
zelot 8
ajuk12(nOOB) 8
Dota 2
qojqva2092
Dendi1399
syndereN416
XaKoH 353
XcaliburYe228
League of Legends
Trikslyr41
Counter-Strike
fl0m3057
byalli356
Other Games
FrodaN5838
B2W.Neo828
hiko825
Lowko672
Harstem536
crisheroes357
Hui .203
Liquid`VortiX195
TKL 156
ArmadaUGS116
Livibee101
CosmosSc2 46
Chillindude28
KnowMe22
SteadfastSC14
Organizations
Other Games
BasetradeTV203
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
[ Show 17 non-featured ]
StarCraft 2
• poizon28 17
• mYiSmile114
• Kozan
• AfreecaTV YouTube
• sooper7s
• intothetv
• IndyKCrew
• LaughNgamezSOOP
• Migwel
StarCraft: Brood War
• blackmanpl 17
• HerbMon 2
• STPLYoutube
• ZZZeroYoutube
• BSLYoutube
Dota 2
• C_a_k_e 981
League of Legends
• Nemesis3303
• TFBlade947
Upcoming Events
PiGosaur Cup
8h 52m
The PondCast
18h 52m
Kung Fu Cup
19h 52m
OSC
1d 8h
CrankTV Team League
1d 19h
Replay Cast
2 days
CrankTV Team League
2 days
Korean StarCraft League
3 days
Afreeca Starleague
3 days
RSL Revival
3 days
Serral vs SHIN
herO vs Solar
[ Show More ]
Online Event
3 days
Replay Cast
4 days
RSL Revival
4 days
Clem vs ByuN
Rogue vs Lambo
WardiTV Weekly
5 days
Sparkling Tuna Cup
6 days
Liquipedia Results

Completed

Acropolis #4
HSC XXIX
Eternal Conflict S2 E3

Ongoing

CSL 2026 Summer (S21)
KCM Race Survival 2026 Season 3
RSL Revival: Season 6
CranK Gathers Season 4: BW vs SC2 Team League
SCTL 2026 Spring
BLAST Bounty Summer Qual
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

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
ESL Pro League Season 24
Stake Ranked Episode 4
Logitech G Connect 2026
SL StarSeries Fall 2026
FISSURE Playground #5
BLAST Open Fall 2026
Esports World Cup 2026
BLAST Bounty Summer 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.