• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EST 15:01
CET 21:01
KST 05:01
  • 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: Winners1Intel 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
Starcraft, SC2, HoTS, WC3, returning to Blizzcon!20$5,000+ WardiTV 2025 Championship5[BSL21] RO32 Group Stage3Weekly Cups (Oct 26-Nov 2): Liquid, Clem, Solar win; LAN in Philly2Weekly Cups (Oct 20-26): MaxPax, Clem, Creator win9
StarCraft 2
General
TL.net Map Contest #21: Winners Starcraft, SC2, HoTS, WC3, returning to Blizzcon! RotterdaM "Serral is the GOAT, and it's not close" Weekly Cups (Oct 20-26): MaxPax, Clem, Creator win 5.0.15 Patch Balance Hotfix (2025-10-8)
Tourneys
$5,000+ WardiTV 2025 Championship Constellation Cup - Main Event - Stellar Fest Merivale 8 Open - LAN - Stellar Fest Sea Duckling Open (Global, Bronze-Diamond) $3,500 WardiTV Korean Royale S4
Strategy
Custom Maps
Map Editor closed ?
External Content
Mutation # 498 Wheel of Misfortune|Cradle of Death Mutation # 497 Battle Haredened Mutation # 496 Endless Infection Mutation # 495 Rest In Peace
Brood War
General
BGH Auto Balance -> http://bghmmr.eu/ SnOw's ASL S20 Finals Review [BSL21] RO32 Group Stage Practice Partners (Official) [ASL20] Ask the mapmakers — Drop your questions
Tourneys
[Megathread] Daily Proleagues [BSL21] RO32 Group B - Sunday 21:00 CET [BSL21] RO32 Group A - Saturday 21:00 CET BSL21 Open Qualifiers Week & CONFIRM PARTICIPATION
Strategy
Current Meta How to stay on top of macro? PvZ map balance Soma's 9 hatch build from ASL Game 2
Other Games
General Games
Stormgate/Frost Giant Megathread Nintendo Switch Thread Dawn of War IV ZeroSpace Megathread General RTS Discussion Thread
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
Russo-Ukrainian War Thread US Politics Mega-thread Things Aren’t Peaceful in Palestine YouTube Thread Dating: How's your luck?
Fan Clubs
White-Ra Fan Club The herO Fan Club!
Media & Entertainment
Movie Discussion! [Manga] One Piece Anime Discussion Thread Korean Music Discussion Series you have seen recently...
Sports
2024 - 2026 Football Thread NBA General Discussion MLB/Baseball 2023 TeamLiquid Health and Fitness Initiative For 2023 Formula 1 Discussion
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 Recent Gifted Posts
Blogs
Saturation point
Uldridge
DnB/metal remix FFO Mick Go…
ImbaTosS
Why we need SC3
Hildegard
Career Paths and Skills for …
TrAiDoS
Reality "theory" prov…
perfectspheres
Our Last Hope in th…
KrillinFromwales
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1327 users

The Big Programming Thread - Page 864

Forum Index > General Forum
Post a Reply
Prev 1 862 863 864 865 866 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.
BluzMan
Profile Blog Joined April 2006
Russian Federation4235 Posts
March 26 2017 19:56 GMT
#17261
On March 27 2017 00:45 travis wrote:
Oh blitz that's an excellent example, thank you.

Just to make sure I am on the right page here, the poblem is that when we dereference p and w in our print statement, they are both going to print from the same address, which currently holds the result of get_val(100) ?


You won't advance at all in C/C++ before you learn the basics, which includes automatic/manual memory and pointers. What you're doing is that you're leaking a pointer to automatic memory (which is always scoped, in this case, within the function body) outside of it's scope. Dereferencing such a pointer is undefined behavior - your program is allowed to do anything, including really gruesome stuff.
You want 20 good men, but you need a bad pussy.
Wrath
Profile Blog Joined July 2014
3174 Posts
March 27 2017 06:22 GMT
#17262
Any ETA on the "Soon" new OP?
DickMcFanny
Profile Blog Joined September 2015
Ireland1076 Posts
March 27 2017 08:41 GMT
#17263
Are there any game devs here?

I'm doing a web dev course but it itches me to start creating a game 2d game in the vein of Super Metroid.

What technologies should I start to learn if my focus is low input latency and 60 FPS / controller support?
Game should run on Linux, OSX and Windows.
| (• ◡•)|╯ ╰(❍ᴥ❍ʋ)
Acrofales
Profile Joined August 2010
Spain18108 Posts
March 27 2017 09:11 GMT
#17264
On March 27 2017 17:41 DickMcFanny wrote:
Are there any game devs here?

