• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 01:31
CET 06:31
KST 14:31
  • 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] Finals Preview: Sweet Victory!9[ASL22] Ro4 Preview: Mirror Mirror6[ASL22] Ro8 Preview: Within Reach5[ASL22] Ro8 Preview: In A Tizzy11[ASL22] Ro16 Preview: Holy Diver5
Community News
Evil Geniuses - shutting down14ISSL (IntoTheTV x SOOP SC2 League): Premier5Weekly Cups (October 12-18): 5.0.17 era begins1[$1250] International ShieldBattery League75Weekly Cups (October 5-11): Farewell to 5.0.167
StarCraft 2
General
How do you feel about the mass reverts in the 5.0.17 PTR? REPORT: StarCraft 2: Remastered In Development Team Liquid Map Contest #22: Results and Winners No more SC2 streamers on team liquid? Evil Geniuses - shutting down
Tourneys
ScienceCraft (October 24-25) - Live Event Sparkling Tuna Cup - Weekly Open Tournament RSL goes to London! 2026 Offline Finals Nov 21-22 ISSL (IntoTheTV x SOOP SC2 League): Premier WORTEX Challenger Series — Open SC2 LAN in Budapes
Strategy
[H] ZvP Mid-Late Game: Stalkers Collossi HT
Custom Maps
[G] How to playtest arcade maps [A] Nemrods 1/4 players [M] (2) Sweltering Sands
External Content
Mutation # 549 Endless Sparkles The PondCast: SC2 News & Results Mutation # 548 Shining Bright Mutation # 547 Temple Of Terror
Brood War
General
Recent recommended BW games Oceanic Brood War - Join and chat! Bot on ladder BW General Discussion Sagi.gg Launcher Released
Tourneys
[Megathread] Daily Proleagues [$1250] International ShieldBattery League [ASL22] Grand Finals [BSL23] RO24 Group C
Strategy
Cliff Jump Revisited (1 in a 1000 strategy) 50,000-Word Terran Builds Memo 2026-10-22 Simple Questions, Simple Answers
Other Games
General Games
Stormgate/Frost Giant Megathread Nintendo Switch Thread Mobile Legends: Bang Bang Armies of Exigo - YesYes? General RTS Discussion Thread
Dota 2
Dota 2 Champions League Season 3 Begins April 25!
League of Legends
[TL LoL EUW IHs] Teemo shall perish
Heroes of the Storm
Heroes of the Storm 2.0
Hearthstone
Deck construction bug
TL Mafia
TL Mafia Community Thread
Community
General
Things Aren’t Peaceful in Palestine US Politics Mega-thread European Politico-economics QA Mega-thread Russo-Ukrainian War Thread Canadian Politics Mega-thread
Fan Clubs
Reynor Fan Club The Flash Fan Club Serral Fan Club
Media & Entertainment
Anime Discussion Thread Movie Discussion! [Manga] One Piece
Sports
Football (Soccer) Thread TeamLiquid Health and Fitness Initiative For 2023 MLB/Baseball 2023
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
Recent Gifted Posts
Blogs
Innovate or Game Over?
TrAiDoS
ShieldBattery on Mac
Kraekkling
[ASL22] Ro4 Day1 Ticket Giv…
bITt.mAN
Can Bots Beat Pros?? Starcr…
namkraft
Customize Sidebar...

Website Feedback

Closed Threads



Active: 9103 users

The Big Programming Thread - Page 323

Forum Index > General Forum
Post a Reply
Prev 1 321 322 323 324 325 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.
Release
Profile Blog Joined October 2010
United States4397 Posts
July 15 2013 05:54 GMT
#6441
What are good books/websites from which to learn html/css/javascript?
☺
Iggyhopper
Profile Joined July 2010
United States259 Posts
Last Edited: 2013-07-15 06:14:15
July 15 2013 06:10 GMT
#6442
NOT w3schools.

