• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EST 23:00
CET 05:00
KST 13:00
  • 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
RSL Season 3 - Playoffs Preview0RSL Season 3 - RO16 Groups C & D Preview0RSL Season 3 - RO16 Groups A & B Preview2TL.net Map Contest #21: Winners12Intel X Team Liquid Seoul event: Showmatches and Meet the Pros10
Community News
Weekly Cups (Nov 24-30): MaxPax, Clem, herO win2BGE Stara Zagora 2026 announced15[BSL21] Ro.16 Group Stage (C->B->A->D)4Weekly Cups (Nov 17-23): Solar, MaxPax, Clem win3RSL Season 3: RO16 results & RO8 bracket13
StarCraft 2
General
BGE Stara Zagora 2026 announced Weekly Cups (Nov 24-30): MaxPax, Clem, herO win SC2 Proleague Discontinued; SKT, KT, SGK, CJ disband Information Request Regarding Chinese Ladder SC: Evo Complete - Ranked Ladder OPEN ALPHA
Tourneys
$5,000+ WardiTV 2025 Championship Constellation Cup - Main Event - Stellar Fest RSL Revival: Season 3 Tenacious Turtle Tussle [Alpha Pro Series] Nice vs Cure
Strategy
Custom Maps
Map Editor closed ?
External Content
Mutation # 502 Negative Reinforcement Mutation # 501 Price of Progress Mutation # 500 Fright night Mutation # 499 Chilling Adaptation
Brood War
General
Which season is the best in ASL? [ASL20] Ask the mapmakers — Drop your questions BW General Discussion FlaSh's Valkyrie Copium BGH Auto Balance -> http://bghmmr.eu/
Tourneys
[Megathread] Daily Proleagues [BSL21] RO16 Group B - Sunday 21:00 CET [BSL21] RO16 Group C - Saturday 21:00 CET Small VOD Thread 2.0
Strategy
Game Theory for Starcraft How to stay on top of macro? Current Meta PvZ map balance
Other Games
General Games
Stormgate/Frost Giant Megathread The Perfect Game Path of Exile Nintendo Switch Thread Should offensive tower rushing be viable in RTS games?
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
Mafia Game Mode Feedback/Ideas TL Mafia Community Thread
Community
General
Things Aren’t Peaceful in Palestine Russo-Ukrainian War Thread US Politics Mega-thread The Big Programming Thread Artificial Intelligence Thread
Fan Clubs
White-Ra Fan Club
Media & Entertainment
[Manga] One Piece Movie Discussion! Anime Discussion Thread
Sports
2024 - 2026 Football Thread Formula 1 Discussion NBA General Discussion
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
Where to ask questions and add stream? The Automated Ban List
Blogs
James Bond movies ranking - pa…
Topin
Esports Earnings: Bigger Pri…
TrAiDoS
Thanks for the RSL
Hildegard
Saturation point
Uldridge
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1285 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
Poland17490 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
PiGosaur Monday
01:00
#60
PiGStarcraft627
SteadfastSC160
CranKy Ducklings103
Liquipedia
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
PiGStarcraft627
SteadfastSC 160
RuFF_SC2 128
Nathanias 78
StarCraft: Brood War
PianO 130
Noble 38
Icarus 9
Dota 2
monkeys_forever497
Counter-Strike
Coldzera 270
Other Games
summit1g13511
JimRising 675
WinterStarcraft425
C9.Mang0368
ViBE163
Mew2King26
Organizations
Other Games
gamesdonequick1166
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 15 non-featured ]
StarCraft 2
• Hupsaiya 77
• intothetv
• AfreecaTV YouTube
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• Azhi_Dahaki16
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
League of Legends
• Lourlo625
• Stunt343
Other Games
• Scarra1376
Upcoming Events
Wardi Open
8h
StarCraft2.fi
13h
Replay Cast
20h
The PondCast
1d 6h
OSC
1d 12h
Demi vs Mixu
Nicoract vs TBD
Babymarine vs MindelVK
ForJumy vs TBD
Shameless vs Percival
Replay Cast
1d 20h
Korean StarCraft League
2 days
CranKy Ducklings
3 days
SC Evo League
3 days
BSL 21
3 days
Sziky vs OyAji
Gypsy vs eOnzErG
[ Show More ]
OSC
3 days
Solar vs Creator
ByuN vs Gerald
Percival vs Babymarine
Moja vs Krystianer
EnDerr vs ForJumy
sebesdes vs Nicoract
Sparkling Tuna Cup
4 days
OSC
4 days
BSL 21
4 days
Bonyth vs StRyKeR
Tarson vs Dandy
Replay Cast
5 days
Wardi Open
5 days
StarCraft2.fi
5 days
Replay Cast
5 days
StarCraft2.fi
6 days
PiGosaur Monday
6 days
Liquipedia Results

Completed

Proleague 2025-11-30
RSL Revival: Season 3
Light HT

Ongoing

C-Race Season 1
IPSL Winter 2025-26
KCM Race Survival 2025 Season 4
YSL S2
BSL Season 21
CSCL: Masked Kings S3
Slon Tour Season 2
Acropolis #4 - TS3
META Madness #9
SL Budapest Major 2025
ESL Impact League Season 8
BLAST Rivals Fall 2025
IEM Chengdu 2025
PGL Masters Bucharest 2025
Thunderpick World Champ.
CS Asia Championships 2025
ESL Pro League S22
StarSeries Fall 2025
FISSURE Playground #2

Upcoming

BSL 21 Non-Korean Championship
Acropolis #4
IPSL Spring 2026
Bellum Gens Elite Stara Zagora 2026
HSC XXVIII
RSL Offline Finals
WardiTV 2025
Kuram Kup
PGL Cluj-Napoca 2026
IEM Kraków 2026
BLAST Bounty Winter 2026
BLAST Bounty Winter Qual
eXTREMESLAND 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...

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 © 2025 TLnet. All Rights Reserved.