I'm doing a web dev course but it itches me to start creating a game 2d game in the vein of Super Metroid.

What technologies should I start to learn if my focus is low input latency and 60 FPS / controller support?
Game should run on Linux, OSX and Windows.

All my game Dev friends talk about nowadays is unity, so I'd start with that and see if it suits your needs.
Cyx.
Profile Joined November 2010
Canada806 Posts
March 27 2017 09:12 GMT
#17265
On March 27 2017 17:41 DickMcFanny wrote:
Are there any game devs here?

I'm doing a web dev course but it itches me to start creating a game 2d game in the vein of Super Metroid.

What technologies should I start to learn if my focus is low input latency and 60 FPS / controller support?
Game should run on Linux, OSX and Windows.

Not quite yet but I have a job lined up for when I graduate not experienced with it for 2d games but I hear Unity is totally reasonable in terms of 2d performance, and has the bonus of being able to target all those platforms and more. Definitely supports controllers too. You could probably achieve something similar with other engines (Unreal is another popular one) but I have even less experience with them than with Unity lol
DickMcFanny
Profile Blog Joined September 2015
Ireland1076 Posts
March 27 2017 09:26 GMT
#17266
On March 27 2017 18:11 Acrofales wrote:
Show nested quote +
On March 27 2017 17:41 DickMcFanny wrote:
Are there any game devs here?

I'm doing a web dev course but it itches me to start creating a game 2d game in the vein of Super Metroid.

What technologies should I start to learn if my focus is low input latency and 60 FPS / controller support?
Game should run on Linux, OSX and Windows.

All my game Dev friends talk about nowadays is unity, so I'd start with that and see if it suits your needs.


I'll start with Unity then, there's a billion tutorials and ebooks about that out there anyway.
| (• ◡•)|╯ ╰(❍ᴥ❍ʋ)
tofucake
Profile Blog Joined October 2009
Hyrule19150 Posts
March 27 2017 13:41 GMT
#17267
On March 27 2017 15:22 Wrath wrote:
Any ETA on the "Soon" new OP?

Soon
Liquipediaasante sana squash banana
DickMcFanny
Profile Blog Joined September 2015
Ireland1076 Posts
March 27 2017 13:42 GMT
#17268
soon™
| (• ◡•)|╯ ╰(❍ᴥ❍ʋ)
Deleted User 3420
Profile Blog Joined May 2003
24492 Posts
March 27 2017 21:31 GMT
#17269
Ok, need help with a proof, maybe some of you could tell me what you think

Question:

+ Show Spoiler +

Let T be defined by:

T_0 = {0, 1, 2, 3, 4, 5, 6}
(for all n >= 0)[if x,y,z are in T_n, then x^2+y^2+z^2 are in t_(n+1)]

T = The union from i=0 to infinity of T_i