JavaScript-
Interactive: http://www.codecademy.com/
Book/Resource: http://eloquentjavascript.net/
HardlyNever
Profile Blog Joined July 2011
United States1258 Posts
July 16 2013 21:30 GMT
#6443
Anyone have experience with this JQuery plugin ?

http://jqueryvalidation.org/

I'm having trouble getting it to work on my form. Or anyone recommend another jquery plugin to validate my forms (they don't have to be too robust).
Out there, the Kid learned to fend for himself. Learned to build. Learned to break.
Arnstein
Profile Blog Joined May 2010
Norway3381 Posts
July 16 2013 21:38 GMT
#6444
On July 15 2013 15:10 Iggyhopper wrote:
NOT w3schools.

JavaScript-
Interactive: http://www.codecademy.com/
Book/Resource: http://eloquentjavascript.net/


Just wondering, what's wrong with w3schools?
rsol in response to the dragoon voice being heard in SCII: dragoon ai reaches new lows: wanders into wrong game
Release
Profile Blog Joined October 2010
United States4397 Posts
July 17 2013 02:44 GMT
#6445
I too am curious why not w3schools?
☺
tofucake
Profile Blog Joined October 2009
Hyrule19264 Posts
July 17 2013 03:11 GMT
#6446
w3schools is kinda completely shit
Liquipediaasante sana squash banana
tec27
Profile Blog Joined June 2004
United States3727 Posts
July 17 2013 06:13 GMT
#6447
We've had this discussion at least like 3 times in this thread already, please search for it instead of starting it again. The reasons haven't changed.
Can you jam with the console cowboys in cyberspace?
Encdalf
Profile Joined February 2012
Germany66 Posts
July 17 2013 09:29 GMT
#6448
On July 15 2013 14:54 Release wrote:
What are good books/websites from which to learn html/css/javascript?


Webplatform
http://www.webplatform.org/

or

MDN
https://developer.mozilla.org/en-US/docs/Web/HTML
https://developer.mozilla.org/en-US/docs/Web/CSS
https://developer.mozilla.org/en-US/docs/Web/JavaScript

My advice is, to start with learning html structuring and semantics (basics won't take long), add css afterwards and learn how to style the elements, and only when you got the basic knowledge of both, start with javascript. In the beginning you will probably use js to modify the dom and it won't help you if you don't know what you're doing there



On July 17 2013 06:38 Arnstein wrote:
Just wondering, what's wrong with w3schools?


http://www.w3fools.com/
holdthephone
Profile Blog Joined August 2010
United States523 Posts
Last Edited: 2013-07-18 01:21:45
July 18 2013 01:21 GMT
#6449
Alright, C++:

Have a text input file, want to read it into char array, but size of file is variable (could be 8 chars, 64, 512, etc...). How can I accommodate for the right amount of characters, besides simply creating an ultra huge char array?

phar
Profile Joined August 2011
United States1080 Posts
Last Edited: 2013-07-18 01:25:47
July 18 2013 01:25 GMT
#6450
malloc ?

I haven't written C++ in 5 years, so there's probably a better way to do it.
Who after all is today speaking about the destruction of the Armenians?
Deleted User 101379
Profile Blog Joined August 2010
4849 Posts
Last Edited: 2013-07-18 01:44:26
July 18 2013 01:40 GMT
#6451
On July 18 2013 10:21 holdthephone wrote:
Alright, C++:

Have a text input file, want to read it into char array, but size of file is variable (could be 8 chars, 64, 512, etc...). How can I accommodate for the right amount of characters, besides simply creating an ultra huge char array?



use stat() to get the size of the file and malloc() or new[] an array of that size.


struct stat;
char *data;
int statresult = stat(path_to_file, &stat);

// returns 0 on success, could write !statresult but that looks more misleading
if (statresult == 0)
{
// C++ Version:
data = new char[stat.st_size];

// C Version
data = malloc(stat.st_size);

// read file into data
// don't forget to delete[] (C++) or free() (C) after you are done with data
}

Pawsom
Profile Blog Joined February 2009
United States928 Posts
July 18 2013 01:40 GMT
#6452
On July 18 2013 10:21 holdthephone wrote:
Alright, C++:

Have a text input file, want to read it into char array, but size of file is variable (could be 8 chars, 64, 512, etc...). How can I accommodate for the right amount of characters, besides simply creating an ultra huge char array?



Vectors if its C++
icystorage
Profile Blog Joined November 2008
Jollibee19350 Posts
July 18 2013 02:31 GMT
#6453
malloc definitely. mcc (a regular poster in this thread) helped me step by step and explained that to me perfectly. Really one of the people that helped me during my freshman year.
LiquidDota StaffAre you ready for a Miracle-? We are! The International 2017 Champions!
Rotodyne
Profile Blog Joined July 2005
United States2263 Posts
July 18 2013 02:46 GMT
#6454
On July 17 2013 06:30 HardlyNever wrote:
Anyone have experience with this JQuery plugin ?

http://jqueryvalidation.org/

I'm having trouble getting it to work on my form. Or anyone recommend another jquery plugin to validate my forms (they don't have to be too robust).


