• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 07:38
CEST 13:38
KST 20:38
  • 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
Team Liquid Map Contest #22 - The Finalists9[ASL21] Ro16 Preview Pt1: Fresh Flow9[ASL21] Ro24 Preview Pt2: News Flash10[ASL21] Ro24 Preview Pt1: New Chaos0Team Liquid Map Contest #22 - Presented by Monster Energy21
Community News
2026 GSL Season 1 Qualifiers6Maestros of the Game 2 announced22026 GSL Tour plans announced4Weekly Cups (April 6-12): herO doubles, "Villains" prevail0MaNa leaves Team Liquid18
StarCraft 2
General
Team Liquid Map Contest #22 - The Finalists 2026 GSL Tour plans announced Maestros of the Game 2 announced Weekly Cups (April 6-12): herO doubles, "Villains" prevail MaNa leaves Team Liquid
Tourneys
Sparkling Tuna Cup - Weekly Open Tournament 2026 GSL Season 1 Qualifiers Master Swan Open (Global Bronze-Master 2) SEL Doubles (SC Evo Bimonthly) $5,000 WardiTV TLMC tournament - Presented by Monster Energy
Strategy
Custom Maps
[D]RTS in all its shapes and glory <3 [A] Nemrods 1/4 players [M] (2) Frigid Storage
External Content
Mutation # 521 Memorable Boss The PondCast: SC2 News & Results Mutation # 520 Moving Fees Mutation # 519 Inner Power
Brood War
General
ASL21 General Discussion BGH Auto Balance -> http://bghmmr.eu/ Data needed A cwal.gg Extension - Easily keep track of anyone [ASL21] Ro16 Preview Pt1: Fresh Flow
Tourneys
[ASL21] Ro16 Group B [ASL21] Ro16 Group A [ASL21] Ro24 Group F [Megathread] Daily Proleagues
Strategy
What's the deal with APM & what's its true value Any training maps people recommend? Fighting Spirit mining rates Muta micro map competition
Other Games
General Games
Battle Aces/David Kim RTS Megathread Nintendo Switch Thread Stormgate/Frost Giant Megathread General RTS Discussion Thread Starcraft Tabletop Miniature Game
Dota 2
The Story of Wings Gaming Official 'what is Dota anymore' discussion
League of Legends
G2 just beat GenG in First stand
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Deck construction bug Heroes of StarCraft mini-set
TL Mafia
Vanilla Mini Mafia Mafia Game Mode Feedback/Ideas TL Mafia Community Thread Five o'clock TL Mafia
Community
General
Things Aren’t Peaceful in Palestine US Politics Mega-thread Canadian Politics Mega-thread Russo-Ukrainian War Thread European Politico-economics QA Mega-thread
Fan Clubs
The IdrA Fan Club
Media & Entertainment
[Req][Books] Good Fantasy/SciFi books [Manga] One Piece Movie Discussion!
Sports
2024 - 2026 Football Thread Formula 1 Discussion Cricket [SPORT] Tokyo Olympics 2021 Thread
World Cup 2022
Tech Support
[G] How to Block Livestream Ads
TL Community
The Automated Ban List
Blogs
Reappraising The Situation T…
TrAiDoS
lurker extra damage testi…
StaticNine
Broowar part 2
qwaykee
Funny Nicknames
LUCKY_NOOB
Iranian anarchists: organize…
XenOsky
ASL S21 English Commentary…
namkraft
Customize Sidebar...

Website Feedback

Closed Threads



Active: 2284 users

The Big Programming Thread - Page 52