(so, it's T_0 U T_1 U T_2 etc etc)

Now, prove that for all w in T, w is not congruent to 7 (mod 8) using structural or weak induction


So, this is what I have so far:

+ Show Spoiler +

For all w in T_0, w fulfill the following cases

w = 0, w^2 is congruent to 0 mod 8
w = 1, w^2 is congruent to 1 mod 8
w = 2, w^2 is congruent to 4 mod 8
w = 3, w^2 is congruent to 1 mod 8
w = 4, w^2 is congruent to 0 mod 8
w = 5, w^2 is congruent to 1 mod 8
w = 6, w^2 is congruent to 4 mod 8

Therefore for all w in T_1, we have the following cases (all values are mod 8)

0+0+0 = 0
0+0+1 = 1
0+1+1 = 2
1+1+1 = 3
4+0+0 = 4
4+0+1 = 5
4+1+1 = 6

so like.. i think I already have shown what it takes to prove it. But I don't know how to form this into an inductive proof. Particularly weak induction where I need an inductive base, and inductive hypothesis, and inductive step. My base would be T_0 proof, but I don't know where I would go from there. So yeah, any help with that would be awesome

Acrofales
Profile Joined August 2010
Spain18108 Posts
March 27 2017 21:56 GMT
#17270
Assume it holds for T_n, and use that to prove it holds for T_n+1
Deleted User 3420
Profile Blog Joined May 2003
24492 Posts
March 27 2017 22:05 GMT
#17271
ohhhhhhhhhh right thanks
Deleted User 3420
Profile Blog Joined May 2003
24492 Posts
Last Edited: 2017-03-28 21:28:10
March 28 2017 19:55 GMT
#17272
I have a quiz on dynamic memory allocation tomorrow and I am a bit behind so I am reviewing.

+ Show Spoiler +

Implement the append function that has the prototype below. The function returns a string that represents
the concatenation of all the strings present in an array of strings. For this problem, you can assume the end
of the parameter array is marked by NULL. You need to allocate memory for the resulting string. You may
not modify the array parameter.
char* append(char *data[]);


Is this how you do that? Handwriting, not testing any of these yet.

+ Show Spoiler +


char* append(char *data[]) {
size = 0;
index = 0;
char *appendvalue;

while(data != NULL) {
size = strlen(data[index]) + size;
index++
}

appendvalue = malloc(size + 1)

index = 0;
while(data != NULL) {
strcat(appendvalue, data[index]);
index++
}

return appendvalue;
}




ok now please take it easy on me... very little experience in this realm. I have a feeling I am screwing multiple things up. Such as if I am even using strcat right (I get confused about the actual difference between how C treats a character array vs a char pointer. Also i suspect that the better way to do this may to use realloc in my first while loop and I wouldn't need a second while loop?

Or maybe I am just super super off base with all of this and am so far off that a hero can swoop in and save me?

Anyways thanks all for your time.

edit: more

+ Show Spoiler +

The following C statement creates an array of 14 characters.
char *desc = (char *) malloc(sizeof(char) * 14);
Indicate whether the code can be simplified or not. If the code cannot be simplified indicate NO. If it can be
simplified rewrite the code below.


change it to malloc(14) ?

last one:

+ Show Spoiler +

The following structures are used for these questions.

#define MAX_LEN 80
typedef struct {
char *title;
int duration;
} Song;
typedef struct {
Song* all_songs; /* array of songs */
int number_of_songs;
char album_name[MAX_LEN + 1];
} Album;

a. Given two Song structures s1 and s2, are there any problems with assigning one structure to another? Is
deep copying taking place during the assignment of these two structures?
b. Define a function that initializes a Song using a duration and a string provided. The function will make a
copy of the string parameter.
c. Define a function that will initialize an Album structure based on an array of Songs provided as parameter.
The function will create a dynamically-allocated array of Songs and will initialize each entry with a copy of
the corresponding song in the parameter array. Feel free to add to the function any parameters you
understand are needed.



+ Show Spoiler +

a.) is there a problem in that when everything is copied, the pointers are copied, which could lead to problems, since we can't independently change the songs in one album without changing the songs in the other?

b.)


Song init_song(int d, char *s) {
Song song;
strcopy(song.title, s);
song.duration = d;
return song;
}

//eh... this easy?


c.)

