• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 10:51
CEST 16:51
KST 23:51
  • 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
[ASL22] Ro24 Preview: Siren's Call8[ASL22] Ro24 Preview: Summer's End9Serral wins HomeStory Cup 2915Serral wins Maestros of the Game 244ByuL, and the Limitations of Standard Play3
Community News
Stellar Fest TWO the Moon (Dec 16-20)8Weekly Cups (August 24-30): Patches' balance mod takes over2New 3v3 BGH Ladder (and more) on ShieldBattery!40Weekly Cups (August 17-23): Zerg dominate the week6Weekly Cups (August 10-16): SHIN doubles5
StarCraft 2
General
Nexon wins bid to develop StarCraft IP content, distribute Overwatch mobile game Balance hotfix patch 5.0.16b (July 16) September World Ranking: herO leads, Serral climbs Weekly Cups (August 10-16): SHIN doubles SC4ALL II: SC2 Player Announcement 6/8 - Maru
Tourneys
IntoTheTV X SOOP SC2 League : Weekly & Monthly SC2 INu's Battles#20 [BO.9] 2026 GSTL Announcement Stellar Fest TWO the Moon (Dec 16-20) PIG STY FESTIVAL 8.0! (13 - 23 August)
Strategy
[G] Having the right mentality to improve
Custom Maps
Nexus Wars 2021 GUIDE [M] (2) Industrial Park
External Content
Mutation # 541 Binary Choice The PondCast: SC2 News & Results Mutation # 540 Dodge This Mutation # 539 Thunder Dome
Brood War
General
BW General Discussion BGH Auto Balance -> http://bghmmr.eu/ Making an Online Broodwar Manager Game ASL22 General Discussion [Personal Project Share] Terran Defense v0.60
Tourneys
KCM Race Survival 2026 Season 3 [Megathread] Daily Proleagues BSL LAN Party - Kraków 29-30 August - OPEN SIGNUPS [ASL22] Ro24 Group F
Strategy
Replay Review Process - What do you do? Game Theory for Starcraft Odyssey Mineral Stack Saturation Fighting Spirit mining rates
Other Games
General Games
Nintendo Switch Thread [Maplestory Hardcore] Let's Play~!! General RTS Discussion Thread Stratus: Battle for the sky now on steam Early acc Stormgate/Frost Giant Megathread
Dota 2
Official 'what is Dota anymore' discussion
League of Legends
[TL LoL EUW IHs] Teemo shall perish TSM pausing esports and CLG Dead
Heroes of the Storm
Heroes of the Storm 2.0
Hearthstone
Deck construction bug
TL Mafia
TL Mafia Power Rank TL Mafia Community Thread NeO.D_StephenKing vs This Guy From 1 Million Dance
Community
General
US Politics Mega-thread Things Aren’t Peaceful in Palestine Russo-Ukrainian War Thread Canadian Politics Mega-thread European Politico-economics QA Mega-thread
Fan Clubs
MarineLorD Fan Club The Creator Fan Club The ShoWTimE Fan Club
Media & Entertainment
Movie Discussion! Anime Discussion Thread
Sports
Football (Soccer) Thread TeamLiquid Health and Fitness Initiative For 2023 MLB/Baseball 2023 NBA General Discussion
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
The Automated Ban List Northern Ireland Global Starcraft
Blogs
Regacy Esports: The Bh…
regacyesports
Violent Games and Crime Rate…
TrAiDoS
LOCKPICKING NOOB
LUCKY_NOOB
Cathedral Of CS And NY pizza a…
FuDDx
Please support my new stand…
Peanutsc
Customize Sidebar...

Website Feedback

Closed Threads



Active: 8175 users

The Big Programming Thread - Page 386

Forum Index > General Forum
Post a Reply
Prev 1 384 385 386 387 388 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.
RoyGBiv_13
Profile Blog Joined August 2010
United States1275 Posts
Last Edited: 2013-11-04 20:03:35
November 04 2013 19:57 GMT
#7701
To feanorian,

I saw your question in the IRC some days ago but wasn't online when you sent it.

What you want is:
char * const * c_string_pointer

Why?
My technique for reading declarations in C is the "backwards" rule. I read from right to left, where each type-qualifier,volatile or const modifies the type immediately after it if its a pointer, or before it if its a type. Watch:
char * const * c_string_pointer
C_string_pointer is a pointer to a constant pointer of type char


