• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 06:07
CET 11:07
KST 19:07
  • 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 Liquid Map Contest #22 - Presented by Monster Energy5ByuL: The Forgotten Master of ZvT30Behind the Blue - Team Liquid History Book19Clem wins HomeStory Cup 289HomeStory Cup 28 - Info & Preview13
Community News
Blizzard Classic Cup @ BlizzCon 2026 - $100k prize pool31Weekly 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
The PondCast: SC2 News & Results Mutation # 517 Distant Threat Mutation # 516 Specter of Death Mutation # 515 Together Forever
Brood War
General
ASL21 General Discussion BGH Auto Balance -> http://bghmmr.eu/ Gypsy to Korea JaeDong's form before ASL BSL Season 22
Tourneys
[Megathread] Daily Proleagues [BSL22] Open Qualifiers & Ladder Tours Small VOD Thread 2.0 IPSL Spring 2026 is here!
Strategy
Simple Questions, Simple Answers Soma's 9 hatch build from ASL Game 2 Fighting Spirit mining rates
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
Five o'clock TL Mafia Mafia Game Mode Feedback/Ideas Vanilla Mini Mafia TL Mafia Community Thread
Community
General
US Politics Mega-thread Things Aren’t Peaceful in Palestine Canadian Politics Mega-thread Russo-Ukrainian War Thread Mexico's Drug War
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
The Automated Ban List
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: 5248 users

The Big Programming Thread - Page 591

Forum Index > General Forum
Post a Reply
Prev 1 589 590 591 592 593 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.
sabas123
Profile Blog Joined December 2010
Netherlands3122 Posts
February 21 2015 14:16 GMT
#11801
im doing this sdl tutorial in C about displaying a img on a window but the compiler is mean to meT_T

does anybody know how I can compile with sdl_image libary? I can't find anything that works
The harder it becomes, the more you should focus on the basics.
Ropid
Profile Joined March 2009
Germany3557 Posts
February 21 2015 14:26 GMT
#11802
What do you type to compile and what's the error message?
"My goal is to replace my soul with coffee and become immortal."
sabas123
Profile Blog Joined December 2010
Netherlands3122 Posts
February 21 2015 14:36 GMT
#11803
compile command: gcc newmain.c `pkg-config --cflags --libs sdl2` -lSDL_image

fatal error: SDL_image.h: No such file or directory
The harder it becomes, the more you should focus on the basics.
Ropid
Profile Joined March 2009
Germany3557 Posts
Last Edited: 2015-02-21 14:49:45
February 21 2015 14:45 GMT
#11804
The compiler has a list of directories it looks at for header files that you use like this in your source code:

#include <bla.h>

You can add a directory to the compiler's list through -I. That -ISDL_image means you tell it to search in a sub-directory "SDL_image" from where you are currently.

If you use this in your source code:

#include "bla.h"

That will search for bla.h in the same directory as where your source is.
"My goal is to replace my soul with coffee and become immortal."
sabas123
Profile Blog Joined December 2010
Netherlands3122 Posts
February 21 2015 14:48 GMT
#11805
On February 21 2015 23:45 Ropid wrote:
The compiler has a list of directories it looks at for header files that you use like this in your source code:

#include <bla.h>

You can add a directory to the compiler's list through -I. That -ISDL_image means you tell it to search in a sub-directory "SDL_image" from where you are currently.

If you use this in your source code:

#include "bla.h"

That will search for bla.h in the same directory as where your source is.

aaahhh thank you, I geuss I have to search for the libary location then.
The harder it becomes, the more you should focus on the basics.
Ropid
Profile Joined March 2009
Germany3557 Posts
Last Edited: 2015-02-21 14:54:53
February 21 2015 14:49 GMT
#11806
On February 21 2015 23:48 sabas123 wrote:
Show nested quote +
On February 21 2015 23:45 Ropid wrote:
The compiler has a list of directories it looks at for header files that you use like this in your source code:

#include <bla.h>