I have used that one before and it seemed to work well. If you post your code or PM me I could take a look.
I can only play starcraft when I am shit canned. IPXZERG is a god.
Deleted User 101379
Profile Blog Joined August 2010
4849 Posts
July 18 2013 03:06 GMT
#6455
On July 18 2013 11:31 icystorage wrote:
malloc definitely. mcc (a regular poster in this thread) helped me step by step and explained that to me perfectly. Really one of the people that helped me during my freshman year.


malloc() is a C call, C++ uses new/new[]. The difference is that new[] calls the constructor if you initialize an array of a class, so it's better to get used to using the C++ specific operator even for cases where there is no actual difference.
Tobberoth
Profile Joined August 2010
Sweden6375 Posts
July 18 2013 09:09 GMT
#6456
On July 18 2013 10:40 Pawsom wrote:
Show nested quote +
On July 18 2013 10:21 holdthephone wrote:
Alright, C++:

Have a text input file, want to read it into char array, but size of file is variable (could be 8 chars, 64, 512, etc...). How can I accommodate for the right amount of characters, besides simply creating an ultra huge char array?



Vectors if its C++

This would be my advice as well. You can use new (or malloc though if it's C++ I don't see why you would), but in modern C++, using vectors would probably be considered best practice.
nunez
Profile Blog Joined February 2011
Norway4003 Posts
Last Edited: 2013-07-18 22:44:28
July 18 2013 22:40 GMT
#6457
On July 18 2013 18:09 Tobberoth wrote:
Show nested quote +
On July 18 2013 10:40 Pawsom wrote:
On July 18 2013 10:21 holdthephone wrote:
Alright, C++:

Have a text input file, want to read it into char array, but size of file is variable (could be 8 chars, 64, 512, etc...). How can I accommodate for the right amount of characters, besides simply creating an ultra huge char array?



Vectors if its C++

This would be my advice as well. You can use new (or malloc though if it's C++ I don't see why you would), but in modern C++, using vectors would probably be considered best practice.


use vector!
don't use new unless you can't not heap it.

if you are also looking to parse the files contents check out boost spirit qi! excellent parser generator (header only) library for cpp.

example parsing file into vector of chars... look how cute.

#include <fstream>
#include <vector>
#include <boost/spirit/include/qi.hpp>

namespace spirit = boost::spirit;
namespace qi = boost::spirit::qi;
std::vector<char> data;
qi::parse(spirit::istream_iterator(std::ifstream("input.txt") >> std::noskipws), spirit::istream_iterator(), *qi::char_, data)

conspired against by a confederacy of dunces.
RoyGBiv_13
Profile Blog Joined August 2010
United States1275 Posts
Last Edited: 2013-07-18 23:12:33
July 18 2013 23:08 GMT
#6458
On July 19 2013 07:40 nunez wrote:
Show nested quote +
On July 18 2013 18:09 Tobberoth wrote:
On July 18 2013 10:40 Pawsom wrote:
On July 18 2013 10:21 holdthephone wrote:
Alright, C++:

