• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EST 03:23
CET 09:23
KST 17:23
  • 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
Behind the Blue - Team Liquid History Book15Clem wins HomeStory Cup 289HomeStory Cup 28 - Info & Preview13Rongyi Cup S3 - Preview & Info8herO wins SC2 All-Star Invitational14
Community News
ACS replaced by "ASL Season Open" - Starts 21/0218LiuLi Cup: 2025 Grand Finals (Feb 10-16)23Weekly Cups (Feb 2-8): Classic, Solar, MaxPax win2Nexon's StarCraft game could be FPS, led by UMS maker10PIG STY FESTIVAL 7.0! (19 Feb - 1 Mar)13
StarCraft 2
General
How do you think the 5.0.15 balance patch (Oct 2025) for StarCraft II has affected the game? Nexon's StarCraft game could be FPS, led by UMS maker Terran Scanner Sweep Behind the Blue - Team Liquid History Book Weekly Cups (Jan 12-18): herO, MaxPax, Solar win
Tourneys
RSL Season 4 announced for March-April LiuLi Cup: 2025 Grand Finals (Feb 10-16) PIG STY FESTIVAL 7.0! (19 Feb - 1 Mar) RSL Revival: Season 4 Korea Qualifier (Feb 14) Sparkling Tuna Cup - Weekly Open Tournament
Strategy
Custom Maps
Map Editor closed ? [A] Starcraft Sound Mod
External Content
The PondCast: SC2 News & Results Mutation # 512 Overclocked Mutation # 511 Temple of Rebirth Mutation # 510 Safety Violation
Brood War
General
[ASL21] Potential Map Candidates Gypsy to Korea Which units you wish saw more use in the game? ACS replaced by "ASL Season Open" - Starts 21/02 Liquipedia.net NEEDS editors for Brood War
Tourneys
Escore Tournament StarCraft Season 1 [Megathread] Daily Proleagues Small VOD Thread 2.0 KCM Race Survival 2026 Season 1
Strategy
Fighting Spirit mining rates Zealot bombing is no longer popular? Simple Questions, Simple Answers Current Meta
Other Games
General Games
Path of Exile Diablo 2 thread Nintendo Switch Thread Battle Aces/David Kim RTS Megathread ZeroSpace Megathread
Dota 2
Official 'what is Dota anymore' discussion
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Deck construction bug Heroes of StarCraft mini-set
TL Mafia
Mafia Game Mode Feedback/Ideas Vanilla Mini Mafia TL Mafia Community Thread
Community
General
US Politics Mega-thread Ask and answer stupid questions here! European Politico-economics QA Mega-thread The Games Industry And ATVI Russo-Ukrainian War Thread
Fan Clubs
The IdrA Fan Club The herO Fan Club!
Media & Entertainment
[Manga] One Piece Anime Discussion Thread
Sports
2024 - 2026 Football Thread
World Cup 2022
Tech Support
TL Community
The Automated Ban List
Blogs
ADHD And Gaming Addiction…
TrAiDoS
My 2025 Magic: The Gathering…
DARKING
Life Update and thoughts.
FuDDx
How do archons sleep?
8882
StarCraft improvement
iopq
Customize Sidebar...

Website Feedback

Closed Threads



Active: 2234 users

The Big Programming Thread - Page 19

Forum Index > General Forum
Post a Reply
Prev 1 17 18 19 20 21 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.
catamorphist
Profile Joined May 2010
United States297 Posts
August 02 2010 22:56 GMT
#361
Never used it, but the right way is almost certainly to navigate through the DOM of the displayed page using this API.
http://us.battle.net/sc2/en/profile/281144/1/catamorphist/
Adeny
Profile Blog Joined January 2009
Norway1233 Posts
August 02 2010 23:28 GMT
#362
I figured it out. For some reason or another, the webBrowser control can't be drag n' dropped into the form, it has to be made from code. However when I tried that DrawToBitmap worked just fine, even though intellisense doesn't know about it. Chances are it's bad practice.
57 Corvette
Profile Blog Joined July 2010
Canada5941 Posts
August 03 2010 00:35 GMT
#363
Has anyone ever used Turing?
http://en.wikipedia.org/wiki/Turing_(programming_language)
I've made a few interesting things with this, despite it being a beginner language. Managed to make a sort of "Space invaders" game using an interfacing device i made from scratch. Can't do alot of amazing stuff with it, but meh.
Survival is winning, everything else is bullshit.
cowsrule
Profile Joined February 2010
United States80 Posts
August 03 2010 21:19 GMT
#364
On July 31 2010 14:51 catamorphist wrote:
Show nested quote +
On July 31 2010 14:39 AcrossFiveJulys wrote:
oh. my. fucking. god.