You can add a directory to the compiler's list through -I. That -ISDL_image means you tell it to search in a sub-directory "SDL_image" from where you are currently.

If you use this in your source code:

#include "bla.h"

That will search for bla.h in the same directory as where your source is.

aaahhh thank you, I geuss I have to search for the libary location then.

I just tried that pkg-config you use on my machine here and it looks like this:

$ pkg-config --cflags --libs sdl2
-D_REENTRANT -I/usr/include/SDL2 -lSDL2 -lpthread

That seems to list everything that should be needed for me. What's happening for you? How does the output look like?

EDIT: But I just found out, if you're after SDL_image.h, that one is in another directory as it's SDL and not SDL2, so the options for it get found through:

$ pkg-config --cflags --libs sdl
-D_GNU_SOURCE=1 -D_REENTRANT -I/usr/include/SDL -lSDL -lpthread

I see there's also another sdl2_image package on my Linux distro, not just sdl_image. Both have a SDL_image.h file in them. Perhaps you installed the wrong package?
"My goal is to replace my soul with coffee and become immortal."
sabas123
Profile Blog Joined December 2010
Netherlands3122 Posts
February 21 2015 14:57 GMT
#11807
I found the error.

I had libsdl1.2-image-dev and libsdl2-image but not libsdl2-image-dev

that took me 2 hoursT_T
The harder it becomes, the more you should focus on the basics.
nunez
Profile Blog Joined February 2011
Norway4003 Posts
February 21 2015 15:35 GMT
#11808
noob!
conspired against by a confederacy of dunces.
sabas123
Profile Blog Joined December 2010
Netherlands3122 Posts
February 21 2015 16:11 GMT
#11809
On February 22 2015 00:35 nunez wrote:
noob!

+ Show Spoiler +
[image loading]
The harder it becomes, the more you should focus on the basics.
sabas123
Profile Blog Joined December 2010
Netherlands3122 Posts
February 21 2015 20:11 GMT
#11810
trying to understand mergesort made me realize somethings are still confusing as hell T_T

+ Show Spoiler +
void merge(int *arr, int size1, int size2) {
int temp[size1+size2];
int ptr1=0, ptr2=0;

while (ptr1+ptr2 < size1+size2) {
if (ptr1 < size1 && arr[ptr1] <= arr[size1+ptr2] || ptr1 < size1 && ptr2 >= size2)
temp[ptr1+ptr2] = arr[ptr1++];

if (ptr2 < size2 && arr[size1+ptr2] < arr[ptr1] || ptr2 < size2 && ptr1 >= size1)
temp[ptr1+ptr2] = arr[size1+ptr2++];
}

for (int i=0; i < size1+size2; i++)
arr[i] = temp[i];
}

void mergeSort(int *arr, int size) {
if (size == 1)
return;

int size1 = size/2, size2 = size-size1;
mergeSort(arr, size1);
mergeSort(arr+size1, size2);
merge(arr, size1, size2);
}

The harder it becomes, the more you should focus on the basics.
Azerbaijan
Profile Blog Joined January 2010
United States660 Posts
February 22 2015 09:49 GMT
#11811
Any erlang programmers here? I am considering using erlang for my university capstone project and am not sure what I am thinking of doing is feasible.
Cynry
Profile Blog Joined August 2010
810 Posts
February 22 2015 09:58 GMT
#11812
On February 22 2015 05:11 sabas123 wrote:
trying to understand mergesort made me realize somethings are still confusing as hell T_T

+ Show Spoiler +
void merge(int *arr, int size1, int size2) {
int temp[size1+size2];
int ptr1=0, ptr2=0;

while (ptr1+ptr2 < size1+size2) {
if (ptr1 < size1 && arr[ptr1] <= arr[size1+ptr2] || ptr1 < size1 && ptr2 >= size2)
temp[ptr1+ptr2] = arr[ptr1++];

if (ptr2 < size2 && arr[size1+ptr2] < arr[ptr1] || ptr2 < size2 && ptr1 >= size1)
temp[ptr1+ptr2] = arr[size1+ptr2++];
}

for (int i=0; i < size1+size2; i++)
arr[i] = temp[i];
}

