• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EST 14:33
CET 20:33
KST 04:33
  • 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
RSL Revival - 2025 Season Finals Preview8RSL Season 3 - Playoffs Preview0RSL Season 3 - RO16 Groups C & D Preview0RSL Season 3 - RO16 Groups A & B Preview2TL.net Map Contest #21: Winners12
Community News
Weekly Cups (Dec 15-21): Classic wins big, MaxPax & Clem take weeklies3ComeBackTV's documentary on Byun's Career !11Weekly Cups (Dec 8-14): MaxPax, Clem, Cure win4Weekly Cups (Dec 1-7): Clem doubles, Solar gets over the hump1Weekly Cups (Nov 24-30): MaxPax, Clem, herO win2
StarCraft 2
General
ComeBackTV's documentary on Byun's Career ! Team TLMC #5: Winners Announced! What's the best tug of war? The Grack before Christmas Weekly Cups (Dec 15-21): Classic wins big, MaxPax & Clem take weeklies
Tourneys
OSC Season 13 World Championship $5,000+ WardiTV 2025 Championship $100 Prize Pool - Winter Warp Gate Masters Showdow Sparkling Tuna Cup - Weekly Open Tournament Winter Warp Gate Amateur Showdown #1
Strategy
Custom Maps
Map Editor closed ?
External Content
Mutation # 505 Rise From Ashes Mutation # 504 Retribution Mutation # 503 Fowl Play Mutation # 502 Negative Reinforcement
Brood War
General
BW General Discussion How soO Began His ProGaming Dreams Klaucher discontinued / in-game color settings BGH Auto Balance -> http://bghmmr.eu/ Recommended FPV games (post-KeSPA)
Tourneys
[BSL21] LB SemiFinals - Saturday 21:00 CET [BSL21] WB & LB Finals - Sunday 21:00 CET Small VOD Thread 2.0 [Megathread] Daily Proleagues
Strategy
Simple Questions, Simple Answers Game Theory for Starcraft Current Meta Fighting Spirit mining rates
Other Games
General Games
Nintendo Switch Thread Mechabellum Stormgate/Frost Giant Megathread Beyond All Reason Path of Exile
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 Survivor II: The Amazon Sengoku Mafia TL Mafia Community Thread
Community
General
US Politics Mega-thread 12 Days of Starcraft The Games Industry And ATVI Russo-Ukrainian War Thread Things Aren’t Peaceful in Palestine
Fan Clubs
White-Ra Fan Club
Media & Entertainment
Anime Discussion Thread [Manga] One Piece
Sports
2024 - 2026 Football Thread Formula 1 Discussion
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
The Automated Ban List TL+ Announced Where to ask questions and add stream?
Blogs
National Diversity: A Challe…
TrAiDoS
I decided to write a webnov…
DjKniteX
James Bond movies ranking - pa…
Topin
Thanks for the RSL
Hildegard
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1518 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
Hyrule19184 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 28m
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
UpATreeSC 168
BRAT_OK 150
IndyStarCraft 128
JuggernautJason48
Railgan 27
MindelVK 27
StarCraft: Brood War
Shuttle 688
Jaedong 607
Larva 207
Dewaltoss 148
firebathero 135
JulyZerg 49
Rock 44
Sexy 38
910 27
Dota 2
qojqva4953
canceldota37
Counter-Strike
fl0m891
Heroes of the Storm
Liquid`Hasu306
Khaldor205
Trikslyr50
Other Games
Grubby6680
Beastyqt770
B2W.Neo346
DeMusliM202
ToD174
ArmadaUGS167
RotterdaM119
XaKoH 108
Organizations
Other Games
gamesdonequick976
StarCraft 2
angryscii 16
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 21 non-featured ]
StarCraft 2
• printf 40
• Adnapsc2 16
• mYiSmile112
• davetesta10
• Dystopia_ 4
• LaughNgamezSOOP
• sooper7s
• AfreecaTV YouTube
• intothetv
• Migwel
• Kozan
• IndyKCrew
StarCraft: Brood War
• STPLYoutube
• ZZZeroYoutube
• BSLYoutube
Dota 2
• WagamamaTV989
• Ler77
• lizZardDota277
League of Legends
• Nemesis3247
Other Games
• imaqtpie1990
• Shiphtur267
Upcoming Events
BSL 21
28m
Sziky vs eOnzErG
Sparkling Tuna Cup
14h 28m
Krystianer vs Classic
TriGGeR vs SKillous
Percival vs Ryung
ByuN vs Nicoract
OSC
22h 28m
BSL 21
1d
Cross vs Dewalt
Replay Cast
1d 13h
Wardi Open
1d 16h
OSC
2 days
Solar vs MaxPax
ByuN vs Krystianer
Spirit vs TBD
OSC
5 days
Korean StarCraft League
6 days
OSC
6 days
[ Show More ]
OSC
6 days
Liquipedia Results

Completed

Escore Tournament S1 - W1
WardiTV 2025
META Madness #9

Ongoing

C-Race Season 1
IPSL Winter 2025-26
BSL Season 21
CSL Season 19: Qualifier 2
eXTREMESLAND 2025
SL Budapest Major 2025
ESL Impact League Season 8
BLAST Rivals Fall 2025
IEM Chengdu 2025
PGL Masters Bucharest 2025
Thunderpick World Champ.
CS Asia Championships 2025

Upcoming

CSL 2025 WINTER (S19)
Escore Tournament S1 - W2
Escore Tournament S1 - W3
BSL 21 Non-Korean Championship
Acropolis #4
IPSL Spring 2026
Bellum Gens Elite Stara Zagora 2026
HSC XXVIII
Big Gabe Cup #3
OSC Championship Season 13
Nations Cup 2026
ESL Pro League Season 23
PGL Cluj-Napoca 2026
IEM Kraków 2026
BLAST Bounty Winter 2026
BLAST Bounty Winter Qual
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.