• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 06:42
CET 11:42
KST 19:42
  • 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
[ASL21] Ro24 Preview Pt1: New Chaos0Team Liquid Map Contest #22 - Presented by Monster Energy5ByuL: The Forgotten Master of ZvT30Behind the Blue - Team Liquid History Book19Clem wins HomeStory Cup 289
Community News
Blizzard Classic Cup @ BlizzCon 2026 - $100k prize pool39Weekly Cups (March 9-15): herO, Clem, ByuN win42026 KungFu Cup Announcement6BGE Stara Zagora 2026 cancelled12Blizzard Classic Cup - Tastosis announced as captains18
StarCraft 2
General
Blizzard Classic Cup @ BlizzCon 2026 - $100k prize pool Potential Updates Coming to the SC2 CN Server Weekly Cups (March 2-8): ByuN overcomes PvT block Weekly Cups (August 25-31): Clem's Last Straw? Weekly Cups (March 9-15): herO, Clem, ByuN win
Tourneys
World University TeamLeague (500$+) | Signups Open RSL Season 4 announced for March-April Sparkling Tuna Cup - Weekly Open Tournament WardiTV Team League Season 10 KSL Week 87
Strategy
Custom Maps
Publishing has been re-enabled! [Feb 24th 2026]
External Content
Mutation # 518 Radiation Zone The PondCast: SC2 News & Results Mutation # 517 Distant Threat Mutation # 516 Specter of Death
Brood War
General
Soulkey's decision to leave C9 JaeDong's form before ASL BGH Auto Balance -> http://bghmmr.eu/ [ASL21] Ro24 Preview Pt1: New Chaos ASL21 General Discussion
Tourneys
[ASL21] Ro24 Group A [Megathread] Daily Proleagues ASL Season 21 LIVESTREAM with English Commentary [BSL22] Open Qualifiers & Ladder Tours
Strategy
Fighting Spirit mining rates Simple Questions, Simple Answers Soma's 9 hatch build from ASL Game 2
Other Games
General Games
General RTS Discussion Thread Stormgate/Frost Giant Megathread Nintendo Switch Thread Path of Exile Dawn of War IV
Dota 2
Official 'what is Dota anymore' discussion The Story of Wings Gaming
League of Legends
G2 just beat GenG in First stand
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 Five o'clock TL Mafia Mafia Game Mode Feedback/Ideas Vanilla Mini Mafia
Community
General
US Politics Mega-thread Things Aren’t Peaceful in Palestine YouTube Thread Canadian Politics Mega-thread Russo-Ukrainian War Thread
Fan Clubs
The IdrA Fan Club
Media & Entertainment
[Req][Books] Good Fantasy/SciFi books Movie Discussion! [Manga] One Piece
Sports
2024 - 2026 Football Thread Cricket [SPORT] Formula 1 Discussion Tokyo Olympics 2021 Thread General nutrition recommendations
World Cup 2022
Tech Support
Laptop capable of using Photoshop Lightroom?
TL Community
U4GM Tips Counter Enemy Gadgets Fast in Black Ops rsvsr How to Keep Reward Chains Rolling in Monopol u4gm What to Do First in MLB The Show 26 Spring
Blogs
Funny Nicknames
LUCKY_NOOB
Money Laundering In Video Ga…
TrAiDoS
Iranian anarchists: organize…
XenOsky
FS++
Kraekkling
Shocked by a laser…
Spydermine0240
Unintentional protectionism…
Uldridge
ASL S21 English Commentary…
namkraft
Customize Sidebar...

Website Feedback

Closed Threads



Active: 5555 users

The Big Programming Thread - Page 252

Forum Index > General Forum
Post a Reply
Prev 1 250 251 252 253 254 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.
Mstring
Profile Joined September 2011
Australia510 Posts
February 19 2013 23:03 GMT
#5021
On February 20 2013 07:58 InRaged wrote:
Thank you, delHospital. Should be char tmp[] instead;

darkness, If you can use strncat instead then instead of tmp variable you could do
strncat(string, (char *)&c, 1);
The casting is required in such case, cause your c is int and not char. Last argument tells strncat how much bytes to copy.


This will compile and won't give you a seg-fault, but will fail to work correctly when the hardware does not store the least significant bit in the first byte of the int.
InRaged
Profile Joined February 2007
1047 Posts
February 19 2013 23:15 GMT
#5022
You mean big-endian hardware, right? Zero-experience programming for this type of machines. Regular Int to char works as expected though, so it's only when working with pointers you have to keep that mind?
Mstring
Profile Joined September 2011
Australia510 Posts
February 19 2013 23:37 GMT
#5023
On February 20 2013 08:15 InRaged wrote:
You mean big-endian hardware, right? Zero-experience programming for this type of machines. Regular Int to char works as expected though, so it's only when working with pointers you have to keep that mind?