Forum Index > General Forum
Post a Reply
Prev 1 50 51 52 53 54 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.
Manit0u
Profile Blog Joined August 2004
Poland17722 Posts
Last Edited: 2011-05-05 15:50:52
May 04 2011 21:10 GMT
#1021
On May 05 2011 05:47 Pawsom wrote:
Show nested quote +
On May 05 2011 05:44 Manit0u wrote:
On May 05 2011 05:08 Pawsom wrote:
On May 05 2011 03:26 Manit0u wrote:
Could someone please help me out here? I'm a noob and I have a momentary lapse of reason right now as I can't for the life of me recall how to properly loop my program so it won't exit after one go (only when someone enters 0 in any case he's asked to enter input)...
I don't need a ready solution, if you could just push me along by suggesting what should I use I'll be fine (I'm trying to learn some programming for personal uses mostly, like this dice throw generator here).

It's ANSI C if you can't tell.

+ Show Spoiler [code] +


#include <stdio.h>
#include <stdlib.h>
#include <time.h>

struct DiceConfiguration
{
int DiceNumber;
int DiceType;
};

struct DiceThrowsResult
{
int DiceNumber;
int Sum;
int ThrowsResults[];
};

struct DiceConfiguration* GetConfiguration(void);
struct DiceThrowsResult* ThrowDices(struct DiceConfiguration *config);
int ThrowDice(struct DiceConfiguration *config);
void PrintDiceThrowsResult(struct DiceThrowsResult *result);

int main(void)
{
srand((unsigned int) time(0)); // random seed

struct DiceConfiguration *config;
config = GetConfiguration();

struct DiceThrowsResult *result;
result = ThrowDices(config);

PrintDiceThrowsResult(result);

free(config);
free(result);

return 0;
}

struct DiceConfiguration* GetConfiguration(void)
{
struct DiceConfiguration *config;
config = malloc(sizeof(struct DiceConfiguration));

printf("Enter the number of dice: ");
scanf("%d", &config->DiceNumber);
printf("Enter dice type (sides) : ");
scanf("%d", &config->DiceType);

return config;
}

struct DiceThrowsResult* ThrowDices(struct DiceConfiguration *config)
{
struct DiceThrowsResult *result;
result = malloc(sizeof(struct DiceThrowsResult) + config->DiceNumber * sizeof(int));
result->DiceNumber = config->DiceNumber;

for (int i = 0; i < config->DiceNumber; i++)
{
result->ThrowsResults[i] = ThrowDice(config);
result->Sum += result->ThrowsResults[i];
}

return result;
}

int ThrowDice(struct DiceConfiguration *config)
{
return rand() % config->DiceType + 1;
}

void PrintDiceThrowsResult(struct DiceThrowsResult *result)
{

for (int i = 0; i < result->DiceNumber; i++)
{
printf("%d ", result->ThrowsResults[i];
}

printf("Sum: %d\n", result->Sum);
}



So try making a loop inside main, around the function calls to ThrowDices() and PrintDiceThrowsResults(). Do you know the syntax for a while loop in C?

You will need to ask the user to if he wants to continue, and use this input as the condition in your loop. Take a try at this, and post back if you need help.

A basic loop could look like:

+ Show Spoiler +

while (continue != FALSE)
{
doStuff();

doMoreShit();

continue = getContinue();
}



You mean something like that?

+ Show Spoiler +


while (DiceNumber > 0 && DiceType > 0)
{

do stuff

}



Then the entire thing should become a while loop...
The problem I'm facing right now is the right place to put the loop, as this while checks for 2 variables which should be assigned before the loop and it would be pointless to do this stuff over and over again with the same variables (infinite loop welcome to).
My mind is completely empty right now, I need to think about it.



No you should declare another variable. Ask the user if they want to roll again, and store their input in that variable. Loop based on the value of that variable.

+ Show Spoiler +


while( repeat != 'n' )
{
result = ThrowDices(config);

PrintDiceThrowsResult(result);

printf("Want to play again? Enter y/n.");

scanf("%c", &repeat);
}



Did you find the dice program somewhere online? It's well written.



There seems to be some problem with this loop...

It compiles fine but here's how it works now:
+ Show Spoiler +


krs@chameleon:~/workspace/C/dice_generator> ./a.out
Enter the number of dice: 4
Enter dice type (sides) : 6
3 2 3 3 Sum: 11
Want to play again? Enter y/n.2 5 5 2 Sum: 14
Want to play again? Enter y/n.y
4 2 5 3 Sum: 14
Want to play again? Enter y/n.1 1 1 1 Sum: 4
Want to play again? Enter y/n.y
3 1 5 3 Sum: 12
Want to play again? Enter y/n.2 1 5 3 Sum: 11
Want to play again? Enter y/n.n
krs@chameleon:~/workspace/C/dice_generator>



I did it differently myself, looped the entire code up until main return, it allowed me to enter new dice and printed results fine, the problem was it auto-skipped the continue question (it posted it but automatically continued the loop, without waiting for input).

And to answer your question, I didn't find it anywhere, I wrote it myself with a bit of help from a friend (we were bored at the lake due to bad weather, didn't even have internet there). We started with a simple for loop and one structure and it kinda evolved as we got new ideas

Edit3: Got it to work as planned! All the Pen & Paper RPG fans can now enjoy

+ Show Spoiler +


#include <stdio.h>
#include <stdlib.h>
#include <time.h>

struct DiceConfiguration
{
int DiceNumber;
int DiceType;
};

struct DiceThrowsResult
{
int DiceNumber;
int Sum;
int ThrowsResults[];
};

struct DiceConfiguration* GetConfiguration(int FirstEntry);
struct DiceThrowsResult* ThrowDices(struct DiceConfiguration *config);
int ThrowDice(struct DiceConfiguration *config);
void PrintDiceThrowsResult(struct DiceThrowsResult *result);
void WelcomeMessage(void);
void ReleaseMemory(struct DiceConfiguration *config, struct DiceThrowsResult *result);

int main(void)
{
struct DiceConfiguration *config;
struct DiceThrowsResult *result;
int FirstEntry;

WelcomeMessage();

while(scanf("%d", &FirstEntry) == 1 && FirstEntry > 0)
{
srand((unsigned int) time(0)); // random seed

config = GetConfiguration(FirstEntry);

result = ThrowDices(config);

PrintDiceThrowsResult(result);

WelcomeMessage();
}

ReleaseMemory(config, result);

return 0;
}

struct DiceConfiguration* GetConfiguration(int FirstEntry)
{
struct DiceConfiguration *config;
config = malloc(sizeof(struct DiceConfiguration));

config->DiceNumber = FirstEntry;
printf("Enter dice type (sides) : ");
scanf("%d", &config->DiceType);

return config;
}

struct DiceThrowsResult* ThrowDices(struct DiceConfiguration *config)
{
struct DiceThrowsResult *result;
result = malloc(sizeof(struct DiceThrowsResult) + config->DiceNumber * sizeof(int));
result->DiceNumber = config->DiceNumber;

for (int i = 0; i < config->DiceNumber; i++)
{
result->ThrowsResults[i] = ThrowDice(config);
result->Sum += result->ThrowsResults[i];
}

return result;
}

int ThrowDice(struct DiceConfiguration *config)
{
return rand() % config->DiceType + 1;
}

void PrintDiceThrowsResult(struct DiceThrowsResult *result)
{

for (int i = 0; i < result->DiceNumber; i++)
{
printf("%d ", result->ThrowsResults[i]);
}

printf("Sum: %d\n", result->Sum);
}

void WelcomeMessage(void )
{
printf("Enter the number of dice to throw (0 to quit): ");
}

void ReleaseMemory(struct DiceConfiguration *config, struct DiceThrowsResult *result)
{
if (config != NULL)
{
free(config);
config = NULL;
}

if (result != NULL)
{
free(result);
result = NULL;
}
}

Time is precious. Waste it wisely.
lbmaian
Profile Joined December 2010
United States689 Posts
May 05 2011 11:21 GMT
#1022
Off topic but nifty - John Resig (jQuery creator) posted an AMA on reddit recently, where he mentions he's a huge SC2 fan: http://www.reddit.com/r/IAmA/comments/h42ak/i_am_john_resig_creator_of_jquery_ama/ o_o
jaydubz
Profile Joined February 2011
21 Posts
Last Edited: 2011-05-05 15:13:26
May 05 2011 14:44 GMT
#1023
Currently having an issue with a custom find/replace feature for Access.

Currently the code operates on a form, and searches either 'all' or a particular column of your choosing. You then provide the text you wish to replace and what you wish to replace it with. Currently the replacing is done using the Replace function.

An issue this has raised is when you only want to match particular words instead of portions of words. For instance, if the find was "Sieb" and the replace was "C++", "SiebList" would change to "C++list", when in fact, we only want "Sieb" to change to "C++" and "SiebList" to remain unchanged.

There may be an instance where we don't want portions of words being replaced. How can we differentiate between exact words and portions of words?

We'd obviously use a Boolean to determine if the user wants partial matching or exact matching.

+ Show Spoiler +

Do While Not rs.EOF
If InStr(rs.Fields!STEP, txtReplace.Value) = 1 Then
find = rs.Fields!DESCRIPTION.Value
rs.Edit
rs.Fields!STEP = Replace(find, rString, rWString)
rs.Update
End If
rs.MoveNext
Loop


Is splitting the value into an array on the " " delim and then comparing each value of the array and replacing/re-constructing the most elegant way of doing this?

Perhaps searching for " value " (white space surrounding the value)? Would not work for one value records though.

Deleted User 101379
Profile Blog Joined August 2010
4849 Posts
May 05 2011 15:19 GMT
#1024
On May 05 2011 06:10 Manit0u wrote:
Show nested quote +
On May 05 2011 05:47 Pawsom wrote:
On May 05 2011 05:44 Manit0u wrote:
On May 05 2011 05:08 Pawsom wrote:
On May 05 2011 03:26 Manit0u wrote:
Could someone please help me out here? I'm a noob and I have a momentary lapse of reason right now as I can't for the life of me recall how to properly loop my program so it won't exit after one go (only when someone enters 0 in any case he's asked to enter input)...
I don't need a ready solution, if you could just push me along by suggesting what should I use I'll be fine (I'm trying to learn some programming for personal uses mostly, like this dice throw generator here).

It's ANSI C if you can't tell.

+ Show Spoiler [code] +


#include <stdio.h>
#include <stdlib.h>
#include <time.h>

struct DiceConfiguration
{
int DiceNumber;
int DiceType;
};

struct DiceThrowsResult
{
int DiceNumber;
int Sum;
int ThrowsResults[];
};

struct DiceConfiguration* GetConfiguration(void);
struct DiceThrowsResult* ThrowDices(struct DiceConfiguration *config);
int ThrowDice(struct DiceConfiguration *config);
void PrintDiceThrowsResult(struct DiceThrowsResult *result);

int main(void)
{
srand((unsigned int) time(0)); // random seed

struct DiceConfiguration *config;
config = GetConfiguration();

struct DiceThrowsResult *result;
result = ThrowDices(config);

PrintDiceThrowsResult(result);

free(config);
free(result);

return 0;
}

struct DiceConfiguration* GetConfiguration(void)
{
struct DiceConfiguration *config;
config = malloc(sizeof(struct DiceConfiguration));

printf("Enter the number of dice: ");
scanf("%d", &config->DiceNumber);
printf("Enter dice type (sides) : ");
scanf("%d", &config->DiceType);

return config;
}

struct DiceThrowsResult* ThrowDices(struct DiceConfiguration *config)
{
struct DiceThrowsResult *result;
result = malloc(sizeof(struct DiceThrowsResult) + config->DiceNumber * sizeof(int));
result->DiceNumber = config->DiceNumber;

for (int i = 0; i < config->DiceNumber; i++)
{
result->ThrowsResults[i] = ThrowDice(config);
result->Sum += result->ThrowsResults[i];
}

return result;
}

int ThrowDice(struct DiceConfiguration *config)
{
return rand() % config->DiceType + 1;
}

void PrintDiceThrowsResult(struct DiceThrowsResult *result)
{

for (int i = 0; i < result->DiceNumber; i++)
{
printf("%d ", result->ThrowsResults[i];
}

printf("Sum: %d\n", result->Sum);
}



So try making a loop inside main, around the function calls to ThrowDices() and PrintDiceThrowsResults(). Do you know the syntax for a while loop in C?

You will need to ask the user to if he wants to continue, and use this input as the condition in your loop. Take a try at this, and post back if you need help.

A basic loop could look like:

+ Show Spoiler +

while (continue != FALSE)
{
doStuff();

doMoreShit();

continue = getContinue();
}



You mean something like that?

+ Show Spoiler +


while (DiceNumber > 0 && DiceType > 0)
{

do stuff

}



Then the entire thing should become a while loop...
The problem I'm facing right now is the right place to put the loop, as this while checks for 2 variables which should be assigned before the loop and it would be pointless to do this stuff over and over again with the same variables (infinite loop welcome to).
My mind is completely empty right now, I need to think about it.



No you should declare another variable. Ask the user if they want to roll again, and store their input in that variable. Loop based on the value of that variable.

+ Show Spoiler +


while( repeat != 'n' )
{
result = ThrowDices(config);

PrintDiceThrowsResult(result);

printf("Want to play again? Enter y/n.");

scanf("%c", &repeat);
}



Did you find the dice program somewhere online? It's well written.



There seems to be some problem with this loop...

It compiles fine but here's how it works now:
+ Show Spoiler +


krs@chameleon:~/workspace/C/dice_generator> ./a.out
Enter the number of dice: 4
Enter dice type (sides) : 6
3 2 3 3 Sum: 11
Want to play again? Enter y/n.2 5 5 2 Sum: 14
Want to play again? Enter y/n.y
4 2 5 3 Sum: 14
Want to play again? Enter y/n.1 1 1 1 Sum: 4
Want to play again? Enter y/n.y
3 1 5 3 Sum: 12
Want to play again? Enter y/n.2 1 5 3 Sum: 11
Want to play again? Enter y/n.n
krs@chameleon:~/workspace/C/dice_generator>



I did it differently myself, looped the entire code up until main return, it allowed me to enter new dice and printed results fine, the problem was it auto-skipped the continue question (it posted it but automatically continued the loop, without waiting for input).

And to answer your question, I didn't find it anywhere, I wrote it myself with a bit of help from a friend (we were bored at the lake due to bad weather, didn't even have internet there). We started with a simple for loop and one structure and it kinda evolved as we got new ideas

Edit:

I gave it some more work, it compiles without errors but seems to completely skip over checking for continue and breaks the loop immediately...
Getchar works better than scanf, but still doesn't seem to do the job.

+ Show Spoiler +


#include <stdio.h>
#include <stdlib.h>
#include <time.h>

struct DiceConfiguration
{
int DiceNumber;
int DiceType;
};

struct DiceThrowsResult
{
int DiceNumber;
int Sum;
int ThrowsResults[];
};

struct DiceConfiguration* GetConfiguration(void);
struct DiceThrowsResult* ThrowDices(struct DiceConfiguration *config);
int ThrowDice(struct DiceConfiguration *config);
void PrintDiceThrowsResult(struct DiceThrowsResult *result);
char GetContinueDecision(void);
void ReleaseMemory(struct DiceConfiguration *config, struct DiceThrowsResult *result);

int main(void)
{
struct DiceConfiguration *config;
struct DiceThrowsResult *result;

int test = 1;
char repeat = 'y';

while(test = 1)
{
srand((unsigned int) time(0)); // random seed

config = GetConfiguration();

result = ThrowDices(config);

PrintDiceThrowsResult(result);

repeat = GetContinueDecision();

if(repeat != 'y')
{
break;
}

}

ReleaseMemory(config, result);

return 0;
}

struct DiceConfiguration* GetConfiguration(void)
{
struct DiceConfiguration *config;
config = malloc(sizeof(struct DiceConfiguration));

printf("Entering \"0\" (zero) will exit the program.\n");
printf("Enter the number of dice: ");
scanf("%d", &config->DiceNumber);
printf("Enter dice type (sides) : ");
scanf("%d", &config->DiceType);

return config;
}

struct DiceThrowsResult* ThrowDices(struct DiceConfiguration *config)
{
struct DiceThrowsResult *result;
result = malloc(sizeof(struct DiceThrowsResult) + config->DiceNumber * sizeof(int));
result->DiceNumber = config->DiceNumber;

for (int i = 0; i < config->DiceNumber; i++)
{
result->ThrowsResults[i] = ThrowDice(config);
result->Sum += result->ThrowsResults[i];
}

return result;
}

int ThrowDice(struct DiceConfiguration *config)
{
return rand() % config->DiceType + 1;
}

void PrintDiceThrowsResult(struct DiceThrowsResult *result)
{

for (int i = 0; i < result->DiceNumber; i++)
{
printf("%d ", result->ThrowsResults[i];
}

printf("Sum: %d\n", result->Sum);
}

char GetContinueDecision(void)
{
char ContinueDecision;

printf("Would you like to throw the dice again? (y/n): ");
ContinueDecision = getchar();

return ContinueDecision;

}

void ReleaseMemory(struct DiceConfiguration *config, struct DiceThrowsResult *result)
{
if (config != NULL)
{
free(config);
config = NULL;
}

if (result != NULL)
{
free(result);
result = NULL;
}
}


And the output

krs@chameleon:~/workspace/C/dice_generator> ./a.out
Entering "0" (zero) will exit the program.
Enter the number of dice: 4
Enter dice type (sides) : 6
6 5 1 5 Sum: 17
Would you like to throw the dice again? (y/n): krs@chameleon:~/workspace/C/dice_generator>



Edit2:

Working but unsatisfactory code:
+ Show Spoiler +


#include <stdio.h>
#include <stdlib.h>
#include <time.h>

struct DiceConfiguration
{
int DiceNumber;
int DiceType;
};

struct DiceThrowsResult
{
int DiceNumber;
int Sum;
int ThrowsResults[];
};

struct DiceConfiguration* GetConfiguration(void);
struct DiceThrowsResult* ThrowDices(struct DiceConfiguration *config);
int ThrowDice(struct DiceConfiguration *config);
void PrintDiceThrowsResult(struct DiceThrowsResult *result);
int GetContinueDecision(void);
void ReleaseMemory(struct DiceConfiguration *config, struct DiceThrowsResult *result);

int main(void)
{
struct DiceConfiguration *config;
struct DiceThrowsResult *result;

int test = 1;
int repeat = 1;

while(test = 1)
{
srand((unsigned int) time(0)); // random seed

config = GetConfiguration();

result = ThrowDices(config);

PrintDiceThrowsResult(result);

repeat = GetContinueDecision();

if(repeat != 1)
{
break;
}

}

ReleaseMemory(config, result);

return 0;
}

struct DiceConfiguration* GetConfiguration(void)
{
struct DiceConfiguration *config;
config = malloc(sizeof(struct DiceConfiguration));

printf("Entering \"0\" (zero) will exit the program.\n");
printf("Enter the number of dice: ");
scanf("%d", &config->DiceNumber);
printf("Enter dice type (sides) : ");
scanf("%d", &config->DiceType);

return config;
}

struct DiceThrowsResult* ThrowDices(struct DiceConfiguration *config)
{
struct DiceThrowsResult *result;
result = malloc(sizeof(struct DiceThrowsResult) + config->DiceNumber * sizeof(int));
result->DiceNumber = config->DiceNumber;

for (int i = 0; i < config->DiceNumber; i++)
{
result->ThrowsResults[i] = ThrowDice(config);
result->Sum += result->ThrowsResults[i];
}

return result;
}

int ThrowDice(struct DiceConfiguration *config)
{
return rand() % config->DiceType + 1;
}

void PrintDiceThrowsResult(struct DiceThrowsResult *result)
{

for (int i = 0; i < result->DiceNumber; i++)
{
printf("%d ", result->ThrowsResults[i];
}

printf("Sum: %d\n", result->Sum);
}

int GetContinueDecision(void)
{
int ContinueDecision;

printf("Would you like to throw the dice again? (1/0): ");
scanf("%d", &ContinueDecision);

return ContinueDecision;
}

void ReleaseMemory(struct DiceConfiguration *config, struct DiceThrowsResult *result)
{
if (config != NULL)
{
free(config);
config = NULL;
}

if (result != NULL)
{
free(result);
result = NULL;
}
}



You forget that after the y/n you press enter - which results in additional characters.
Those stay in the input buffer and the next read returns immedatly with the \n (or i think on windows first \r and next read \n).

There are several options to skip those:
1. Read a string and then only use the first character
2. Flush the input buffer (iirc doesn't work on all platforms)
3. Read the character, then read until you find a \n

In my opinion, the first option is the best, though you need to make sure that you don't introduce buffer overflows.
HueHang
Profile Joined August 2010
73 Posts
May 05 2011 15:31 GMT
#1025
I've got a little question to you guys:
Is there a kind of MONO Framework(Linux) for Mac OS-X ? I am quite familiar with C#.NET, but if there is no framework to support it on Mac OS-X, then I gotta switch to the Qt-Toolkit and I am not really skilled with that framework.
MasterOfChaos
Profile Blog Joined April 2007
Germany2896 Posts
Last Edited: 2011-05-05 15:51:17
May 05 2011 15:47 GMT
#1026
I'm pretty sure there is mono on os-x. The problem is which GUI framework to use. If you you want to write your program for mac only you can use bindings to the native APIs(MonoMac). But cross platform libraries like GTK#/WinForms look alien on macs.
I also heard about some QT bindings for .net. But no idea how good that works and if it's available for macs.

5secs of google:
http://www.mono-project.com/Mono:OSX
LiquipediaOne eye to kill. Two eyes to live.
Blenderhead
Profile Joined April 2010
United States29 Posts
May 05 2011 15:51 GMT
#1027
I program regularly in MATLAB, but have very little experience in other languages. Is MATLAB similar to any standard languages like C++?
MasterOfChaos
Profile Blog Joined April 2007
Germany2896 Posts
Last Edited: 2011-05-05 15:53:43
May 05 2011 15:52 GMT
#1028
The type system is a bit different, since it's core type is a vector and not a scalar. So writing your programs in a vector based way is usually advisable.
LiquipediaOne eye to kill. Two eyes to live.
Manit0u
Profile Blog Joined August 2004
Poland17722 Posts
Last Edited: 2011-05-05 16:18:26
May 05 2011 15:53 GMT
#1029
On May 06 2011 00:19 Morfildur wrote:
Show nested quote +
On May 05 2011 06:10 Manit0u wrote:
On May 05 2011 05:47 Pawsom wrote:
On May 05 2011 05:44 Manit0u wrote:
On May 05 2011 05:08 Pawsom wrote:
On May 05 2011 03:26 Manit0u wrote:
Could someone please help me out here? I'm a noob and I have a momentary lapse of reason right now as I can't for the life of me recall how to properly loop my program so it won't exit after one go (only when someone enters 0 in any case he's asked to enter input)...
I don't need a ready solution, if you could just push me along by suggesting what should I use I'll be fine (I'm trying to learn some programming for personal uses mostly, like this dice throw generator here).

It's ANSI C if you can't tell.

+ Show Spoiler [code] +


#include <stdio.h>
#include <stdlib.h>
#include <time.h>

struct DiceConfiguration
{
int DiceNumber;
int DiceType;
};

struct DiceThrowsResult
{
int DiceNumber;
int Sum;
int ThrowsResults[];
};

struct DiceConfiguration* GetConfiguration(void);
struct DiceThrowsResult* ThrowDices(struct DiceConfiguration *config);
int ThrowDice(struct DiceConfiguration *config);
void PrintDiceThrowsResult(struct DiceThrowsResult *result);

int main(void)
{
srand((unsigned int) time(0)); // random seed

struct DiceConfiguration *config;
config = GetConfiguration();

struct DiceThrowsResult *result;
result = ThrowDices(config);

PrintDiceThrowsResult(result);

free(config);
free(result);

return 0;
}

struct DiceConfiguration* GetConfiguration(void)
{
struct DiceConfiguration *config;
config = malloc(sizeof(struct DiceConfiguration));

printf("Enter the number of dice: ");
scanf("%d", &config->DiceNumber);
printf("Enter dice type (sides) : ");
scanf("%d", &config->DiceType);

return config;
}

struct DiceThrowsResult* ThrowDices(struct DiceConfiguration *config)
{
struct DiceThrowsResult *result;
result = malloc(sizeof(struct DiceThrowsResult) + config->DiceNumber * sizeof(int));
result->DiceNumber = config->DiceNumber;

for (int i = 0; i < config->DiceNumber; i++)
{
result->ThrowsResults[i] = ThrowDice(config);
result->Sum += result->ThrowsResults[i];
}

return result;
}

int ThrowDice(struct DiceConfiguration *config)
{
return rand() % config->DiceType + 1;
}

void PrintDiceThrowsResult(struct DiceThrowsResult *result)
{

for (int i = 0; i < result->DiceNumber; i++)
{
printf("%d ", result->ThrowsResults[i];
}

printf("Sum: %d\n", result->Sum);
}



So try making a loop inside main, around the function calls to ThrowDices() and PrintDiceThrowsResults(). Do you know the syntax for a while loop in C?

You will need to ask the user to if he wants to continue, and use this input as the condition in your loop. Take a try at this, and post back if you need help.

A basic loop could look like:

+ Show Spoiler +

while (continue != FALSE)
{
doStuff();

doMoreShit();

continue = getContinue();
}



You mean something like that?

+ Show Spoiler +


while (DiceNumber > 0 && DiceType > 0)
{

do stuff

}



Then the entire thing should become a while loop...
The problem I'm facing right now is the right place to put the loop, as this while checks for 2 variables which should be assigned before the loop and it would be pointless to do this stuff over and over again with the same variables (infinite loop welcome to).
My mind is completely empty right now, I need to think about it.



No you should declare another variable. Ask the user if they want to roll again, and store their input in that variable. Loop based on the value of that variable.

+ Show Spoiler +


while( repeat != 'n' )
{
result = ThrowDices(config);

PrintDiceThrowsResult(result);

printf("Want to play again? Enter y/n.");

scanf("%c", &repeat);
}



Did you find the dice program somewhere online? It's well written.



There seems to be some problem with this loop...

It compiles fine but here's how it works now:
+ Show Spoiler +


krs@chameleon:~/workspace/C/dice_generator> ./a.out
Enter the number of dice: 4
Enter dice type (sides) : 6
3 2 3 3 Sum: 11
Want to play again? Enter y/n.2 5 5 2 Sum: 14
Want to play again? Enter y/n.y
4 2 5 3 Sum: 14
Want to play again? Enter y/n.1 1 1 1 Sum: 4
Want to play again? Enter y/n.y
3 1 5 3 Sum: 12
Want to play again? Enter y/n.2 1 5 3 Sum: 11
Want to play again? Enter y/n.n
krs@chameleon:~/workspace/C/dice_generator>



I did it differently myself, looped the entire code up until main return, it allowed me to enter new dice and printed results fine, the problem was it auto-skipped the continue question (it posted it but automatically continued the loop, without waiting for input).

And to answer your question, I didn't find it anywhere, I wrote it myself with a bit of help from a friend (we were bored at the lake due to bad weather, didn't even have internet there). We started with a simple for loop and one structure and it kinda evolved as we got new ideas

Edit:

I gave it some more work, it compiles without errors but seems to completely skip over checking for continue and breaks the loop immediately...
Getchar works better than scanf, but still doesn't seem to do the job.

+ Show Spoiler +


#include <stdio.h>
#include <stdlib.h>
#include <time.h>

struct DiceConfiguration
{
int DiceNumber;
int DiceType;
};

struct DiceThrowsResult
{
int DiceNumber;
int Sum;
int ThrowsResults[];
};

struct DiceConfiguration* GetConfiguration(void);
struct DiceThrowsResult* ThrowDices(struct DiceConfiguration *config);
int ThrowDice(struct DiceConfiguration *config);
void PrintDiceThrowsResult(struct DiceThrowsResult *result);
char GetContinueDecision(void);
void ReleaseMemory(struct DiceConfiguration *config, struct DiceThrowsResult *result);

int main(void)
{
struct DiceConfiguration *config;
struct DiceThrowsResult *result;

int test = 1;
char repeat = 'y';

while(test = 1)
{
srand((unsigned int) time(0)); // random seed

config = GetConfiguration();

result = ThrowDices(config);

PrintDiceThrowsResult(result);

repeat = GetContinueDecision();

if(repeat != 'y')
{
break;
}

}

ReleaseMemory(config, result);

return 0;
}

struct DiceConfiguration* GetConfiguration(void)
{
struct DiceConfiguration *config;
config = malloc(sizeof(struct DiceConfiguration));

printf("Entering \"0\" (zero) will exit the program.\n");
printf("Enter the number of dice: ");
scanf("%d", &config->DiceNumber);
printf("Enter dice type (sides) : ");
scanf("%d", &config->DiceType);

return config;
}

struct DiceThrowsResult* ThrowDices(struct DiceConfiguration *config)
{
struct DiceThrowsResult *result;
result = malloc(sizeof(struct DiceThrowsResult) + config->DiceNumber * sizeof(int));
result->DiceNumber = config->DiceNumber;

for (int i = 0; i < config->DiceNumber; i++)
{
result->ThrowsResults[i] = ThrowDice(config);
result->Sum += result->ThrowsResults[i];
}

return result;
}

int ThrowDice(struct DiceConfiguration *config)
{
return rand() % config->DiceType + 1;
}

void PrintDiceThrowsResult(struct DiceThrowsResult *result)
{

for (int i = 0; i < result->DiceNumber; i++)
{
printf("%d ", result->ThrowsResults[i];
}

printf("Sum: %d\n", result->Sum);
}

char GetContinueDecision(void)
{
char ContinueDecision;

printf("Would you like to throw the dice again? (y/n): ");
ContinueDecision = getchar();

return ContinueDecision;

}

void ReleaseMemory(struct DiceConfiguration *config, struct DiceThrowsResult *result)
{
if (config != NULL)
{
free(config);
config = NULL;
}

if (result != NULL)
{
free(result);
result = NULL;
}
}


And the output

krs@chameleon:~/workspace/C/dice_generator> ./a.out
Entering "0" (zero) will exit the program.
Enter the number of dice: 4
Enter dice type (sides) : 6
6 5 1 5 Sum: 17
Would you like to throw the dice again? (y/n): krs@chameleon:~/workspace/C/dice_generator>



Edit2:

Working but unsatisfactory code:
+ Show Spoiler +


#include <stdio.h>
#include <stdlib.h>
#include <time.h>

struct DiceConfiguration
{
int DiceNumber;
int DiceType;
};

struct DiceThrowsResult
{
int DiceNumber;
int Sum;
int ThrowsResults[];
};

struct DiceConfiguration* GetConfiguration(void);
struct DiceThrowsResult* ThrowDices(struct DiceConfiguration *config);
int ThrowDice(struct DiceConfiguration *config);
void PrintDiceThrowsResult(struct DiceThrowsResult *result);
int GetContinueDecision(void);
void ReleaseMemory(struct DiceConfiguration *config, struct DiceThrowsResult *result);

int main(void)
{
struct DiceConfiguration *config;
struct DiceThrowsResult *result;

int test = 1;
int repeat = 1;

while(test = 1)
{
srand((unsigned int) time(0)); // random seed

config = GetConfiguration();

result = ThrowDices(config);

PrintDiceThrowsResult(result);

repeat = GetContinueDecision();

if(repeat != 1)
{
break;
}

}

ReleaseMemory(config, result);

return 0;
}

struct DiceConfiguration* GetConfiguration(void)
{
struct DiceConfiguration *config;
config = malloc(sizeof(struct DiceConfiguration));

printf("Entering \"0\" (zero) will exit the program.\n");
printf("Enter the number of dice: ");
scanf("%d", &config->DiceNumber);
printf("Enter dice type (sides) : ");
scanf("%d", &config->DiceType);

return config;
}

struct DiceThrowsResult* ThrowDices(struct DiceConfiguration *config)
{
struct DiceThrowsResult *result;
result = malloc(sizeof(struct DiceThrowsResult) + config->DiceNumber * sizeof(int));
result->DiceNumber = config->DiceNumber;

for (int i = 0; i < config->DiceNumber; i++)
{
result->ThrowsResults[i] = ThrowDice(config);
result->Sum += result->ThrowsResults[i];
}

return result;
}

int ThrowDice(struct DiceConfiguration *config)
{
return rand() % config->DiceType + 1;
}

void PrintDiceThrowsResult(struct DiceThrowsResult *result)
{

for (int i = 0; i < result->DiceNumber; i++)
{
printf("%d ", result->ThrowsResults[i];
}

printf("Sum: %d\n", result->Sum);
}

int GetContinueDecision(void)
{
int ContinueDecision;

printf("Would you like to throw the dice again? (1/0): ");
scanf("%d", &ContinueDecision);

return ContinueDecision;
}

void ReleaseMemory(struct DiceConfiguration *config, struct DiceThrowsResult *result)
{
if (config != NULL)
{
free(config);
config = NULL;
}

if (result != NULL)
{
free(result);
result = NULL;
}
}



You forget that after the y/n you press enter - which results in additional characters.
Those stay in the input buffer and the next read returns immedatly with the \n (or i think on windows first \r and next read \n).

There are several options to skip those:
1. Read a string and then only use the first character
2. Flush the input buffer (iirc doesn't work on all platforms)
3. Read the character, then read until you find a \n

In my opinion, the first option is the best, though you need to make sure that you don't introduce buffer overflows.


Bah, you posted it when I was updating my message (check it up). I got it to work, albeit in a different way.

Output:


krs@chameleon:~/workspace/C/dice_generator> ./a.out
Enter the number of dice to throw (0 to quit): 4
Enter dice type (sides) : 6
1 4 5 4 Sum: 14
Enter the number of dice to throw (0 to quit): 4
Enter dice type (sides) : 6
3 1 1 2 Sum: 7
Enter the number of dice to throw (0 to quit): 0
krs@chameleon:~/workspace/C/dice_generator>


Edit: The only problem I'm getting now is if I enter 0 as first number, then I get seg fault
Time is precious. Waste it wisely.
tofucake
Profile Blog Joined October 2009
Hyrule19202 Posts
May 06 2011 13:57 GMT
#1030
Seg Faults!

You haven't posted your revised code, so nobody can really help you...
Liquipediaasante sana squash banana
Daavee
Profile Joined March 2010
Germany11 Posts
Last Edited: 2011-05-06 14:39:07
May 06 2011 14:21 GMT
#1031
If you enter 0 as first number result->sum isn't initialised but printed. Could be your problem.

/edit: you don't initialise the sum at all. are you using a compiler that sets memory to zero with malloc? seems quite weird.

Entering "0" (zero) will exit the program.

it does not. it's easier to get rid of the GetContinueDecision-Function and check DiceNumber against 0.
Pawsom
Profile Blog Joined February 2009
United States928 Posts
May 06 2011 14:45 GMT
#1032
You don't need to seed your random number generator by calling srand() everytime you enter the loop. Just call it once before the loop to initialize rand.

Oh god it looks worse actually.. Everytime you enter the loop, you call getConfig() which calls malloc. However, you only free one allocation of this memory. In your small program you won't even notice, but its a blatant memory leak.
Pawsom
Profile Blog Joined February 2009
United States928 Posts
Last Edited: 2011-05-06 14:50:58
May 06 2011 14:50 GMT
#1033
On May 06 2011 23:21 Daavee wrote:
If you enter 0 as first number result->sum isn't initialised but printed. Could be your problem.

/edit: you don't initialise the sum at all. are you using a compiler that sets memory to zero with malloc? seems quite weird.

Show nested quote +
Entering "0" (zero) will exit the program.

it does not. it's easier to get rid of the GetContinueDecision-Function and check DiceNumber against 0.



No there's jsut no code anywhere to check fi the number of dice is zero, and if so exit.

It should look like
+ Show Spoiler +


getConfig();

if( config.numDice != 0 )
{
// roll them bones
}

else
{
// say goodbye
}


Edit; Nvm thats exactly what you said maybe I quoted the wrong post or something /shrug.
Cloud
Profile Blog Joined November 2004
Sexico5880 Posts
Last Edited: 2011-05-06 22:44:12
May 06 2011 22:42 GMT
#1034
Google's code jam is starting in like 20 mins if anyone wants to enter. It's a programming competition, problems are kinda like project euler's but timed.

You have 24 hours to solve the first set so I think it's not too late to sign up.

http://code.google.com/codejam/
BlueLaguna on West, msg for game.
Manit0u
Profile Blog Joined August 2004
Poland17722 Posts
Last Edited: 2011-05-07 06:24:12
May 07 2011 06:23 GMT
#1035
On May 06 2011 22:57 tofucake wrote:
Seg Faults!

You haven't posted your revised code, so nobody can really help you...


The last version of the code was in my previous post (I edited it in place of the old one to save space).
Here it is again, I'll be tackling it again today.

+ Show Spoiler +


#include <stdio.h>
#include <stdlib.h>
#include <time.h>

struct DiceConfiguration
{
int DiceNumber;
int DiceType;
};

struct DiceThrowsResult
{
int DiceNumber;
int Sum;
int ThrowsResults[];
};

struct DiceConfiguration* GetConfiguration(int FirstEntry);
struct DiceThrowsResult* ThrowDices(struct DiceConfiguration *config);
int ThrowDice(struct DiceConfiguration *config);
void PrintDiceThrowsResult(struct DiceThrowsResult *result);
void WelcomeMessage(void);
void ReleaseMemory(struct DiceConfiguration *config, struct DiceThrowsResult *result);

int main(void)
{
struct DiceConfiguration *config;
struct DiceThrowsResult *result;
int FirstEntry = 0;

srand((unsigned int) time(0)); // random seed

WelcomeMessage();

while(scanf("%d", &FirstEntry) == 1 && FirstEntry > 0)
{
config = GetConfiguration(FirstEntry);

result = ThrowDices(config);

PrintDiceThrowsResult(result);

ReleaseMemory(config, result);

WelcomeMessage();
}

return 0;
}

struct DiceConfiguration* GetConfiguration(int FirstEntry)
{
struct DiceConfiguration *config;
config = malloc(sizeof(struct DiceConfiguration));

config->DiceNumber = FirstEntry;
printf("Enter dice type (sides) : ");
scanf("%d", &config->DiceType);

return config;
}

struct DiceThrowsResult* ThrowDices(struct DiceConfiguration *config)
{
struct DiceThrowsResult *result;
result = malloc(sizeof(struct DiceThrowsResult) + config->DiceNumber * sizeof(int));
result->DiceNumber = config->DiceNumber;

for (int i = 0; i < config->DiceNumber; i++)
{
result->ThrowsResults[i] = ThrowDice(config);
result->Sum += result->ThrowsResults[i];
}

return result;
}

int ThrowDice(struct DiceConfiguration *config)
{
return rand() % config->DiceType + 1;
}

void PrintDiceThrowsResult(struct DiceThrowsResult *result)
{

for (int i = 0; i < result->DiceNumber; i++)
{
printf("%d ", result->ThrowsResults[i]);
}

printf("Sum: %d\n", result->Sum);
}

void WelcomeMessage(void )
{
printf("Enter the number of dice to throw (0 to quit): ");
}

void ReleaseMemory(struct DiceConfiguration *config, struct DiceThrowsResult *result)
{
if (config != NULL)
{
free(config);
config = NULL;
}

if (result != NULL)
{
free(result);
result = NULL;
}
}



No more seg faults (int FirstEntry was declared but without default value, that's what caused the segmentation fault).
Time is precious. Waste it wisely.
haduken
Profile Blog Joined April 2003
Australia8267 Posts
May 07 2011 07:02 GMT
#1036
Does anyone know how to use the entity framework designer to set entity type = date? (Not datetime).

Strange that they don't have this type out of box. I can edit the generated SQL script but it's a pain.
Rillanon.au
Manit0u
Profile Blog Joined August 2004
Poland17722 Posts
Last Edited: 2011-05-07 11:59:25
May 07 2011 11:58 GMT
#1037
On May 07 2011 16:02 haduken wrote:
Does anyone know how to use the entity framework designer to set entity type = date? (Not datetime).

Strange that they don't have this type out of box. I can edit the generated SQL script but it's a pain.


Not sure if this will help, but maybe it will:

1. Open the EDMX file up using an XML Editor

Now look in the StorageModels element for the column in question.

The 'type' of the Property in the SSDL section is the type the EntityFramework thinks the database column is. I suspect it will say DateTime2. You should be able to change it back to something like DateTime.

It seems that this solution could let you change DateTime to Date.

2.

public partial class Transactions
{
public Transactions()
{
//HACK: To prevent this error: {"SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM."}
this.LastModified = System.DateTime.Now;
}
}


That's for setting the default values, not sure if it could also be used to manipulate types.

Unless you want it to get just the date and not time. There should be an option to ignore time in datetime, no?
Time is precious. Waste it wisely.
haduken
Profile Blog Joined April 2003
Australia8267 Posts
Last Edited: 2011-05-08 04:12:10
May 07 2011 16:10 GMT
#1038
On May 07 2011 20:58 Manit0u wrote:
Show nested quote +
On May 07 2011 16:02 haduken wrote:
Does anyone know how to use the entity framework designer to set entity type = date? (Not datetime).

Strange that they don't have this type out of box. I can edit the generated SQL script but it's a pain.


Not sure if this will help, but maybe it will:

1. Open the EDMX file up using an XML Editor

Now look in the StorageModels element for the column in question.

The 'type' of the Property in the SSDL section is the type the EntityFramework thinks the database column is. I suspect it will say DateTime2. You should be able to change it back to something like DateTime.

It seems that this solution could let you change DateTime to Date.

2.

public partial class Transactions
{
public Transactions()
{
//HACK: To prevent this error: {"SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM."}
this.LastModified = System.DateTime.Now;
}
}


That's for setting the default values, not sure if it could also be used to manipulate types.

Unless you want it to get just the date and not time. There should be an option to ignore time in datetime, no?


Thanks! You've actually beat stackoverflow on this one. Your first suggestion don't work as Visual Studio won't qualify date as it is not a primitive type which means I can't build...

My problem is to do with range of data types in SQL. I prefer to use date time anyway and only chose to have date because I have to migrate some really fucked up access data.

EF designer will only generate script that set datetime which is problematic for me because the access data I have is set to just date which has a minimal value that is out of range for datetime.

There are work arounds of course but it's a pain when I have 30 different tables ...

Update: Find the solution. It is done via structural annotation in the SSDL and EDMX file. I won't bore every one with the details but basically it is done by scanning the edmx file and change the type to date, you put the extra scanning and code generation code in SSDL and call from that.
Rillanon.au
nakam
Profile Joined April 2010
Sweden245 Posts
Last Edited: 2011-05-08 11:53:29
May 08 2011 11:52 GMT
#1039
This following MySQL query works fine in phpMyAdmin:
+ Show Spoiler +
SET @rownum = 0, @rank = 0, @prev_val = NULL;
SELECT @rownum := @rownum + 1 AS row
, @rank := IF(@prev_val!=rating,@rownum,@rank) AS rank
, @prev_val := rating AS rating
, fid
FROM
(
SELECT AVG(rating) AS rating, fid
FROM _relation t
GROUP BY fid
ORDER BY 1 DESC
) t
ORDER BY rating DESC

How does one execute this from php? I'm only familiar with mysql_query and that doesn't seem to support multiple queries like that.
TL Local Timezone Script - http://www.teamliquid.net/forum/viewmessage.php?topic_id=277156
tofucake
Profile Blog Joined October 2009
Hyrule19202 Posts
May 08 2011 13:17 GMT
#1040
@nakam: What you're doing is overly complicated and is easily done in PHP. However, you could run it as a stored procedure. Below is the PHP equivalent.
$result = array();
$i = 0;
$prev_val = false;

$resource = mysql_query("SELECT rating, fid FROM _relation GROUP BY fid ORDER BY rating DESC");
while($row = mysql_fetch_assoc($resource))
{
$tmp = array(
'row' => ++$i,
'rank' => $row['rank'] != $prev_val ? $row['rank'] : $i,
'rating' => $row['rank'],
'fid' => $row['fid']
);
$result[] = $tmp;
$prev_val = $row['rank'];
}


@Manit0u: Your loop is bad.
while(scanf("%d", &FirstEntry) == 1)
{
if(FirstEntry > 0)
{
config = GetConfiguration(FirstEntry);
result = ThrowDices(config);
PrintDiceThrowsResult(result);
ReleaseMemory(config, result);
WelcomeMessage();
} else {
break;
}
}

Keep the scanf and check of the value separate. I'm also tempted to toss out a picture I posted elsewhere.
+ Show Spoiler +
[image loading]
Liquipediaasante sana squash banana
Prev 1 50 51 52 53 54 1032 Next
Please log in or register to reply.
Live Events Refresh
Kung Fu Cup
11:00
#5
RotterdaM341
TKL 130
IndyStarCraft 74
Rex69
SteadfastSC69
Liquipedia
Replay Cast
09:00
KungFu Cup 2026 Week 4
CranKy Ducklings137
LiquipediaDiscussion
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
RotterdaM 341
Lowko154
TKL 130
IndyStarCraft 74
SteadfastSC 69
Rex 69
ProTech23
StarCraft: Brood War
Britney 24579
Horang2 2090
Bisu 1174
Jaedong 908
Hyuk 728
firebathero 685
Soma 368
Zeus 366
Mini 276
actioN 251
[ Show more ]
Stork 203
Pusan 196
Snow 165
Larva 161
Last 149
ZerO 137
Light 135
PianO 124
hero 90
Soulkey 84
Rush 82
Hyun 70
sorry 49
Hm[arnc] 45
[sc1f]eonzerg 42
Sharp 35
NaDa 30
Shinee 26
Sacsri 24
Bale 22
soO 21
Free 19
Barracks 19
Terrorterran 13
HiyA 12
Icarus 11
Movie 8
ajuk12(nOOB) 7
Noble 4
ggaemo 1
Dota 2
XaKoH 700
canceldota181
League of Legends
Reynor47
Counter-Strike
x6flipin425
allub177
markeloff45
Other Games
singsing1611
B2W.Neo994
Pyrionflax216
DeMusliM210
Mew2King58
QueenE15
ZerO(Twitch)9
Organizations
Other Games
BasetradeTV1417
Counter-Strike
PGL179
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 13 non-featured ]
StarCraft 2
• CranKy Ducklings SOOP23
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
League of Legends
• Jankos1172
• TFBlade1147
Upcoming Events
Replay Cast
12h 22m
The PondCast
22h 22m
WardiTV Map Contest Tou…
23h 22m
CranKy Ducklings
1d 12h
Escore
1d 22h
WardiTV Map Contest Tou…
1d 23h
OSC
2 days
Korean StarCraft League
2 days
CranKy Ducklings
2 days
WardiTV Map Contest Tou…
2 days
[ Show More ]
IPSL
3 days
WolFix vs nOmaD
dxtr13 vs Razz
BSL
3 days
Sparkling Tuna Cup
3 days
WardiTV Map Contest Tou…
3 days
Ladder Legends
4 days
BSL
4 days
IPSL
4 days
JDConan vs TBD
Aegong vs rasowy
Replay Cast
4 days
Replay Cast
4 days
Wardi Open
4 days
Afreeca Starleague
4 days
Bisu vs Ample
Jaedong vs Flash
Monday Night Weeklies
5 days
RSL Revival
5 days
Afreeca Starleague
5 days
Barracks vs Leta
Royal vs Light
WardiTV Map Contest Tou…
5 days
RSL Revival
6 days
Liquipedia Results

Completed

Proleague 2026-04-13
RSL Revival: Season 4
NationLESS Cup

Ongoing

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

Upcoming

Escore Tournament S2: W3
Acropolis #4
BSL 22 Non-Korean Championship
CSLAN 4
Kung Fu Cup 2026 Grand Finals
HSC XXIX
uThermal 2v2 2026 Main Event
RSL Revival: Season 5
2026 GSL S1
WardiTV TLMC #16
IEM Cologne Major 2026
Stake Ranked Episode 2
CS Asia Championships 2026
Asian Champions League 2026
IEM Atlanta 2026
PGL Astana 2026
BLAST Rivals Spring 2026
CCT Season 3 Global Finals
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.