Album init_album(Song *songs) {
Album album;
album.album_name = "they didn't say anything about this";

//I don't know how to assign the songs.
//I don't even know how to tell when I have hit the last song. I mean I go through them with pointer //incrementation, right? But how do I know when I am past the last song? Does the pointer become //null?


thanks
Nesserev
Profile Blog Joined January 2011
Belgium2760 Posts
Last Edited: 2017-03-28 22:17:20
March 28 2017 21:40 GMT
#17273
--- Nuked ---
Deleted User 3420
Profile Blog Joined May 2003
24492 Posts
Last Edited: 2017-03-28 21:56:48
March 28 2017 21:54 GMT
#17274
Nesserev, first, thank you for the comprehensive review of my code.

Quick question - what is the actual purpose of casting malloc? Isn't it just a chunk of memory?

People seem to be arguing about it here: http://stackoverflow.com/questions/605845/do-i-cast-the-result-of-malloc

But I don't understand why a chunk of memory needs a type anyways! Isn't it getting it's type by being assigned to something?

edit: I guess the malloc function returns a pointer. so me calling it "just a chunk of memory" is clearly incorrect.
Biolunar
Profile Joined February 2012
Germany224 Posts
March 28 2017 21:58 GMT
#17275
Casting the return value of malloc is a bad idea. void* will be implicitly converted into any other pointer type, so don’t cast it.
What is best? To crush the Zerg, see them driven before you, and hear the lamentations of the Protoss.
Nesserev
Profile Blog Joined January 2011
Belgium2760 Posts
Last Edited: 2017-03-28 22:21:37
March 28 2017 22:14 GMT
#17276
--- Nuked ---
Deleted User 3420
Profile Blog Joined May 2003
24492 Posts
March 28 2017 22:21 GMT
#17277
While I have got you guys, could you take a look at the 4th spoiler? I feel more confident since I was in the ballpark on the first one, but I am really unsure what to do for this question.
Blitzkrieg0
Profile Blog Joined August 2010
United States13132 Posts
March 28 2017 22:28 GMT
#17278
On March 29 2017 06:58 Biolunar wrote:
Casting the return value of malloc is a bad idea. void* will be implicitly converted into any other pointer type, so don’t cast it.


I've always seen casting malloc as part of the coding standard. While pointless it is a sanity check.
I'll always be your shadow and veil your eyes from states of ain soph aur.
Nesserev
Profile Blog Joined January 2011
Belgium2760 Posts
Last Edited: 2017-03-28 23:47:35
March 28 2017 23:38 GMT
#17279
--- Nuked ---
TMG26
Profile Joined July 2012
Portugal2017 Posts
March 29 2017 14:02 GMT
#17280
On March 29 2017 07:28 Blitzkrieg0 wrote:
Show nested quote +
On March 29 2017 06:58 Biolunar wrote:
Casting the return value of malloc is a bad idea. void* will be implicitly converted into any other pointer type, so don’t cast it.


I've always seen casting malloc as part of the coding standard. While pointless it is a sanity check.


It's also recommended in older C standards.
Supporter of the situational Blink Dagger on Storm.
Prev 1 862 863 864 865 866 1032 Next
Please log in or register to reply.
Live Events Refresh
LAN Event
18:00
Day 3: Ursa 2v2, FFA
SteadfastSC341
IndyStarCraft 173
LiquipediaDiscussion
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
mouzHeroMarine 461
SteadfastSC 341
IndyStarCraft 173
White-Ra 151
UpATreeSC 149
ProTech122
Railgan 44
MindelVK 34
ROOTCatZ 15
StarCraft: Brood War
Shuttle 454
BRAT_OK 69
scan(afreeca) 32
Shine 7
ivOry 5
Dota 2
qojqva3461
Dendi1022
Counter-Strike
pashabiceps824
Heroes of the Storm
Liquid`Hasu247
Other Games
FrodaN1350
fl0m758
Beastyqt582
Mlord517
ceh9442
KnowMe194
ArmadaUGS173
C9.Mang092
Mew2King77
Trikslyr55
shahzam7
OptimusSC21
Organizations
Counter-Strike
PGL125
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 20 non-featured ]
StarCraft 2
• Reevou 13
• Adnapsc2 9
• Dystopia_ 0
• Kozan
• sooper7s
• AfreecaTV YouTube
• Migwel
• LaughNgamezSOOP
• intothetv
• IndyKCrew
StarCraft: Brood War
• STPLYoutube
• ZZZeroYoutube
• BSLYoutube
Dota 2
• C_a_k_e 2940
• Ler90
League of Legends
• Nemesis2245
• TFBlade918
Other Games
• imaqtpie1157
• WagamamaTV313
• Shiphtur223
Upcoming Events
OSC
1h 59m
Replay Cast
2h 59m
OSC
15h 59m
LAN Event
18h 59m
Korean StarCraft League
1d 6h
CranKy Ducklings
1d 13h
LAN Event
1d 18h
IPSL
1d 21h
dxtr13 vs OldBoy
Napoleon vs Doodle
BSL 21
1d 23h
Gosudark vs Kyrie
Gypsy vs Sterling
UltrA vs Radley
Dandy vs Ptak
Replay Cast
2 days
[ Show More ]
Sparkling Tuna Cup
2 days
WardiTV Korean Royale
2 days
LAN Event
2 days
IPSL
2 days
JDConan vs WIZARD
WolFix vs Cross
BSL 21
2 days
spx vs rasowy
HBO vs KameZerg
Cross vs Razz
dxtr13 vs ZZZero
Replay Cast
3 days
Wardi Open
3 days
WardiTV Korean Royale
4 days
Replay Cast
5 days
Kung Fu Cup
5 days
Classic vs Solar
herO vs Cure
Reynor vs GuMiho
ByuN vs ShoWTimE
Tenacious Turtle Tussle
6 days
The PondCast
6 days
RSL Revival
6 days
Solar vs Zoun
MaxPax vs Bunny
Kung Fu Cup
6 days
WardiTV Korean Royale
6 days
Liquipedia Results

Completed

BSL 21 Points
SC4ALL: StarCraft II
Eternal Conflict S1

Ongoing

C-Race Season 1
IPSL Winter 2025-26
KCM Race Survival 2025 Season 4
SOOP Univ League 2025
YSL S2
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
Esports World Cup 2025

Upcoming

BSL Season 21
SLON Tour Season 2
BSL 21 Non-Korean Championship
Acropolis #4
HSC XXVIII
RSL Offline Finals
WardiTV 2025
RSL Revival: Season 3
Stellar Fest
META Madness #9
BLAST Bounty Winter 2026: Closed Qualifier
eXTREMESLAND 2025
ESL Impact League Season 8
SL Budapest Major 2025
BLAST Rivals Fall 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.