• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 05:43
CEST 11:43
KST 18:43
  • 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 TLMC #5 - Finalists & Open Tournaments0[ASL20] Ro16 Preview Pt2: Turbulence10Classic Games #3: Rogue vs Serral at BlizzCon9[ASL20] Ro16 Preview Pt1: Ascent10Maestros of the Game: Week 1/Play-in Preview12
Community News
BSL 2025 Warsaw LAN + Legends Showmatch0Weekly Cups (Sept 8-14): herO & MaxPax split cups4WardiTV TL Team Map Contest #5 Tournaments1SC4ALL $6,000 Open LAN in Philadelphia8Weekly Cups (Sept 1-7): MaxPax rebounds & Clem saga continues29
StarCraft 2
General
#1: Maru - Greatest Players of All Time Weekly Cups (Sept 8-14): herO & MaxPax split cups Team Liquid Map Contest #21 - Presented by Monster Energy SpeCial on The Tasteless Podcast Team TLMC #5 - Finalists & Open Tournaments
Tourneys
Maestros of The Game—$20k event w/ live finals in Paris Sparkling Tuna Cup - Weekly Open Tournament SC4ALL $6,000 Open LAN in Philadelphia WardiTV TL Team Map Contest #5 Tournaments RSL: Revival, a new crowdfunded tournament series
Strategy
Custom Maps
External Content
Mutation # 491 Night Drive Mutation # 490 Masters of Midnight Mutation # 489 Bannable Offense Mutation # 488 What Goes Around
Brood War
General
Soulkey on ASL S20 ASL TICKET LIVE help! :D BW General Discussion NaDa's Body A cwal.gg Extension - Easily keep track of anyone
Tourneys
[ASL20] Ro16 Group D [ASL20] Ro16 Group C [Megathread] Daily Proleagues BSL 2025 Warsaw LAN + Legends Showmatch
Strategy
Simple Questions, Simple Answers Muta micro map competition Fighting Spirit mining rates [G] Mineral Boosting
Other Games
General Games
Stormgate/Frost Giant Megathread Nintendo Switch Thread Path of Exile Borderlands 3 General RTS Discussion Thread
Dota 2
Official 'what is Dota anymore' discussion LiquidDota to reintegrate into TL.net
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Heroes of StarCraft mini-set
TL Mafia
TL Mafia Community Thread
Community
General
US Politics Mega-thread Canadian Politics Mega-thread Things Aren’t Peaceful in Palestine Russo-Ukrainian War Thread UK Politics Mega-thread
Fan Clubs
The Happy Fan Club!
Media & Entertainment
Movie Discussion! [Manga] One Piece Anime Discussion Thread
Sports
2024 - 2026 Football Thread Formula 1 Discussion MLB/Baseball 2023
World Cup 2022
Tech Support
Linksys AE2500 USB WIFI keeps disconnecting Computer Build, Upgrade & Buying Resource Thread High temperatures on bridge(s)
TL Community
BarCraft in Tokyo Japan for ASL Season5 Final The Automated Ban List
Blogs
I <=> 9
KrillinFromwales
The Personality of a Spender…
TrAiDoS
A very expensive lesson on ma…
Garnet
hello world
radishsoup
Lemme tell you a thing o…
JoinTheRain
RTS Design in Hypercoven
a11
Evil Gacha Games and the…
ffswowsucks
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1573 users

The Big Programming Thread - Page 19

Forum Index > General Forum
Post a Reply
Prev 1 17 18 19 20 21 1031 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
Hyrule19087 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 States3701 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 States3701 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 1031 Next
Please log in or register to reply.
Live Events Refresh
Next event in 17m
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
Rex 2
StarCraft: Brood War
Calm 5699
Bisu 731
Hyuk 162
HiyA 96
Hyun 96
sorry 86
ToSsGirL 84
Dewaltoss 82
Pusan 77
Light 74
[ Show more ]
Soma 60
actioN 56
Mini 49
ZerO 32
BeSt 30
Nal_rA 28
soO 27
Liquid`Ret 26
Sharp 24
Rush 19
Free 16
SilentControl 10
Dota 2
singsing1508
XcaliburYe237
boxi98170
League of Legends
JimRising 381
Counter-Strike
olofmeister1583
shoxiejesuss629
allub166
Other Games
XaKoH 143
NeuroSwarm75
Trikslyr15
Organizations
Other Games
gamesdonequick599
StarCraft: Brood War
lovetv 593
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 14 non-featured ]
StarCraft 2
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• iopq 1
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
League of Legends
• Jankos1421
• Stunt679
Other Games
• WagamamaTV81
Upcoming Events
RSL Revival
17m
Maru vs Reynor
Cure vs TriGGeR
Rex2
Map Test Tournament
1h 17m
The PondCast
3h 17m
RSL Revival
1d
Zoun vs Classic
Korean StarCraft League
1d 17h
BSL Open LAN 2025 - War…
1d 22h
RSL Revival
2 days
BSL Open LAN 2025 - War…
2 days
RSL Revival
3 days
Online Event
3 days
[ Show More ]
Wardi Open
4 days
Monday Night Weeklies
4 days
Sparkling Tuna Cup
5 days
LiuLi Cup
6 days
Liquipedia Results

Completed

Proleague 2025-09-10
Chzzk MurlocKing SC1 vs SC2 Cup #2
HCC Europe

Ongoing

BSL 20 Team Wars
KCM Race Survival 2025 Season 3
BSL 21 Points
ASL Season 20
CSL 2025 AUTUMN (S18)
LASL Season 20
RSL Revival: Season 2
Maestros of the Game
StarSeries Fall 2025
FISSURE Playground #2
BLAST Open Fall 2025
BLAST Open Fall Qual
Esports World Cup 2025
BLAST Bounty Fall 2025
BLAST Bounty Fall Qual
IEM Cologne 2025
FISSURE Playground #1

Upcoming

2025 Chongqing Offline CUP
BSL World Championship of Poland 2025
IPSL Winter 2025-26
BSL Season 21
SC4ALL: Brood War
BSL 21 Team A
Stellar Fest
SC4ALL: StarCraft II
EC S1
ESL Impact League Season 8
SL Budapest Major 2025
BLAST Rivals Fall 2025
IEM Chengdu 2025
PGL Masters Bucharest 2025
MESA Nomadic Masters Fall
Thunderpick World Champ.
CS Asia Championships 2025
ESL Pro League S22
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.