With arrays and functions, you use the clockwise inside-to-outside rule, it can get very confusing for difficult, long functions or array types.

volatile foo * const * bar[len];

bar is an array of length len of pointers to constant pointers to a volatile foo.

int * volatile bar(char * const foo[])

bar is a volatile pointer to function with one argument, foo, which is an array of constant pointers to char, which returns an int.
Any sufficiently advanced technology is indistinguishable from magic
CorsairHero
Profile Joined December 2008
Canada9491 Posts
November 04 2013 21:34 GMT
#7702
On November 05 2013 04:02 obesechicken13 wrote:
I'm having some problems with a website. Sitegrounds says we are going over the CPU load available for our site. We upgraded and are still going over and sitegrounds is shutting us down.

It's definitely a cron issue rather than a visitors issue. All of the problems occur at 1AM or 2AM. HTTP CPU load is low but Cron CPU usage is high.
[image loading]

These cron job times are wrong. Add one hour for each one. Eg if it says it runs at 4:30, it really runs at 5:30 my time. Timezones.
[image loading]

How do I debug this?
I've looked at the error logs file and there's nothing from this month in it.
Which files should I be looking at?

Run each cron job one at a time and look at cpu usage?

ps -p <PID> -o %cpu,%mem,cmd

Not the most elegant way, but you don't have that many cronjobs
© Current year.
obesechicken13
Profile Blog Joined July 2008
United States10467 Posts
Last Edited: 2013-11-05 04:31:20
November 05 2013 04:28 GMT
#7703
On November 05 2013 06:34 CorsairHero wrote:
Show nested quote +
On November 05 2013 04:02 obesechicken13 wrote:
I'm having some problems with a website. Sitegrounds says we are going over the CPU load available for our site. We upgraded and are still going over and sitegrounds is shutting us down.

It's definitely a cron issue rather than a visitors issue. All of the problems occur at 1AM or 2AM. HTTP CPU load is low but Cron CPU usage is high.
[image loading]

These cron job times are wrong. Add one hour for each one. Eg if it says it runs at 4:30, it really runs at 5:30 my time. Timezones.
[image loading]

How do I debug this?
I've looked at the error logs file and there's nothing from this month in it.
Which files should I be looking at?

Run each cron job one at a time and look at cpu usage?

ps -p <PID> -o %cpu,%mem,cmd

Not the most elegant way, but you don't have that many cronjobs

Thought about that but then I noticed I couldn't run ps -p since I'm on a shared server.

I eventually realized there was something wrong with the sitegrounds reporting. Thank you to everyone who took the time to read what I wrote.

Sitegrounds defines CPU time as number of seconds used by a machine in any given hour. By that graph, I used 4.5million seconds of CPU in that one hour. Can't blame them, I'd cancel someone's account too if they were somehow breaking the time continuum to get more internet from me.

Tip('CPU time or CPU usage is the amount of time (in seconds)<br> a computer program uses in processing CPU instructions.<br> No Customer is allowed to use more than 20000 CPU Seconds<br> for any given calendar day. No Customer is allowed to use more<br> than 2000 CPU Seconds for any given hour of the day.<br><br><b>The hourly and daily statistics are being updated<br>each hour')
I think in our modern age technology has evolved to become more addictive. The things that don't give us pleasure aren't used as much. Work was never meant to be fun, but doing it makes us happier in the long run.
sluggaslamoo
Profile Blog Joined November 2009
Australia4494 Posts
November 05 2013 04:51 GMT
#7704
On November 05 2013 02:26 ObliviousNA wrote:
What's a good OpenGL book? I have a decent background in it, but I want to learn the modern/correct way of doing things.

Considering:
http://www.amazon.com/OpenGL-Programming-Guide-Official-Learning/dp/0321773039/ref=sr_1_1?ie=UTF8&qid=1383584858&sr=8-1&keywords=opengl

http://www.amazon.com/OpenGL-SuperBible-Comprehensive-Reference-ebook/dp/B00E1GL1SO/ref=sr_1_2?ie=UTF8&qid=1383584858&sr=8-2&keywords=opengl

Neither have stellar reviews for their recent versions, which makes me a bit wary. I'm mainly looking for a good description of API and best practices with a refresher on the math.