Have a text input file, want to read it into char array, but size of file is variable (could be 8 chars, 64, 512, etc...). How can I accommodate for the right amount of characters, besides simply creating an ultra huge char array?



Vectors if its C++

This would be my advice as well. You can use new (or malloc though if it's C++ I don't see why you would), but in modern C++, using vectors would probably be considered best practice.


use vector!
don't use new unless you can't not heap it.

if you are also looking to parse the files contents check out boost spirit qi! excellent parser generator library for cpp.

example parsing file into vector of chars... look how cute.

#include <fstream>
#include <vector>
#include <boost/spirit/include/qi.hpp>

namespace spirit = boost::spirit;
namespace qi = boost::spirit::qi;
std::vector<char> data;
qi::parse(spirit::istream_iterator(std::ifstream("input.txt") >> std::noskipws), spirit::istream_iterator(), *qi::char_, data)



A more generic question would be: "how do I keep a variable amount of memory reserved for X purpose". The more generic answer is: "on the heap, on the stack, or within ROM (a file on the file system, typically) [and secret option D, manually defined memory]"

You typically don't want to use the stack for unbounded amounts of memory, as it can cause a stack overflow, which could be a security hole. This is typically why you don't have unbounded recursion either.

In this case, you are trying to buffer a variable amount of memory in RAM for processing data typically stored in ROM. This would mean you will dynamically request memory from the heap. Boost's Array, std's Vector, and C's malloc library all use heap.

Typical OS behaviour states that your heap can continue to grow as long as you have pages left for the kernel to assign, so it is bounded by the amount of RAM on your system. Because the malloc library uses operating system hooks, it does not have (major) security issues like the stack does. Vector and Array are pretty good at heap management, trying to keep your data in a contiguous virtual block if possible, but calling malloc directly also has it's benefits. The keyword "new" is a wrapper around malloc that also calls the constructor for that class.

The third option would be to directly process the file in ROM without buffering the entire thing into RAM. This is a strategy used by many of the GNU utilities, as streaming data does not need a variable size buffer. Probably the fastest way, but definitely overkill in most applications.

[secret option D is just assigning a pointer to some place in memory, clearing it and using it, but why do this whenever such smart people have already built a malloc library?]
Any sufficiently advanced technology is indistinguishable from magic
nunez
Profile Blog Joined February 2011
Norway4003 Posts
July 18 2013 23:44 GMT
#6459
On July 19 2013 08:08 RoyGBiv_13 wrote:
Show nested quote +
On July 19 2013 07:40 nunez wrote:
On July 18 2013 18:09 Tobberoth wrote:
On July 18 2013 10:40 Pawsom wrote:
On July 18 2013 10:21 holdthephone wrote:
Alright, C++:

Have a text input file, want to read it into char array, but size of file is variable (could be 8 chars, 64, 512, etc...). How can I accommodate for the right amount of characters, besides simply creating an ultra huge char array?



Vectors if its C++

This would be my advice as well. You can use new (or malloc though if it's C++ I don't see why you would), but in modern C++, using vectors would probably be considered best practice.


use vector!
don't use new unless you can't not heap it.

if you are also looking to parse the files contents check out boost spirit qi! excellent parser generator library for cpp.

example parsing file into vector of chars... look how cute.

#include <fstream>
#include <vector>
#include <boost/spirit/include/qi.hpp>

namespace spirit = boost::spirit;
namespace qi = boost::spirit::qi;
std::vector<char> data;
qi::parse(spirit::istream_iterator(std::ifstream("input.txt") >> std::noskipws), spirit::istream_iterator(), *qi::char_, data)



A more generic question would be: "how do I keep a variable amount of memory reserved for X purpose". The more generic answer is: "on the heap, on the stack, or within ROM (a file on the file system, typically) [and secret option D, manually defined memory]"

You typically don't want to use the stack for unbounded amounts of memory, as it can cause a stack overflow, which could be a security hole. This is typically why you don't have unbounded recursion either.