You're giving something that expects a char* an int* and taking for granted the fact that it just happens to be stored in a way which will works in this particular case. You don't need to keep it in mind if you avoid casting pointers like this.
Emon_
Profile Blog Joined November 2009
3925 Posts
February 19 2013 23:51 GMT
#5024
I've been thinking about creating a game aimed at children and young adults to help them with learning math. What is the fastest way to do this as a single player game and what is the fastest if I wanted to make it multiplayer?
"I know that human beings and fish can coexist peacefully" -GWB ||
Shield
Profile Blog Joined August 2009
Bulgaria4824 Posts
February 20 2013 00:25 GMT
#5025
On February 20 2013 07:58 InRaged wrote:
Thank you, delHospital. Should be char tmp[];

darkness, If you can use strncat instead of strcat then instead of tmp variable you could do
strncat(string, (char *)&c, 1);
The casting is required in such case, cause your c is int and not char (but it isn't as portable, see Mstring's responce). Last argument tells strncat how much bytes to copy.

Also there is a bug in your algorithm. Check your if conditions to find it ;P


The bug is I had wrong condition to check for lower-case letters. There is 'a' and 'M'.
Other than that, everything works. Thanks for help.
InRaged
Profile Joined February 2007
1047 Posts
February 20 2013 02:01 GMT
#5026
On February 20 2013 08:37 Mstring wrote:
Show nested quote +
On February 20 2013 08:15 InRaged wrote:
You mean big-endian hardware, right? Zero-experience programming for this type of machines. Regular Int to char works as expected though, so it's only when working with pointers you have to keep that mind?


You're giving something that expects a char* an int* and taking for granted the fact that it just happens to be stored in a way which will works in this particular case. You don't need to keep it in mind if you avoid casting pointers like this.

No need to be condescending. I took it for granted, because it is granted that on x86 and on any other little-endian system it is stored in a way that will work. Big-endian systems are pretty exotic, so forgive me for forgetting about such details.
Mstring
Profile Joined September 2011
Australia510 Posts
February 20 2013 02:15 GMT
#5027
On February 20 2013 11:01 InRaged wrote:
Show nested quote +
On February 20 2013 08:37 Mstring wrote:
On February 20 2013 08:15 InRaged wrote:
You mean big-endian hardware, right? Zero-experience programming for this type of machines. Regular Int to char works as expected though, so it's only when working with pointers you have to keep that mind?


You're giving something that expects a char* an int* and taking for granted the fact that it just happens to be stored in a way which will works in this particular case. You don't need to keep it in mind if you avoid casting pointers like this.

No need to be condescending. I took it for granted, because it is granted that on x86 and on any other little-endian system it is stored in a way that will work. Big-endian systems are pretty exotic, so forgive me for forgetting about such details.

I think you are seeing things in my comment which aren't there. I was simply being direct.
phar
Profile Joined August 2011
United States1080 Posts
Last Edited: 2013-02-20 05:58:25
February 20 2013 05:00 GMT
#5028
Can't go around thinking criticisms of your code are condescending, that'll prevent you from improving. If something is wrong and someone points it out, that's good for you, they're not trying to insult you or anything.

i can grammar
Who after all is today speaking about the destruction of the Armenians?
Tobberoth
Profile Joined August 2010
Sweden6375 Posts
February 20 2013 08:52 GMT
#5029
On February 20 2013 08:51 Emon_ wrote:
I've been thinking about creating a game aimed at children and young adults to help them with learning math. What is the fastest way to do this as a single player game and what is the fastest if I wanted to make it multiplayer?