This has got to be the dumbest bug I've written. Can you spot it? Rofl.


double BIRLDist::getMaxReward(MDPModel* mdp){

double max = mdp->getRewardProb(0,0,2);
for (int s=1; s<mdp->m_states; s++){

if (mdp->getRewardProb(s,0,2 > max))
max = mdp->getRewardProb(s,0,2);

}
return fabs(max);
}


Wow, it's really gay that you don't get a compiler warning from that. Chalk another one up in the "C++ fucks you again" book.


You should compile with "Treat warnings as errors" and set the highest warning level. This should give you a warning something along the lines of "Performance warning: Converting bool to int". By default you won't get a warning about this because it is a valid expression.
catamorphist
Profile Joined May 2010
United States297 Posts
August 03 2010 21:26 GMT
#365
On August 04 2010 06:19 cowsrule wrote:
Show nested quote +
On July 31 2010 14:51 catamorphist wrote:
On July 31 2010 14:39 AcrossFiveJulys wrote:
oh. my. fucking. god.

This has got to be the dumbest bug I've written. Can you spot it? Rofl.


double BIRLDist::getMaxReward(MDPModel* mdp){

double max = mdp->getRewardProb(0,0,2);
for (int s=1; s<mdp->m_states; s++){

if (mdp->getRewardProb(s,0,2 > max))
max = mdp->getRewardProb(s,0,2);

}
return fabs(max);
}


Wow, it's really gay that you don't get a compiler warning from that. Chalk another one up in the "C++ fucks you again" book.


You should compile with "Treat warnings as errors" and set the highest warning level. This should give you a warning something along the lines of "Performance warning: Converting bool to int". By default you won't get a warning about this because it is a valid expression.


Joke's on the OP then -- gotta -Wall.
http://us.battle.net/sc2/en/profile/281144/1/catamorphist/
NinjA246
Profile Joined August 2010
United States4 Posts
August 06 2010 14:32 GMT
#366
On August 03 2010 09:35 57 Corvette wrote:
Has anyone ever used Turing?
http://en.wikipedia.org/wiki/Turing_(programming_language)
I've made a few interesting things with this, despite it being a beginner language. Managed to make a sort of "Space invaders" game using an interfacing device i made from scratch. Can't do alot of amazing stuff with it, but meh.


You sure you can't do a lot of amazing stuff with it?
Zerg is not UP
tofucake
Profile Blog Joined October 2009
Hyrule19192 Posts
August 06 2010 15:36 GMT
#367
On August 04 2010 06:26 catamorphist wrote:
Show nested quote +
On August 04 2010 06:19 cowsrule wrote:
On July 31 2010 14:51 catamorphist wrote:
On July 31 2010 14:39 AcrossFiveJulys wrote:
oh. my. fucking. god.

This has got to be the dumbest bug I've written. Can you spot it? Rofl.


double BIRLDist::getMaxReward(MDPModel* mdp){

double max = mdp->getRewardProb(0,0,2);
for (int s=1; sm_states; s++){

if (mdp->getRewardProb(s,0,2 > max))
max = mdp->getRewardProb(s,0,2);

}
return fabs(max);
}


Wow, it's really gay that you don't get a compiler warning from that. Chalk another one up in the "C++ fucks you again" book.


You should compile with "Treat warnings as errors" and set the highest warning level. This should give you a warning something along the lines of "Performance warning: Converting bool to int". By default you won't get a warning about this because it is a valid expression.


Joke's on the OP then -- gotta -Wall.

How is it a joke on me?
Liquipediaasante sana squash banana
catamorphist
Profile Joined May 2010
United States297 Posts
August 06 2010 15:37 GMT
#368
On August 07 2010 00:36 tofucake wrote:
Show nested quote +
On August 04 2010 06:26 catamorphist wrote:
On August 04 2010 06:19 cowsrule wrote:
On July 31 2010 14:51 catamorphist wrote:
On July 31 2010 14:39 AcrossFiveJulys wrote:
oh. my. fucking. god.

This has got to be the dumbest bug I've written. Can you spot it? Rofl.