Also, if someone could speak to the formatting/support for their e-books (with a smaller screen like the nex 7) that would be great!


The red book definitely, you won't find anything as comprehensive online. Also its really big, but you don't have to read it from front to back if you know what it is you need to learn.
Come play Android Netrunner - http://www.teamliquid.net/forum/viewmessage.php?topic_id=409008
Reggiegigas
Profile Joined August 2010
234 Posts
November 05 2013 09:07 GMT
#7705
I have a question. C++.

So I want to have a file with various sections, and under each section, there will be sample names separated by commas.

So what I want to happen is that when a character in my game is born, it will open the file and jump to the relevant section and randomly select a name and apply that to the character object.

How do I do this? I only know the basics of ifstream/ofstream.

I want it to be dynamic so if I manually add names to the sections, the program will still be able to determine by itself how many there are in the section, and then to randomly pick one.
Nesserev
Profile Blog Joined January 2011
Belgium2760 Posts
November 05 2013 09:44 GMT
#7706
--- Nuked ---
Reggiegigas
Profile Joined August 2010
234 Posts
November 05 2013 10:25 GMT
#7707
On November 05 2013 18:44 Nesserev wrote:
Well, it all depends on how you format your file...

For example, if you format your sections like these
SECTIONNAME
name1, name2, name3, etc.

You can use the readline function in a while loop to find the appropriate sectionname,
and then use a readline function again to put all the names in a string, and then use a function to process that string into an array/vector of strings...

There are so many ways to do it...


What I had in mind was something like this


**********
** Human Male region1
**********
name1, name2, name3 (...)

(others...)

**********
** Orc Female region2
**********
name1, name2, name3, name4 (...)

(etc)
Nesserev
Profile Blog Joined January 2011
Belgium2760 Posts
November 05 2013 11:00 GMT
#7708
--- Nuked ---
spinesheath
Profile Blog Joined June 2009
Germany8679 Posts
November 05 2013 13:23 GMT
#7709
Load the whole thing into memory once and keep it there. It's highly unlikely that this file would be so large that memory is an issue.

Ideally you would just use XML, no point in implementing a parser for your own format. You'd have to find a simple C++ xml parser.
Something like this:
<section race="human" gender="male" region="TL">
<name>Reggie</name>
<name>Gigas</name>
(more names)
</section>
(more sections)

If you have a good reason to disagree with the above, please tell me. Thank you.
Manit0u
Profile Blog Joined August 2004
Poland17838 Posts
Last Edited: 2013-11-05 17:06:25
November 05 2013 17:03 GMT
#7710
On November 05 2013 19:25 Reggiegigas wrote:
Show nested quote +
On November 05 2013 18:44 Nesserev wrote:
Well, it all depends on how you format your file...

For example, if you format your sections like these
SECTIONNAME
name1, name2, name3, etc.

You can use the readline function in a while loop to find the appropriate sectionname,
and then use a readline function again to put all the names in a string, and then use a function to process that string into an array/vector of strings...

There are so many ways to do it...


What I had in mind was something like this

Show nested quote +

**********
** Human Male region1
**********
name1, name2, name3 (...)

(others...)

**********
** Orc Female region2
**********
name1, name2, name3, name4 (...)

(etc)


http://www.cplusplus.com/reference/map/map/
http://en.wikipedia.org/wiki/Associative_containers_(C )

Just use a mapping and dump it to file. Best way to store data like that. Not only is it human-readable but also usable by the code.

Example:


typedef map < string, list<string> > map_type;

map_type name_map;
list<string> h_m_name_list;