Depends on how you plan to make the game. If you're just going for some interface with buttons and textboxes, you can go with pretty much anything, such as C# or Java. If you plan to have proper "graphics", you'll probably need SDL. While there are bindings for most languages, I think the easiest in that case would be to go with Python and Pygame (SDL.Net was last updated like 2-3 years ago, I don't know about Java SDL bindings).

Adding multiplayer is probably just as complex on Python as it is in C# or Java, you need to learn about sockets etc regardless.
Pibacc
Profile Joined May 2010
Canada545 Posts
Last Edited: 2013-02-20 09:16:50
February 20 2013 09:16 GMT
#5030
Hey everyone. I'm just learning how to use visual basic and I'm stuck with making a program to find the average for best 3 out of 4 using a self made private sub that I call to using a button. Below are pictures of the form and source code.

Form
Source Code

I thought this would work but when I run the program the calculations are off. I tested using 50/50/50/10 and the average comes out as 33.33~.

Anyone able to help me figure out the problem?
Tobberoth
Profile Joined August 2010
Sweden6375 Posts
Last Edited: 2013-02-20 09:27:36
February 20 2013 09:23 GMT
#5031
On February 20 2013 18:16 Pibacc wrote:
Hey everyone. I'm just learning how to use visual basic and I'm stuck with making a program to find the average for best 3 out of 4 using a self made private sub that I call to using a button. Below are pictures of the form and source code.

Form
Source Code

I thought this would work but when I run the program the calculations are off. I tested using 50/50/50/10 and the average comes out as 33.33~.

Anyone able to help me figure out the problem?

You should be assigning dblLow, you're doing it the other way around. It should be dblLow = dblV4 instead of dblV4 = dblLow.

As it is right now, when you get to the actual calculation, dblLow is still unassigned and some of your dblV values has been set to the dblLow unassigned value (0 by default in VB). So the actual calculation in this case becomes (50 + 0 + 50 + 0 - 0) / 3
Pibacc
Profile Joined May 2010
Canada545 Posts
Last Edited: 2013-02-20 09:32:52
February 20 2013 09:30 GMT
#5032
On February 20 2013 18:23 Tobberoth wrote:
Show nested quote +
On February 20 2013 18:16 Pibacc wrote:
Hey everyone. I'm just learning how to use visual basic and I'm stuck with making a program to find the average for best 3 out of 4 using a self made private sub that I call to using a button. Below are pictures of the form and source code.

Form
Source Code

I thought this would work but when I run the program the calculations are off. I tested using 50/50/50/10 and the average comes out as 33.33~.

Anyone able to help me figure out the problem?

You should be assigning dblLow, you're doing it the other way around. It should be dblLow = dblV4 instead of dblV4 = dblLow.

As it is right now, when you get to the actual calculation, dblLow is still unassigned and some of your dblV values has been set to the dblLow unassigned value (0 by default in VB). So the actual calculation in this case becomes (50 + 0 + 50 + 0 - 0) / 3


WOW I cannot believe I fucked that up for only half of them lol. After fixing the first if statement it works. Thank you very much!
Soan
Profile Blog Joined August 2010
New Zealand194 Posts
February 20 2013 09:52 GMT
#5033
On February 20 2013 08:51 Emon_ wrote:
I've been thinking about creating a game aimed at children and young adults to help them with learning math. What is the fastest way to do this as a single player game and what is the fastest if I wanted to make it multiplayer?


The fastest way is to probably use a pre-existing engine such as Unity. All the difficult stuff is taken care of and you're just left with writing the game code and supplying the art. Of course you also have to learn how to use Unity, but there's plenty of tutorials around on the internets.
SgtCoDFish
Profile Blog Joined July 2010
United Kingdom1520 Posts
February 20 2013 10:12 GMT
#5034
On February 20 2013 08:51 Emon_ wrote:
I've been thinking about creating a game aimed at children and young adults to help them with learning math. What is the fastest way to do this as a single player game and what is the fastest if I wanted to make it multiplayer?


This is impossible to answer without knowing about you first; what programming experience do you already have? If you're already super experienced with a language, you'll make a game quickest in that language. If not, something like pygame will probably be quick (I've never used it but I hear good things)

If your only goal is making it quick, there are tools like Game Maker that can make games/prototypes really quickly, sometimes without even needing code. People will shit on things like Game Maker but really if you want speed you won't beat it with a traditional programming language for a small quick game. I think Game Maker can do both single and multiplayer, but don't quote me on that.

(Personally, I would use Java+LibGDX because that's what I'm comfortable with. The only other language I'm proficient with is C++ and C++ is a bit of a pain for multiplayer.)
Shield
Profile Blog Joined August 2009
Bulgaria4824 Posts
Last Edited: 2013-02-20 19:19:39
February 20 2013 19:12 GMT
#5035
Question about C:

How can I create n strings using heap?

E.g.

#define STRSIZE 50
input n = 5

I was thinking about usng a loop, but I guess this wouldn't work because of 'i':

for (i = 1; i <= n; i++)
char *string'i' = malloc(STRSIZE * sizeof(char));

So it may not be created as string1, string2, string3, etc.

suggestions?

Edit: Is that how malloc should be used for char string[STRSIZE]?
phar
Profile Joined August 2011
United States1080 Posts
Last Edited: 2013-02-21 02:11:15
February 21 2013 02:08 GMT
#5036
pointer pointer, same thing as an array pointers or array of arrays. In c, you can think of an array as the same thing as a pointer - foo[5] is just a fancy way of writing *(foo + 5). Sort of...

(syntax may not be exact, take with grain of salt and run through gcc to find my obvious fuckups):
char **my_strings;
int n; // sometime later n = 5 I guess? You weren't clear on that but w/e

my_strings = (char **) malloc(n * sizeof(char *));

for (int i = 1; i < n; ++i) {
my_strings[i] = (char *) malloc(STRSIZE * sizeof(char));
}
Who after all is today speaking about the destruction of the Armenians?
ranshaked
Profile Blog Joined August 2010
United States870 Posts
February 22 2013 16:49 GMT
#5037
Hey guys! I need a little help in Java. I'm trying to convert a String to specific ints. It has to do with a card game, so I have face values 2-10, jack, queen, king, ace. I'm using a method called getface(): and I can print out the face values fine, but I need to convert them to ints in order to compare them easier in order to determine the winner of a hand.

I've tried:
Switch statements (only to find out that you can't use case 'Ace': faceValue = 14;...apparently it only works with ints!)
If statements (doesn't work, it won't let me force the switch)
Integer.parseInt(string) (doesn't work, it throws a bunch of errors)


Is there another way to convert the face value from a String to it's equivalent int?
DumJumJmyWum
Profile Joined March 2011
United States75 Posts
February 22 2013 17:07 GMT
#5038
On February 23 2013 01:49 ranshaked wrote:
Hey guys! I need a little help in Java. I'm trying to convert a String to specific ints. It has to do with a card game, so I have face values 2-10, jack, queen, king, ace. I'm using a method called getface(): and I can print out the face values fine, but I need to convert them to ints in order to compare them easier in order to determine the winner of a hand.

I've tried:
Switch statements (only to find out that you can't use case 'Ace': faceValue = 14;...apparently it only works with ints!)
If statements (doesn't work, it won't let me force the switch)
Integer.parseInt(string) (doesn't work, it throws a bunch of errors)


Is there another way to convert the face value from a String to it's equivalent int?


For the Strings that are numbers, you can use Integer.parse(). It will throw an exception for non integer values.
However, I would suggest trying to use enums instead as you can use autocomplete in your IDE as well as give your code better structure.

Also, as of Java 7, you can use strings in switch statements. So, if you're allowed to upgrade to version 7, that would probably be the easiest.
CapnAmerica
Profile Blog Joined November 2010
United States508 Posts
February 22 2013 17:56 GMT
#5039
On February 23 2013 01:49 ranshaked wrote:
Hey guys! I need a little help in Java. I'm trying to convert a String to specific ints. It has to do with a card game, so I have face values 2-10, jack, queen, king, ace. I'm using a method called getface(): and I can print out the face values fine, but I need to convert them to ints in order to compare them easier in order to determine the winner of a hand.

I've tried:
Switch statements (only to find out that you can't use case 'Ace': faceValue = 14;...apparently it only works with ints!)
If statements (doesn't work, it won't let me force the switch)
Integer.parseInt(string) (doesn't work, it throws a bunch of errors)


Is there another way to convert the face value from a String to it's equivalent int?


I only have c++ programming experience, but you could simply assign a value to a new variable for each card. For your if statements, if cardname = jack then cardnum = 11, if cardname = queen then cardnum = 12, and so on.

Forgive my ignorance though, but why can't you use an assignment statement like:

If I were doing this in c++ (again, never done anything in java)

void convertCardNums()

{

string cardValue;

if (cardValue = "1")
cardValue = "01";

...

if (cardValue = "jack")
cardValue = "11";
if (cardValue = "queen")
cardValue = "12";
if (cardValue = "king")
cardValue = "13";

}

After all this time, I still haven't figured out the correlation between sexual orientation and beating an unprepared opponent. Are homosexuals the next koreans? Many players seem to think it's an unfair advantage. - pandaburn
Blisse
Profile Blog Joined July 2010
Canada3710 Posts
Last Edited: 2013-02-22 19:02:38
February 22 2013 18:59 GMT
#5040
On February 23 2013 01:49 ranshaked wrote:
Hey guys! I need a little help in Java. I'm trying to convert a String to specific ints. It has to do with a card game, so I have face values 2-10, jack, queen, king, ace. I'm using a method called getface(): and I can print out the face values fine, but I need to convert them to ints in order to compare them easier in order to determine the winner of a hand.

I've tried:
Switch statements (only to find out that you can't use case 'Ace': faceValue = 14;...apparently it only works with ints!)
If statements (doesn't work, it won't let me force the switch)
Integer.parseInt(string) (doesn't work, it throws a bunch of errors)


Is there another way to convert the face value from a String to it's equivalent int?


The performance of a system that has to use a switch statement every time you want to compare card values is going to be unnecessarily bad. This is a case where you don't want to use strings to store the card. Instead, use ints for all the cards, and only convert them to strings when you need to display it. :/

If you do it that way, you can simply use a single List with all the names of the strings in the correct index, so faceString[1] returns "Ace".


This would be more of a design issue/solution.
There is no one like you in the universe.
Prev 1 250 251 252 253 254 1032 Next
Please log in or register to reply.
Live Events Refresh
Afreeca Starleague
10:00
Ro24 Group A
Sharp vs Scan
Rain vs Mong
Afreeca ASL 10683
StarCastTV_EN194
LiquipediaDiscussion
Replay Cast
09:00
WardiTV Mondays #75
CranKy Ducklings142
LiquipediaDiscussion
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
ProTech114
MindelVK 12
StarCraft: Brood War
Calm 15038
Flash 5159
Bisu 4658
Horang2 2721
Jaedong 1378
Hyuk 836
BeSt 695
Larva 345
Stork 304
Pusan 284
[ Show more ]
Zeus 277
Leta 143
Light 121
PianO 65
Killer 63
ToSsGirL 59
NotJumperer 57
Backho 49
Bale 29
yabsab 28
Nal_rA 27
Shinee 24
Hm[arnc] 20
soO 14
GoRush 12
Noble 11
Movie 8
Terrorterran 8
Dota 2
XcaliburYe343
canceldota139
Counter-Strike
olofmeister1748
zeus438
edward69
Other Games
ceh9669
Happy332
shoxiejesuss245
crisheroes223
Fuzer 213
Livibee134
XBOCT116
Sick112
Mew2King72
ViBE35
Organizations
Other Games
gamesdonequick681
StarCraft: Brood War
UltimateBattle 231
lovetv 18
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 14 non-featured ]
StarCraft 2
• LUISG 40
• StrangeGG 28
• CranKy Ducklings SOOP5
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• iopq 4
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Upcoming Events
Wardi Open
1h 18m
Monday Night Weeklies
6h 18m
Sparkling Tuna Cup
23h 18m
Afreeca Starleague
23h 18m
Soulkey vs Ample
JyJ vs sSak
Replay Cast
1d 22h
Afreeca Starleague
1d 23h
hero vs YSC
Larva vs Shine
Kung Fu Cup
2 days
Replay Cast
2 days
KCM Race Survival
2 days
The PondCast
2 days
[ Show More ]
WardiTV Team League
3 days
Replay Cast
3 days
WardiTV Team League
4 days
RSL Revival
4 days
Cure vs Zoun
herO vs Rogue
WardiTV Team League
5 days
Platinum Heroes Events
5 days
BSL
5 days
RSL Revival
5 days
ByuN vs Maru
MaxPax vs TriGGeR
WardiTV Team League
6 days
BSL
6 days
Replay Cast
6 days
Afreeca Starleague
6 days
Light vs Calm
Royal vs Mind
Liquipedia Results

Completed

Proleague 2026-03-22
WardiTV Winter 2026
Underdog Cup #3

Ongoing

KCM Race Survival 2026 Season 1
BSL Season 22
CSL Elite League 2026
CSL Season 20: Qualifier 1
ASL Season 21
Acropolis #4 - TS6
RSL Revival: Season 4
Nations Cup 2026
NationLESS Cup
BLAST Open Spring 2026
ESL Pro League S23 Finals
ESL Pro League S23 Stage 1&2
PGL Cluj-Napoca 2026
IEM Kraków 2026
BLAST Bounty Winter 2026
BLAST Bounty Winter Qual

Upcoming

2026 Changsha Offline CUP
CSL Season 20: Qualifier 2
CSL 2026 SPRING (S20)
Acropolis #4
IPSL Spring 2026
BSL 22 Non-Korean Championship
CSLAN 4
Kung Fu Cup 2026 Grand Finals
HSC XXIX
uThermal 2v2 2026 Main Event
IEM Cologne Major 2026
Stake Ranked Episode 2
CS Asia Championships 2026
Asian Champions League 2026
IEM Atlanta 2026
PGL Astana 2026
BLAST Rivals Spring 2026
CCT Season 3 Global Finals
IEM Rio 2026
PGL Bucharest 2026
Stake Ranked Episode 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 © 2026 TLnet. All Rights Reserved.