void mergeSort(int *arr, int size) {
if (size == 1)
return;

int size1 = size/2, size2 = size-size1;
mergeSort(arr, size1);
mergeSort(arr+size1, size2);
merge(arr, size1, size2);
}


What's your issue with this one ? Recursivity ?
Blisse
Profile Blog Joined July 2010
Canada3710 Posts
Last Edited: 2015-02-22 10:44:05
February 22 2015 10:26 GMT
#11813
On February 22 2015 05:11 sabas123 wrote:
trying to understand mergesort made me realize somethings are still confusing as hell T_T

+ Show Spoiler +
void merge(int *arr, int size1, int size2) {
int temp[size1+size2];
int ptr1=0, ptr2=0;

while (ptr1+ptr2 < size1+size2) {
if (ptr1 < size1 && arr[ptr1] <= arr[size1+ptr2] || ptr1 < size1 && ptr2 >= size2)
temp[ptr1+ptr2] = arr[ptr1++];

if (ptr2 < size2 && arr[size1+ptr2] < arr[ptr1] || ptr2 < size2 && ptr1 >= size1)
temp[ptr1+ptr2] = arr[size1+ptr2++];
}

for (int i=0; i < size1+size2; i++)
arr[i] = temp[i];
}

void mergeSort(int *arr, int size) {
if (size == 1)
return;

int size1 = size/2, size2 = size-size1;
mergeSort(arr, size1);
mergeSort(arr+size1, size2);
merge(arr, size1, size2);
}



does your code work? what's with the ptr1 >= size1, that will never happen
There is no one like you in the universe.
spinesheath
Profile Blog Joined June 2009
Germany8679 Posts
Last Edited: 2015-02-22 12:58:16
February 22 2015 10:55 GMT
#11814
Don't call stuff "ptr". What's that? "pointer", "peter", "pastor", "petrol"? Give your variables proper names. It's not even a pointer to begin with.
Don't do stuff like arr[size1+ptr2++]. What's even worse: temp[ptr1+ptr2] = arr[size1+ptr2++]. What's evaluated first, the left side array index or the right side postfix increment? Sure, it's properly defined, but that doesn't make it a good idea to write stuff like that.

I'd assume you'd be less confused if you didn't try to be so fancy.
If you have a good reason to disagree with the above, please tell me. Thank you.
Blisse
Profile Blog Joined July 2010
Canada3710 Posts
Last Edited: 2015-02-23 07:10:58
February 22 2015 12:52 GMT
#11815
reformatted your code to how i would write it (kinda)

really just need to clean up the code and it should be a lot easier to read through

+ Show Spoiler +

void merge(int* outArray, int aSize, int bSize) 
{
int outArraySize = aSize + bSize;
int tempArray[outArraySize];
int aIndex = 0;
int bIndex = 0;

while (aIndex + bIndex < outArraySize)
{
if (aIndex < aSize)
{
if ((outArray[aIndex] <= outArray[aSize+bIndex]) || (bIndex == bSize))
{
tempArray[aIndex + bIndex] = outArray[aIndex];
aIndex += 1;
}
}

if (bIndex < bSize)
{
if ((outArray[aIndex] > outArray[aSize + bIndex]) || (aIndex == aSize))
{
tempArray[aIndex + bIndex] = outArray[aSize + bIndex];
bIndex += 1;
}
}
}

for (int i = 0; i < outArraySize; ++i)
{
outArray[i] = tempArray[i];
}
}

void mergeSort(int* array, int size)
{
if (size == 1)
{
return;
}

int size1 = size/2;
int size2 = (size/2) + 1;
mergeSort(array, size1);
mergeSort(array+size1, size2);
merge(array, size1, size2);
}


