• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 17:26
CEST 23:26
KST 06:26
  • 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] Ro16 Preview Pt2: All Star10Team Liquid Map Contest #22 - The Finalists16[ASL21] Ro16 Preview Pt1: Fresh Flow9[ASL21] Ro24 Preview Pt2: News Flash10[ASL21] Ro24 Preview Pt1: New Chaos0
Community News
2026 GSL Season 1 Qualifiers13Maestros of the Game 2 announced82026 GSL Tour plans announced14Weekly Cups (April 6-12): herO doubles, "Villains" prevail1MaNa leaves Team Liquid24
StarCraft 2
General
Maestros of the Game 2 announced Team Liquid Map Contest #22 - The Finalists MaNa leaves Team Liquid 2026 GSL Tour plans announced Blizzard Classic Cup @ BlizzCon 2026 - $100k prize pool
Tourneys
Sparkling Tuna Cup - Weekly Open Tournament 2026 GSL Season 1 Qualifiers GSL CK: More events planned pending crowdfunding RSL Revival: Season 5 - Qualifiers and Main Event Master Swan Open (Global Bronze-Master 2)
Strategy
Custom Maps
[D]RTS in all its shapes and glory <3 [A] Nemrods 1/4 players [M] (2) Frigid Storage
External Content
Mutation # 522 Flip My Base The PondCast: SC2 News & Results Mutation # 521 Memorable Boss Mutation # 520 Moving Fees
Brood War
General
Pros React To: ASL S21, Ro.16 Group C ASL21 General Discussion BGH Auto Balance -> http://bghmmr.eu/ [TOOL] Starcraft Chat Translator Data needed
Tourneys
[ASL21] Ro16 Group C [Megathread] Daily Proleagues [ASL21] Ro16 Group D [ASL21] Ro16 Group B
Strategy
Simple Questions, Simple Answers What's the deal with APM & what's its true value Any training maps people recommend? Fighting Spirit mining rates
Other Games
General Games
Diablo IV Nintendo Switch Thread Dawn of War IV Starcraft Tabletop Miniature Game General RTS Discussion Thread
Dota 2
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
Vanilla Mini Mafia Mafia Game Mode Feedback/Ideas TL Mafia Community Thread Five o'clock TL Mafia
Community
General
Things Aren’t Peaceful in Palestine US Politics Mega-thread Canadian Politics Mega-thread Russo-Ukrainian War Thread YouTube Thread
Fan Clubs
The IdrA Fan Club
Media & Entertainment
Anime Discussion Thread [Manga] One Piece [Req][Books] Good Fantasy/SciFi books Movie Discussion!
Sports
McBoner: A hockey love story 2024 - 2026 Football Thread Formula 1 Discussion Cricket [SPORT]
World Cup 2022
Tech Support
[G] How to Block Livestream Ads
TL Community
The Automated Ban List
Blogs
Sexual Health Of Gamers
TrAiDoS
lurker extra damage testi…
StaticNine
Broowar part 2
qwaykee
Funny Nicknames
LUCKY_NOOB
Iranian anarchists: organize…
XenOsky
Customize Sidebar...

Website Feedback

Closed Threads



Active: 2916 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
Poland17731 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 2h 34m
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
mouzHeroMarine 437
elazer 239
ProTech145
StarCraft: Brood War
Britney 15487
Calm 2536
BeSt 306
Rush 160
firebathero 80
Terrorterran 17
ajuk12(nOOB) 16
Dota 2
monkeys_forever291
Pyrionflax176
Counter-Strike
pashabiceps2466
tarik_tv2170
fl0m1844
Heroes of the Storm
Liquid`Hasu416
Other Games
summit1g6767
Grubby3894
FrodaN829
shahzam471
mouzStarbuck244
C9.Mang0243
Trikslyr147
ArmadaUGS64
Mew2King54
Organizations
Other Games
BasetradeTV301
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 16 non-featured ]
StarCraft 2
• davetesta3
• Reevou 2
• intothetv
• AfreecaTV YouTube
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Dota 2
• masondota21165
League of Legends
• Doublelift1935
Other Games
• imaqtpie1238
• Shiphtur251
Upcoming Events
Replay Cast
2h 34m
The PondCast
12h 34m
KCM Race Survival
12h 34m
WardiTV Map Contest Tou…
13h 34m
Gerald vs herO
Clem vs Cure
ByuN vs Solar
Rogue vs MaxPax
ShoWTimE vs TBD
OSC
17h 34m
CranKy Ducklings
1d 2h
Escore
1d 12h
RSL Revival
1d 19h
Replay Cast
2 days
WardiTV Map Contest Tou…
2 days
[ Show More ]
Universe Titan Cup
2 days
Rogue vs Percival
Ladder Legends
2 days
uThermal 2v2 Circuit
2 days
BSL
2 days
Sparkling Tuna Cup
3 days
WardiTV Map Contest Tou…
3 days
Ladder Legends
3 days
BSL
3 days
Replay Cast
4 days
Replay Cast
4 days
Wardi Open
4 days
Afreeca Starleague
4 days
Soma vs hero
Monday Night Weeklies
4 days
Replay Cast
5 days
Afreeca Starleague
5 days
Leta vs YSC
Replay Cast
6 days
Liquipedia Results

Completed

Proleague 2026-04-20
RSL Revival: Season 4
NationLESS Cup

Ongoing

BSL Season 22
ASL Season 21
CSL 2026 SPRING (S20)
IPSL Spring 2026
KCM Race Survival 2026 Season 2
Proleague 2026-04-22
StarCraft2 Community Team League 2026 Spring
WardiTV TLMC #16
Nations Cup 2026
IEM Rio 2026
PGL Bucharest 2026
Stake Ranked Episode 1
BLAST Open Spring 2026
ESL Pro League S23 Finals
ESL Pro League S23 Stage 1&2
PGL Cluj-Napoca 2026
IEM Kraków 2026

Upcoming

Escore Tournament S2: W4
Acropolis #4
BSL 22 Non-Korean Championship
CSLAN 4
Kung Fu Cup 2026 Grand Finals
HSC XXIX
uThermal 2v2 2026 Main Event
Maestros of the Game 2
2026 GSL S2
RSL Revival: Season 5
2026 GSL S1
XSE Pro League 2026
IEM Cologne Major 2026
Stake Ranked Episode 2
CS Asia Championships 2026
IEM Atlanta 2026
Asian Champions League 2026
PGL Astana 2026
BLAST Rivals Spring 2026
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.