In this case, you are trying to buffer a variable amount of memory in RAM for processing data typically stored in ROM. This would mean you will dynamically request memory from the heap. Boost's Array, std's Vector, and C's malloc library all use heap.

Typical OS behaviour states that your heap can continue to grow as long as you have pages left for the kernel to assign, so it is bounded by the amount of RAM on your system. Because the malloc library uses operating system hooks, it does not have (major) security issues like the stack does. Vector and Array are pretty good at heap management, trying to keep your data in a contiguous virtual block if possible, but calling malloc directly also has it's benefits. The keyword "new" is a wrapper around malloc that also calls the constructor for that class.

The third option would be to directly process the file in ROM without buffering the entire thing into RAM. This is a strategy used by many of the GNU utilities, as streaming data does not need a variable size buffer. Probably the fastest way, but definitely overkill in most applications.

[secret option D is just assigning a pointer to some place in memory, clearing it and using it, but why do this whenever such smart people have already build a malloc library?]


i didn't mean to imply vector does not use heap if you extrapolated that from my post (the vector itself is ofc on the stack), it usually does (does not have to). maybe i should have been more explicit instead of going for a bad pun, he he. rather to use vector instead of new for a dynamically sized array of chars, felt it was a safe bet considering the perceived context.
conspired against by a confederacy of dunces.
Release
Profile Blog Joined October 2010
United States4397 Posts
July 19 2013 00:09 GMT
#6460
I keep getting this error:

Warning: Unknown: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone.

in eclipse for php. I've tried editting the php.ini, using the date_default_timezone_set, and ini_set, but none of these get rid of this error.
Any other way to fix this error?
☺
Prev 1 321 322 323 324 325 1032 Next
Please log in or register to reply.
Live Events Refresh
Next event in 5h 29m
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
WinterStarcraft512
StarCraft: Brood War
Rain 2373
GuemChi 1671
Leta 295
ProTech185
ZergMaN 37
Noble 16
Icarus 9
League of Legends
Doublelift4492
JimRising 721
Super Smash Bros
hungrybox606
Heroes of the Storm
Trikslyr48
Other Games
summit1g9151
C9.Mang0222
PiGStarcraft209
NeuroSwarm142
RuFF_SC2101
Sick50
Organizations
Other Games
gamesdonequick643
[ Show 13 non-featured ]
StarCraft 2
• practicex 38
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• Migwel
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Dota 2
• lizZardDota285
League of Legends
• Stunt425
Other Games
• Scarra827
• Shiphtur602
Upcoming Events
IntoTheTV X SOOP
5h 29m
ByuN vs Lambo
MaxPax vs Bunny
PiGosaur Cup
18h 29m
The PondCast
1d 4h
Kung Fu Cup
1d 5h
IntoTheTV X SOOP
2 days
SHIN vs GuMiho
Clem vs Classic
OSC
2 days
WardiTV Invitational
3 days
GSL
3 days
Epic.LAN
3 days
Replay Cast
3 days
[ Show More ]
Sparkling Tuna Cup
4 days
Epic.LAN
4 days
Yamato Cup
5 days
Map Test Tournament
5 days
WardiTV Weekly
6 days
Replay Cast
6 days
Rogue vs Classic
Liquipedia Results

Completed

Acropolis #5 - GSC
Blizzard Classic Cup 2026
HCC Season 3

Ongoing

Acropolis #5
KCM Race Survival 2026 Season 4
International ShieldBattery League
BSL Season 23
PGL Masters Bucharest 2026
Stake Ranked Episode 5
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
BLAST Open Fall 2026
Esports World Cup 2026

Upcoming

IPSL Winter 2026-27
SC4ALL II: Brood War
BSL 23: Non-Korean Championship
HSC XXX
Stellar Fest 2: Lunar Cup
SC4ALL II: StarCraft II
Kung Fu Cup 2026 Grand Finals
RSL Offline Finals
eXTREMESLAND 2026
PGL Major Singapore 2026
Stake Ranked Episode 6
BLAST Rivals Fall 2026
IEM Beijing 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...

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.