• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 13:17
CEST 19:17
KST 02:17
  • 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
[ASL19] Finals Recap: Standing Tall8HomeStory Cup 27 - Info & Preview18Classic wins Code S Season 2 (2025)16Code S RO4 & Finals Preview: herO, Rogue, Classic, GuMiho0TL Team Map Contest #5: Presented by Monster Energy6
Community News
Flash Announces Hiatus From ASL44Weekly Cups (June 23-29): Reynor in world title form?12FEL Cracov 2025 (July 27) - $8000 live event16Esports World Cup 2025 - Final Player Roster16Weekly Cups (June 16-22): Clem strikes back1
StarCraft 2
General
The SCII GOAT: A statistical Evaluation Statistics for vetoed/disliked maps Esports World Cup 2025 - Final Player Roster How does the number of casters affect your enjoyment of esports? Weekly Cups (June 23-29): Reynor in world title form?
Tourneys
RSL: Revival, a new crowdfunded tournament series [GSL 2025] Code S: Season 2 - Semi Finals & Finals $5,100+ SEL Season 2 Championship (SC: Evo) FEL Cracov 2025 (July 27) - $8000 live event HomeStory Cup 27 (June 27-29)
Strategy
How did i lose this ZvP, whats the proper response Simple Questions Simple Answers
Custom Maps
[UMS] Zillion Zerglings
External Content
Mutation # 480 Moths to the Flame Mutation # 479 Worn Out Welcome Mutation # 478 Instant Karma Mutation # 477 Slow and Steady
Brood War
General
BGH Auto Balance -> http://bghmmr.eu/ Player “Jedi” cheat on CSL Help: rep cant save Flash Announces Hiatus From ASL BW General Discussion
Tourneys
[Megathread] Daily Proleagues [BSL20] GosuLeague RO16 - Tue & Wed 20:00+CET The Casual Games of the Week Thread [BSL20] ProLeague LB Final - Saturday 20:00 CET
Strategy
Simple Questions, Simple Answers I am doing this better than progamers do.
Other Games
General Games
Stormgate/Frost Giant Megathread Nintendo Switch Thread Path of Exile What do you want from future RTS games? Beyond All Reason
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
Heroes of StarCraft mini-set
TL Mafia
TL Mafia Community Thread Vanilla Mini Mafia
Community
General
Russo-Ukrainian War Thread US Politics Mega-thread Things Aren’t Peaceful in Palestine Trading/Investing Thread The Games Industry And ATVI
Fan Clubs
SKT1 Classic Fan Club! Maru Fan Club
Media & Entertainment
Anime Discussion Thread [Manga] One Piece [\m/] Heavy Metal Thread
Sports
2024 - 2025 Football Thread NBA General Discussion Formula 1 Discussion TeamLiquid Health and Fitness Initiative For 2023 NHL Playoffs 2024
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
Blogs
Culture Clash in Video Games…
TrAiDoS
from making sc maps to makin…
Husyelt
Blog #2
tankgirl
StarCraft improvement
iopq
Trip to the Zoo
micronesia
Customize Sidebar...

Website Feedback

Closed Threads



Active: 589 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
Hyrule19029 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 States3696 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 States3696 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
WardiTV European League
16:00
Swiss Groups Day 2
Krystianer vs sebesdesLIVE!
MaxPax vs Babymarine
SKillous vs Mixu
ShoWTimE vs MaNa
WardiTV766
Liquipedia
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
mouzHeroMarine 399
BRAT_OK 89
JuggernautJason49
MindelVK 22
StarCraft: Brood War
Britney 22773
Sea 3037
Rain 2961
BeSt 131
Dewaltoss 81
sSak 26
zelot 24
scan(afreeca) 20
sas.Sziky 18
Aegong 17
[ Show more ]
GoRush 12
yabsab 10
Sacsri 9
soO 8
JulyZerg 5
IntoTheRainbow 4
Dota 2
Gorgc9094
qojqva3035
capcasts233
League of Legends
Dendi831
Counter-Strike
fl0m510
flusha274
Super Smash Bros
Mew2King153
Heroes of the Storm
Liquid`Hasu141
Other Games
FrodaN1744
ceh9488
Lowko356
crisheroes302
elazer179
Pyrionflax138
ArmadaUGS137
KnowMe125
Trikslyr62
QueenE54
Organizations
StarCraft 2
angryscii 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 14 non-featured ]
StarCraft 2
• intothetv
• AfreecaTV YouTube
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
League of Legends
• Nemesis6839
• Jankos1550
Other Games
• Shiphtur358
• imaqtpie39
Upcoming Events
Replay Cast
6h 43m
RSL Revival
16h 43m
herO vs SHIN
Reynor vs Cure
OSC
19h 43m
WardiTV European League
22h 43m
Scarlett vs Percival
Jumy vs ArT
YoungYakov vs Shameless
uThermal vs Fjant
Nicoract vs goblin
Harstem vs Gerald
FEL
22h 43m
Korean StarCraft League
1d 9h
CranKy Ducklings
1d 16h
RSL Revival
1d 16h
FEL
1d 22h
Sparkling Tuna Cup
2 days
[ Show More ]
RSL Revival
2 days
FEL
2 days
BSL: ProLeague
3 days
Dewalt vs Bonyth
Replay Cast
4 days
Replay Cast
4 days
The PondCast
5 days
Replay Cast
6 days
RSL Revival
6 days
Liquipedia Results

Completed

Proleague 2025-06-28
HSC XXVII
Heroes 10 EU

Ongoing

JPL Season 2
BSL 2v2 Season 3
BSL Season 20
Acropolis #3
KCM Race Survival 2025 Season 2
CSL 17: 2025 SUMMER
Copa Latinoamericana 4
Championship of Russia 2025
RSL Revival: Season 1
Murky Cup #2
BLAST.tv Austin Major 2025
ESL Impact League Season 7
IEM Dallas 2025
PGL Astana 2025
Asian Champions League '25
BLAST Rivals Spring 2025
MESA Nomadic Masters
CCT Season 2 Global Finals
IEM Melbourne 2025
YaLLa Compass Qatar 2025

Upcoming

CSLPRO Last Chance 2025
CSLPRO Chat StarLAN 3
K-Championship
uThermal 2v2 Main Event
SEL Season 2 Championship
FEL Cracov 2025
Esports World Cup 2025
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
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.