double BIRLDist::getMaxReward(MDPModel* mdp){

double max = mdp->getRewardProb(0,0,2);
for (int s=1; s<mdp->m_states; s++){

if (mdp->getRewardProb(s,0,2 > max))
max = mdp->getRewardProb(s,0,2);

}
return fabs(max);
}


Wow, it's really gay that you don't get a compiler warning from that. Chalk another one up in the "C++ fucks you again" book.


You should compile with "Treat warnings as errors" and set the highest warning level. This should give you a warning something along the lines of "Performance warning: Converting bool to int". By default you won't get a warning about this because it is a valid expression.


Joke's on the OP then -- gotta -Wall.

How is it a joke on me?


Sorry, I meant the guy with the C++ bug -- I shouldn't have said "OP."
http://us.battle.net/sc2/en/profile/281144/1/catamorphist/
tec27
Profile Blog Joined June 2004
United States3702 Posts
August 09 2010 04:22 GMT
#369
I just finished rewriting a DLL that can inject a specified DLL into a specified process (useful for having if you want to inject from a .NET application or something). Thought some of you might be interested in seeing the code for it:

http://pastebin.com/YNgbyK0K
Can you jam with the console cowboys in cyberspace?
Loser777
Profile Blog Joined January 2008
1931 Posts
Last Edited: 2010-08-10 23:47:16
August 10 2010 23:46 GMT
#370
C++ newbie here...I'm having trouble deleting arrays of pointers (SO SAD I DON'T HAVE JAVA'S GARBAGE COLLECTION BAWWWWW