h_m_name_list.pushback("Joe");
h_m_name_list.pushback("Bill);

name_map["h_male_names"] = h_m_name_list;


You could do it with lists, arrays of strings etc. If you dump it to the file it'll look more or less like that:


h_male_names : ({ "Joe", "Bill" })


You can even nest maps inside of maps if you want (at least you can in other languages, been a while since I did something in C++).
Time is precious. Waste it wisely.
CecilSunkure
Profile Blog Joined May 2010
United States2829 Posts
November 05 2013 17:49 GMT
#7711
I agree, keep a copy of the data in memory. Once you need to actually save this memory to a file you can dump it all in one go.
Mataza
Profile Blog Joined August 2010
Germany5364 Posts
November 06 2013 00:41 GMT
#7712
I need like a starter package on C.
(that is just c, not c++ or c#)

Compiler, do I something like JVM to execute c programs, a resource to learn the commands etc.
I would be ever so grateful if someone could point me in the right direction.

For some reason the editors vim and emacs were recommended to me. Haven't really used either yet, but I don't exactly see the point?

If nobody hates you, you´re doing something wrong. However someone hating you doesn´t make you right
RoyGBiv_13
Profile Blog Joined August 2010
United States1275 Posts
November 06 2013 00:52 GMT
#7713
On November 06 2013 09:41 Mataza wrote:
I need like a starter package on C.
(that is just c, not c++ or c#)

Compiler, do I something like JVM to execute c programs, a resource to learn the commands etc.
I would be ever so grateful if someone could point me in the right direction.

For some reason the editors vim and emacs were recommended to me. Haven't really used either yet, but I don't exactly see the point?



C is a minimal language. No need for a virtual machine like the JVM to execute your code in, as it will run directly within your host OS.

For compilers, I recommend using GCC. There are other compilers out there, but GCC is historically the most used. You can find it in the Mingwe (personally preferred) or Cygwin packages for Windows, or if using Linux, it's included by default in 99% of the distros out there.

People recommend vim or emacs as once you've learned them, they are easily the most efficient way to navigate code (arguably for any language). They each were originally built for Linux, but there are ports now for other general purpose operating systems as well such as Windows. I'd guess that what you really want is a familiar development environment to learn an introduction to C. For that, here's a link to my old alma mater's instructions for getting C set up for eclipse on Windows. http://www.rose-hulman.edu/class/csse/resources/Eclipse/eclipse-c-configuration.htm


Any sufficiently advanced technology is indistinguishable from magic
Cyx.
Profile Joined November 2010
Canada806 Posts
November 06 2013 01:43 GMT
#7714
On November 06 2013 09:41 Mataza wrote:
I need like a starter package on C.
(that is just c, not c++ or c#)

Compiler, do I something like JVM to execute c programs, a resource to learn the commands etc.
I would be ever so grateful if someone could point me in the right direction.

For some reason the editors vim and emacs were recommended to me. Haven't really used either yet, but I don't exactly see the point?



Also, as far as editors go, you'll find that having a code browser of some sort with syntax highlighting and all of the other nice things that come with a full IDE is like... REALLY nice for working in C. Sure you can write all your programs in Notepad and compile them with the command line if you feel like... but being able to see typos and things that are just not legal before you even try to compile them is life-saving, and the debugging abilities that IDEs provide you with are also really hard to even imagine working without on anything more than two or three files large.
Zorkmid
Profile Joined November 2008
4410 Posts
November 06 2013 03:46 GMT
#7715
A lot of people that I've talked to say that IDEs are a bad way to learn a language for just that very reason.
RoyGBiv_13
Profile Blog Joined August 2010
United States1275 Posts
November 06 2013 04:24 GMT
#7716
Right tools for the right job...
If you're handling just one .c file and one .h file, a full on IDE is going to confuse you more than help. Notepad++ does code highlighting and a single command in your terminal can run the program without having to learn how to create a new project, manage a makefile, add dependencies, etc...
For writing C, I do so in an editor that is pretty close to notepad.

That being said, a good debugger is worth learning, and using gdb on the command-line is not ideal.

If you think about it, most of your time writing code is spent navigating the code, reading what it does. Nothing has more information about the code than a debugger during run-time. Static analysis will only take you so far in a weakly typed language like C.
Any sufficiently advanced technology is indistinguishable from magic
Nesserev
Profile Blog Joined January 2011
Belgium2760 Posts
November 06 2013 04:42 GMT
#7717
--- Nuked ---
AsmodeusXI
Profile Blog Joined July 2007
United States15536 Posts
November 06 2013 15:31 GMT
#7718
Question for the wizards in here: does anyone have any recommendations for a JavaScript library/framework for games development? I'm interested in doing game creation in HTML5 and there are a LOT of options out there, so I'm looking for some opinions.
WriterTL > RL. BNet: Asmodeus#1187 - LoL: DJForeclosure - Steam: asmodeusxi | www.n3rddimension.com
Cyx.
Profile Joined November 2010
Canada806 Posts
November 06 2013 19:17 GMT
#7719
On November 06 2013 12:46 Zorkmid wrote:
A lot of people that I've talked to say that IDEs are a bad way to learn a language for just that very reason.


And this is why we don't post without fully reading what we're responding to. 0o

don't listen to me, I was responding mostly to the 'why should I use an editor' rather than the 'what tools should I get to learn c' =/
Zorkmid
Profile Joined November 2008
4410 Posts
Last Edited: 2013-11-06 21:03:43
November 06 2013 21:03 GMT
#7720
On November 07 2013 04:17 Cyx. wrote:
Show nested quote +
On November 06 2013 12:46 Zorkmid wrote:
A lot of people that I've talked to say that IDEs are a bad way to learn a language for just that very reason.


And this is why we don't post without fully reading what we're responding to. 0o

don't listen to me, I was responding mostly to the 'why should I use an editor' rather than the 'what tools should I get to learn c' =/


I wasn't really responding to anything you said, just giving one point of view on IDEs as a learning tool. No need for the saltyness.
Prev 1 384 385 386 387 388 1032 Next
Please log in or register to reply.
Live Events Refresh
Next event in 7h 39m
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
ProTech131
Trap 8
StarCraft: Brood War
Shuttle 2869
Horang2 1009
firebathero 892
Rush 430
Stork 314
Sea.KH 86
Pusan 84
Barracks 69
Sexy 46
Terrorterran 29
[ Show more ]
soO 25
sorry 21
910 20
zelot 16
SilentControl 15
IntoTheRainbow 7
Dota 2
Gorgc4337
qojqva2243
Dendi1421
420jenkins297
Counter-Strike
byalli830
Heroes of the Storm
Liquid`Hasu249
Other Games
singsing2106
Liquid`RaSZi591
crisheroes390
B2W.Neo390
Lowko292
DeMusliM289
OGKoka 225
Liquid`VortiX163
Hui .121
ArmadaUGS79
Mew2King57
KnowMe55
QueenE40
Organizations
StarCraft 2
IntoTheiNu 430
[ Show 10 non-featured ]
StarCraft 2
• mYiSmile118
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• Migwel
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
League of Legends
• Nemesis2086
Upcoming Events
OSC
7h 39m
IntoTheTV X SOOP
20h 9m
CranKy Ducklings
1d 19h
Sparkling Tuna Cup
2 days
OSC
2 days
Shopify Rebellion Sundays
3 days
Mixu vs TBD
Spirit vs TBD
Clem vs TBD
Patches Events
3 days
Afreeca Starleague
3 days
Soma vs Shuttle
BeSt vs Rush
WardiTV Weekly
3 days
Afreeca Starleague
4 days
Leta vs ggaemo
Jaedong vs Queen
[ Show More ]
GSL
4 days
PiGosaur Cup
5 days
Kung Fu Cup
5 days
Replay Cast
6 days
The PondCast
6 days
Liquipedia Results

Completed

Proleague 2026-09-02
PiG Sty Festival 8.0
Light Tournament 2026

Ongoing

KCM Race Survival 2026 Season 3
K-JUNGMAN
ASL Season 22
Super Anchor Qualifying S3
CSL 2026 AUTUMN (S22)
RSL Revival: Season 6
Calamity Invitational
Big Dog Cup 2026 Div 1
BLAST Open Fall 2026
Esports World Cup 2026
Esports World Cup 2026: LCQ
BLAST Bounty Summer 2026
BLAST Bounty Summer Qual
Stake Ranked Episode 3
XSE Pro League 2026
IEM Cologne Major 2026

Upcoming

Acropolis #5
Acropolis #5 - TRS
Escore Tournament S3: King of Kings
Blizzard Classic Cup 2026
Acropolis #5 - GSA
Acropolis #5 - GSB
Acropolis #5 - GSC
HSC XXX
Stellar Fest 2: Lunar Cup
SC4ALL II: StarCraft II
Kung Fu Cup 2026 Grand Finals
RSL Offline Finals
BLAST Rivals Fall 2026
IEM Beijing 2026
Stake Ranked Episode 5
PGL Masters Bucharest 2026
1win Private Club #2
Thunderpick World Champ. '26
ESL Pro League Season 24
Stake Ranked Episode 4
1win Private Club #1
Logitech G Play Connect 2026
SL StarSeries Fall 2026
FISSURE Playground #3
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...

Disclosure: This page contains affiliate marketing links that support TLnet.

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.