• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EST 04:36
CET 10:36
KST 18:36
  • 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
TL.net Map Contest #21: Winners11Intel X Team Liquid Seoul event: Showmatches and Meet the Pros10[ASL20] Finals Preview: Arrival13TL.net Map Contest #21: Voting12[ASL20] Ro4 Preview: Descent11
Community News
[TLMC] Fall/Winter 2025 Ladder Map Rotation4Weekly Cups (Nov 3-9): Clem Conquers in Canada4SC: Evo Complete - Ranked Ladder OPEN ALPHA8StarCraft, SC2, HotS, WC3, Returning to Blizzcon!45$5,000+ WardiTV 2025 Championship7
StarCraft 2
General
[TLMC] Fall/Winter 2025 Ladder Map Rotation Mech is the composition that needs teleportation t Weekly Cups (Nov 3-9): Clem Conquers in Canada Craziest Micro Moments Of All Time? SC: Evo Complete - Ranked Ladder OPEN ALPHA
Tourneys
Constellation Cup - Main Event - Stellar Fest Tenacious Turtle Tussle Sparkling Tuna Cup - Weekly Open Tournament $5,000+ WardiTV 2025 Championship Merivale 8 Open - LAN - Stellar Fest
Strategy
Custom Maps
Map Editor closed ?
External Content
Mutation # 499 Chilling Adaptation Mutation # 498 Wheel of Misfortune|Cradle of Death Mutation # 497 Battle Haredened Mutation # 496 Endless Infection
Brood War
General
Rapidtags: The Ultimate Tool for Hashtag and Keywo Terran 1:35 12 Gas Optimization FlaSh on: Biggest Problem With SnOw's Playstyle BW General Discussion BGH Auto Balance -> http://bghmmr.eu/
Tourneys
[BSL21] RO32 Group D - Sunday 21:00 CET [BSL21] RO32 Group C - Saturday 21:00 CET [ASL20] Grand Finals [Megathread] Daily Proleagues
Strategy
Current Meta PvZ map balance How to stay on top of macro? Soma's 9 hatch build from ASL Game 2
Other Games
General Games
Nintendo Switch Thread Stormgate/Frost Giant Megathread Should offensive tower rushing be viable in RTS games? Path of Exile Dawn of War IV
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
TL Mafia Community Thread SPIRED by.ASL Mafia {211640}
Community
General
US Politics Mega-thread Russo-Ukrainian War Thread Things Aren’t Peaceful in Palestine Canadian Politics Mega-thread The Games Industry And ATVI
Fan Clubs
White-Ra Fan Club The herO Fan Club!
Media & Entertainment
[Manga] One Piece Anime Discussion Thread Movie Discussion! Korean Music Discussion Series you have seen recently...
Sports
2024 - 2026 Football Thread Formula 1 Discussion NBA General Discussion MLB/Baseball 2023 TeamLiquid Health and Fitness Initiative For 2023
World Cup 2022
Tech Support
SC2 Client Relocalization [Change SC2 Language] Linksys AE2500 USB WIFI keeps disconnecting Computer Build, Upgrade & Buying Resource Thread
TL Community
The Automated Ban List
Blogs
Dyadica Gospel – a Pulp No…
Hildegard
Coffee x Performance in Espo…
TrAiDoS
Saturation point
Uldridge
DnB/metal remix FFO Mick Go…
ImbaTosS
Reality "theory" prov…
perfectspheres
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1220 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
Hyrule19151 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
Next event in 1h 54m
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
SortOf 286
StarCraft: Brood War
Britney 49000
Rain 2987
Hyuk 2893
Soma 360
Backho 327
Rush 213
Pusan 117
JulyZerg 53
sSak 31
zelot 14
[ Show more ]
NaDa 12
Noble 11
ZerO 10
Hm[arnc] 8
Terrorterran 7
Dota 2
XaKoH 419
XcaliburYe139
Counter-Strike
fl0m1798
olofmeister680
shoxiejesuss411
oskar63
Super Smash Bros
Mew2King237
Other Games
ceh9502
Happy244
Pyrionflax116
ZerO(Twitch)4
Organizations
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 14 non-featured ]
StarCraft 2
• Berry_CruncH257
• LUISG 21
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
League of Legends
• Rush1347
• Stunt515
Upcoming Events
OSC
1h 54m
Kung Fu Cup
2h 24m
Classic vs Solar
herO vs Cure
Reynor vs GuMiho
ByuN vs ShoWTimE
Tenacious Turtle Tussle
13h 24m
The PondCast
1d
RSL Revival
1d
Solar vs Zoun
MaxPax vs Bunny
Kung Fu Cup
1d 2h
WardiTV Korean Royale
1d 2h
PiGosaur Monday
1d 15h
RSL Revival
2 days
Classic vs Creator
Cure vs TriGGeR
Kung Fu Cup
2 days
[ Show More ]
CranKy Ducklings
3 days
RSL Revival
3 days
herO vs Gerald
ByuN vs SHIN
Kung Fu Cup
3 days
IPSL
3 days
ZZZero vs rasowy
Napoleon vs KameZerg
BSL 21
3 days
Tarson vs Julia
Doodle vs OldBoy
eOnzErG vs WolFix
StRyKeR vs Aeternum
Sparkling Tuna Cup
4 days
RSL Revival
4 days
Reynor vs sOs
Maru vs Ryung
Kung Fu Cup
4 days
WardiTV Korean Royale
4 days
BSL 21
4 days
JDConan vs Semih
Dragon vs Dienmax
Tech vs NewOcean
TerrOr vs Artosis
IPSL
4 days
Dewalt vs WolFix
eOnzErG vs Bonyth
Wardi Open
5 days
Monday Night Weeklies
5 days
WardiTV Korean Royale
6 days
Liquipedia Results

Completed

Proleague 2025-11-07
Stellar Fest: Constellation Cup
Eternal Conflict S1

Ongoing

C-Race Season 1
IPSL Winter 2025-26
KCM Race Survival 2025 Season 4
SOOP Univ League 2025
YSL S2
BSL Season 21
BLAST Rivals Fall 2025
IEM Chengdu 2025
PGL Masters Bucharest 2025
Thunderpick World Champ.
CS Asia Championships 2025
ESL Pro League S22
StarSeries Fall 2025
FISSURE Playground #2
BLAST Open Fall 2025
BLAST Open Fall Qual

Upcoming

SLON Tour Season 2
BSL 21 Non-Korean Championship
Acropolis #4
IPSL Spring 2026
HSC XXVIII
RSL Offline Finals
WardiTV 2025
RSL Revival: Season 3
META Madness #9
BLAST Bounty Winter 2026
BLAST Bounty Winter 2026: Closed Qualifier
eXTREMESLAND 2025
ESL Impact League Season 8
SL Budapest Major 2025
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2025 TLnet. All Rights Reserved.