here is the problem code:
+ Show Spoiler +
int main()
{

BankAccount* bankAccounts[10] = {new BankAccount()};


bool run = true;
int inputAccountNumber;

string curNum;
string curName;
string curBal;


fstream input("C:\\bankAccounts.txt", ios::in);
for(int i = 0; !input.eof(); i++)
{
getline(input, curNum);
getline(input, curName);
getline(input, curBal);

int num = atoi(curNum.c_str());
double bal = atof(curBal.c_str());

bankAccounts[i] = new BankAccount(num, curName, bal, "GA");
}
input.close();

[...]
for(int i = 0; i < 10; i++)
{
delete bankAccounts[i];
}
delete [] bankAccounts;



Basically, anywhere I execute [delete [] bankAccounts] I get _BLOCK_TYPE_IS_VALID -though I don't think I'm deleting anything twice... and If I remove the delete [] bankAccounts I get stack around the variable bankAccounts was corrupted...

I'm sure this is an easy problem to solve, but in Java I never had to deal with this.
6581
Yukidasu
Profile Blog Joined September 2009
Australia125 Posts
August 10 2010 23:54 GMT
#371
+ Show Spoiler +
BankAccount* bankAccounts[10] = {new BankAccount()};


This leaks a BankAccount, you don't need it. Your main problem here is that your array is on the stack, meaning that it is created and destroyed with your function like normal variables. That's what the syntax Class* variable[number]; means.

Basically, get rid of the = and the stuff after it on that line, and remove the last delete[] statement because you don't need it. Or replace the first line with:

+ Show Spoiler +
BankAccount** bankAccounts = new BankAccount*[10];
Lost in a groundless dream. You can't fly if there's nowhere to fall.
Loser777
Profile Blog Joined January 2008
1931 Posts
Last Edited: 2010-08-11 00:21:32
August 11 2010 00:17 GMT
#372
I tried to make another project with your first idea and everything worked, but in my original code, when I changed the corresponding statements to

BankAccount* bankAccounts[10];

for(int i = 0; i < 10; i++)
{
delete bankAccounts[i];
bankAccounts[i] = NULL;
}

I get "stack around the variable bankAccounts was corrupted"...

EDIT: when I moved the array outside of main (as a global variable), the problem was fixed... any reasons why?

6581
Badjas
Profile Blog Joined October 2008
Netherlands2038 Posts
August 11 2010 00:22 GMT
#373
You create a random number of BankAccounts, but you try to delete 10 of them. Which might be a mistmatch. You should test if the object has been created or not.

C++ language specs do not mandate initializing variables, so you can't test on NULL if you don't initialize them to be NULL first, so add an extra loop for that right after your declaration of bankAccounts.
I <3 the internet, I <3 you
Adeny
Profile Blog Joined January 2009
Norway1233 Posts
August 11 2010 00:35 GMT
#374
By the way, this is very unsafe and needs validation:
for(int i = 0; !input.eof(); i++)

because every iteration it writes to an array of a finite size, so if the file grows, it'll overflow. You probably know though, just pointing it out. What would probably be better is if you manually keep track of how many instances are created, pseudo code inc:

Disclaimer: grain of salt, not meant to be implemented directly etc.

main
{
uint totalBankAccounts = 0
while (!input.eof())
{
initialize bankAccount
add bankAccount's pointer bankAccounts[]
totalBankAccounts++
}

while (totalBankAccount > 0)
{
delete bankAccounts[i]
}

delete [] bankAccounts
}

Oh and I guess bankAccounts[] needs to be self-expanding, or validate if it has reached its upper bound before you initialize a new account.
mmp
Profile Blog Joined April 2009
United States2130 Posts
Last Edited: 2010-08-11 00:55:07
August 11 2010 00:54 GMT
#375
tofucake, please update the OP (maybe clean it up with spoiler tags to categorize)?

Web Programming
+ Show Spoiler +

HTML5: http://www.whatwg.org/specs/web-apps/current-work/multipage/index.html
HTML5 Canvas Element: http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html
HTML5 Video Element: http://www.w3.org/TR/html5/video.html
DOM: http://www.w3.org/DOM/ (what's going on inside the browser, if you dare to peek)

JavaScript:
Douglas Crockford's "The Good Parts" Talk:

http://www.crockford.com/javascript/
http://www.jslint.com/
http://www.json.org/

http://jquery.org (look into QUnit test suite and JQueryUI also, very handy stuff)
I (λ (foo) (and (<3 foo) ( T_T foo) (RAGE foo) )) Starcraft
dvide
Profile Joined March 2010
United Kingdom287 Posts
Last Edited: 2010-08-11 04:05:06
August 11 2010 00:54 GMT
#376
There are several problems here. Your use of fstream::eof() is flawed. See here for why:
http://stackoverflow.com/questions/1039667/why-does-stdfstream-set-the-eof-bit-the-way-it-does
http://stackoverflow.com/questions/730910/ifstream-object-eof-not-working

Secondly you should probably use: std::vector<BankAccount*> bankAccounts;

This will save you a lot of trouble. It uses a dynamic array internally, meaning you can insert any number of elements into the vector (using the push_back member function) and it will resize itself automatically at runtime to fit. In your case, if there is not exactly 10 bank accounts stored inside your file then there will be a problem here. For example, if there are 11 bank accounts in the file then your code will insert the last one into the 11th element of the array, which is undefined behaviour.

If there are less than 10 bank accounts stored inside your file, during clean-up you will be deleting a bank account that was never created. You will be calling delete on an uninitialised pointer, which again is undefined behaviour. You could initialise all bankAccount elements to NULL before you read the file, in which case your code would be fine so long as there are always <= 10 bank accounts in your file. Calling the delete operator on a NULL pointer is safe.

But again a normal C++ programmer wouldn't do it this way. Infact, a normal C++ wouldn't even use std::vector if they were able. They would rather use something like Boost's ptr_vector for this task, which is a class that owns the pointers internally and handles clean-up for you in its destructor (a popular C++ idiom called RAII, if you're interested). It also provides a nicer interface to your elements than an std::vector of pointers. This is probably not something you should focus on though until you are comfortable with what is actually going on. But just know that it's not always this difficult in C++ once you start using the proper tools for the job at hand


EDIT: How a C++ programmer would write this: http://codepad.org/Qs7nNq3R

Also, if you don't want to use stringstream I would recommend sscanf instead of atoi. At least that way you can check for formatting errors properly. atoi simply returns 0 on error, so if 0 is a valid value you won't know if it's a true error or not. However, when you gain more knowledge, you should be aware of the security problems with scanf (namely buffer overflows).