There is no one like you in the universe.
spinesheath
Profile Blog Joined June 2009
Germany8679 Posts
Last Edited: 2015-02-22 12:57:48
February 22 2015 12:56 GMT
#11816
Duh, you already fixed it. Now I have nothing to say here.
If you have a good reason to disagree with the above, please tell me. Thank you.
Blisse
Profile Blog Joined July 2010
Canada3710 Posts
Last Edited: 2015-02-22 13:02:01
February 22 2015 12:58 GMT
#11817
On February 22 2015 21:56 spinesheath wrote:
Duh, you already fixed it. Now I have nothing to say here.


:p


we should have like a "critique my code" thingie every once in a while
There is no one like you in the universe.
sabas123
Profile Blog Joined December 2010
Netherlands3122 Posts
February 22 2015 14:14 GMT
#11818
On February 22 2015 21:58 Blisse wrote:
Show nested quote +
On February 22 2015 21:56 spinesheath wrote:
Duh, you already fixed it. Now I have nothing to say here.


:p


we should have like a "critique my code" thingie every once in a while

ye that is a really good idea.

the code I posted was a tutorial i got somewhere because I got to frustated after my own code not working after like 10 times lol.

the part that confuses me about that program is when the merge is called. this is how i under stand it

you give mergsort an array, -> it splits it and calls its self to infinty till there are only 2 in the array left - > starts merging.
but wont it will just a unsorted array for each time it called itself, and when it is sorted it has only 2 numbers to merge.
The harder it becomes, the more you should focus on the basics.
nunez
Profile Blog Joined February 2011
Norway4003 Posts
Last Edited: 2015-02-22 15:00:16
February 22 2015 14:43 GMT
#11819
On February 22 2015 19:55 spinesheath wrote:
Don't call stuff "ptr". What's that? "pointer", "peter", "pastor", "petrol"? Give your variables proper names. It's not even a pointer to begin with.
Don't do stuff like arr[size1+ptr2++]. What's even worse: temp[ptr1+ptr2] = arr[size1+ptr2++]. What's evaluated first, the left side array index or the right side postfix increment? Sure, it's properly defined, but that doesn't make it a good idea to write stuff like that.

I'd assume you'd be less confused if you didn't try to be so fancy.


i'd prefer ptr (pronouned: ptr) to pointer if you are writing c++, it conforms to the standard and is terser.
std::unique_ptr, std::shared_ptr, std::weak_ptr, etc...

your other point is good and is worth a peep. this point is valid only as it pertains to evaluation order, and not precedence, or expressions in general. i avoid it myself, i am not familiar enough to resolve ambiguities for now.

@ropid
i get that partiucal kind of programming pleasure from only using
#include<...>, so i always do -I./ in my projects.
conspired against by a confederacy of dunces.
Ropid
Profile Joined March 2009
Germany3557 Posts
February 22 2015 17:52 GMT
#11820
On February 22 2015 23:14 sabas123 wrote:
Show nested quote +
On February 22 2015 21:58 Blisse wrote:
On February 22 2015 21:56 spinesheath wrote:
Duh, you already fixed it. Now I have nothing to say here.


:p


we should have like a "critique my code" thingie every once in a while

ye that is a really good idea.

the code I posted was a tutorial i got somewhere because I got to frustated after my own code not working after like 10 times lol.

the part that confuses me about that program is when the merge is called. this is how i under stand it

you give mergsort an array, -> it splits it and calls its self to infinty till there are only 2 in the array left - > starts merging.
but wont it will just a unsorted array for each time it called itself, and when it is sorted it has only 2 numbers to merge.

You could think of it as some sort of math.

Look at this:

sort FHDCEAGB
= merge (sort FHDC) (sort EAGB)
= merge (merge (sort FH) (sort DC)) (sort EAGB)
= merge (merge (merge (sort F) (sort H)) (sort DC)) (sort EAGB)
= merge (merge (merge F H) (sort DC)) (sort EAGB)
= merge (merge FH (sort DC)) (sort EAGB)
= merge (merge FH (merge (sort D) (sort C))) (sort EAGB)
= merge (merge FH (merge D C)) (sort EAGB)
= merge (merge FH CD) (sort EAGB)
= merge CDFH (sort EAGB)
= merge CDFH (merge (sort EA) (sort GB))
= merge CDFH (merge (merge (sort E) (sort A)) (sort GB))
= merge CDFH (merge (merge E A) (sort GB))
= merge CDFH (merge AE (sort GB))
= merge CDFH (merge AE (merge (sort G) (sort B)))
= merge CDFH (merge AE (merge G B))
= merge CDFH (merge AE BG)
= merge CDFH ABEG
= ABCDEFGH

I regret starting with 8 elements and not just 4. T_T

An alternative is thinking about it visually as some sort of tree graph that gets built up by the sort function and collapsed by the merge function. You could draw that on paper or something.

You could also think about what's happening on the stack. That's what helped me with recursion. The local variables of functions are living inside layers on the stack. Each function call adds a new layer on top, returning from a function deletes that layer. Parameters are the same as variables (and you can btw. even use them and overwrite them in C).
"My goal is to replace my soul with coffee and become immortal."
Prev 1 589 590 591 592 593 1032 Next
Please log in or register to reply.
Live Events Refresh
RSL Revival
10:00
Season 4: Playoffs Day 2
herO vs MaxPax
Rogue vs TriGGeR
Tasteless384
CranKy Ducklings45
Rex29
LiquipediaDiscussion
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
Tasteless 384
ProTech130
Rex 29
StarCraft: Brood War
Sea 19966
Calm 5917
Hyuk 2886
Jaedong 1349
Horang2 1234
Mong 476
Larva 461
Hm[arnc] 427
BeSt 371
actioN 252
[ Show more ]
EffOrt 151
Light 89
Soma 89
Pusan 74
Rush 74
ZerO 56
Yoon 54
Aegong 41
Mind 38
sorry 36
NotJumperer 31
zelot 25
Barracks 25
GoRush 25
Free 25
ToSsGirL 25
hero 21
Noble 18
Last 16
910 16
Terrorterran 13
Bale 12
SilentControl 5
eros_byul 0
Dota 2
XaKoH 1144
XcaliburYe203
Counter-Strike
Stewie2K1051
zeus523
Heroes of the Storm
MindelVK16
Other Games
singsing1811
Fuzer 200
Sick162
ZerO(Twitch)11
Organizations
Other Games
gamesdonequick575
Dota 2
PGL Dota 2 - Main Stream115
Other Games
BasetradeTV51
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 14 non-featured ]
StarCraft 2
• Berry_CruncH248
• 3DClanTV 23
• CranKy Ducklings SOOP4
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
League of Legends
• HappyZerGling139
Upcoming Events
BSL
9h 54m
Replay Cast
13h 54m
Replay Cast
22h 54m
Afreeca Starleague
23h 54m
Sharp vs Scan
Rain vs Mong
Wardi Open
1d 1h
Monday Night Weeklies
1d 6h
Sparkling Tuna Cup
1d 23h
Afreeca Starleague
1d 23h
Soulkey vs Ample
JyJ vs sSak
Replay Cast
2 days
Afreeca Starleague
2 days
hero vs YSC
Larva vs Shine
[ Show More ]
Kung Fu Cup
3 days
Replay Cast
3 days
KCM Race Survival
3 days
The PondCast
3 days
WardiTV Team League
4 days
Replay Cast
4 days
WardiTV Team League
5 days
RSL Revival
5 days
Cure vs Zoun
WardiTV Team League
6 days
BSL
6 days
RSL Revival
6 days
ByuN vs Maru
Liquipedia Results

Completed

Jeongseon Sooper Cup
WardiTV Winter 2026
Underdog Cup #3

Ongoing

KCM Race Survival 2026 Season 1
BSL Season 22
CSL Elite League 2026
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

ASL Season 21
Acropolis #4 - TS6
2026 Changsha Offline CUP
CSL 2026 SPRING (S20)
CSL Season 20: Qualifier 1
Acropolis #4
IPSL Spring 2026
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.