Hope this helps
tec27
Profile Blog Joined June 2004
United States3702 Posts
August 11 2010 06:20 GMT
#377
I just put up the source to APMAlert2 ( http://www.teamliquid.net/forum/viewmessage.php?topic_id=142171 ) on github if anyone's interested: http://github.com/tec27/APMAlert2

Its pretty messy, but if you're interested in how Direct3D hooking works when you don't control the process starting, its a pretty good reference (I think ). And hopefully soon it will be less messy.
Can you jam with the console cowboys in cyberspace?
alexpnd
Profile Blog Joined March 2009
Canada1857 Posts
August 11 2010 13:10 GMT
#378
tec27 thats way over my head but I'm going to take a look at it. I'm always interested in injection! I put up my bookmarklet stuff on my blog so check it out for any curious web dev's. It's simple stuff but still fun!

http://www.teamliquid.net/blogs/viewblog.php?topic_id=143169

It's essentially a lean image browser for threads and random sites (4 chan etc.)
www.brainyweb.ca //web stuff!
Badjas
Profile Blog Joined October 2008
Netherlands2038 Posts
August 11 2010 15:15 GMT
#379
tec27 that's awesome Thanks for sharing. Once upon a time I was terribly annoyed that I couldn't mess with other application's display like that.. now if only remember what I wanted to use that for.. but still, nice to know the resource out there to do that
I <3 the internet, I <3 you
stafu
Profile Blog Joined January 2009
Australia1196 Posts
August 11 2010 15:30 GMT
#380
Hey guys, maybe not the absolute best place to ask but I thought I'd give it a shot.

I'm taking an AI unit this semester and we get to do a self-directed project, so naturally my first thought was using BWAPI to make a BroodWar bot. We're only in second week but I'm just trying to scope out how long this would take me and if it's going to be feasible. I've got another game-based/OpenGL programming unit this semester as well which is definitely going to take up a lot of time so I'm a little wary. I'm pretty comfortable with C++ but only just learning the basics of AI theory now. So does anyone know given a fairly limited scope, could I complete a decent AI within 11-12 weeks?
Prev 1 17 18 19 20 21 1032 Next
Please log in or register to reply.
Live Events Refresh
RSL Revival
08:00
S4 Korea Server Qualifier
CranKy Ducklings78
Gemini_1927
LiquipediaDiscussion
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
SortOf 158
ProTech48
Rex 34
StarCraft: Brood War
Hyuk 1680
Leta 88
Aegong 65
Free 39
Yoon 34
soO 19
910 18
IntoTheRainbow 15
Hm[arnc] 10
ivOry 8
[ Show more ]
Shine 8
League of Legends
JimRising 626
Super Smash Bros
Mew2King131
Other Games
gofns24656
summit1g11097
tarik_tv9806
C9.Mang0404
Organizations
Counter-Strike
PGL3378
Other Games
gamesdonequick586
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 12 non-featured ]
StarCraft 2
• Adnapsc2 10
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
League of Legends
• Jankos1024
Upcoming Events
LiuLi Cup
2h 37m
Cure vs Reynor
Clem vs Maru
Rogue vs TriGGeR
ByuN vs Serral
uThermal 2v2 Circuit
3h 37m
PSISTORM Gaming Misc
8h 32m
RSL Revival
9h 37m
AI Arena Tournament
11h 37m
Replay Cast
15h 37m
Sparkling Tuna Cup
1d 1h
LiuLi Cup
1d 2h
Ladder Legends
1d 9h
Replay Cast
1d 15h
[ Show More ]
Replay Cast
2 days
Wardi Open
2 days
Monday Night Weeklies
2 days
OSC
2 days
WardiTV Winter Champion…
3 days
Replay Cast
4 days
WardiTV Winter Champion…
4 days
Replay Cast
4 days
PiG Sty Festival
5 days
The PondCast
5 days
KCM Race Survival
5 days
WardiTV Winter Champion…
5 days
Replay Cast
5 days
PiG Sty Festival
6 days
Epic.LAN
6 days
Replay Cast
6 days
Liquipedia Results

Completed

Escore Tournament S1: W8
Rongyi Cup S3
Underdog Cup #3

Ongoing

KCM Race Survival 2026 Season 1
LiuLi Cup: 2025 Grand Finals
Nations Cup 2026
PGL Cluj-Napoca 2026
IEM Kraków 2026
BLAST Bounty Winter 2026
BLAST Bounty Winter Qual
eXTREMESLAND 2025
SL Budapest Major 2025

Upcoming

Escore Tournament S1: King of Kings
[S:21] ASL SEASON OPEN 1st Round
[S:21] ASL SEASON OPEN 1st Round Qualifier
[S:21] ASL SEASON OPEN 2nd Round
[S:21] ASL SEASON OPEN 2nd Round Qualifier
Acropolis #4
IPSL Spring 2026
HSC XXIX
uThermal 2v2 2026 Main Event
Bellum Gens Elite Stara Zagora 2026
RSL Revival: Season 4
WardiTV Winter 2026
BLAST Rivals Spring 2026
CCT Season 3 Global Finals
FISSURE Playground #3
IEM Rio 2026
PGL Bucharest 2026
Stake Ranked Episode 1
BLAST Open Spring 2026
ESL Pro League Season 23
ESL Pro League Season 23
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.