• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EST 01:25
CET 07:25
KST 15:25
  • 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
Chinese SC2 server to reopen; live all-star event in Hangzhou Maestros of the Game: Live Finals Preview (RO4) BGE Stara Zagora 2026 announced Weekly Cups (Nov 24-30): MaxPax, Clem, herO win SC2 Proleague Discontinued; SKT, KT, SGK, CJ disband
Tourneys
StarCraft Evolution League (SC Evo Biweekly) RSL Offline Finals Info - Dec 13 and 14! RSL Offline FInals Sea Duckling Open (Global, Bronze-Diamond) $5,000+ WardiTV 2025 Championship
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
BW General Discussion Which season is the best in ASL? Data analysis on 70 million replays BGH Auto Balance -> http://bghmmr.eu/ [ASL20] Ask the mapmakers — Drop your questions
Tourneys
[BSL21] RO16 Group D - Sunday 21:00 CET [BSL21] RO16 Group A - Saturday 21:00 CET [Megathread] Daily Proleagues [BSL21] RO16 Group B - Sunday 21:00 CET
Strategy
Current Meta Game Theory for Starcraft How to stay on top of macro? PvZ map balance
Other Games
General Games
Stormgate/Frost Giant Megathread ZeroSpace Megathread Nintendo Switch Thread The Perfect Game Path of Exile
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
US Politics Mega-thread Things Aren’t Peaceful in Palestine Russo-Ukrainian War 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: 1650 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
Hyrule19173 Posts
July 17 2013 03:11 GMT
#6446
w3schools is kinda completely shit
Liquipediaasante sana squash banana
tec27
Profile Blog Joined June 2004
United States3702 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
Replay Cast
00:00
WardiTV Mondays #62
LiquipediaDiscussion
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
RuFF_SC2 197
SortOf 77
trigger 46
-ZergGirl 16
StarCraft: Brood War
Stork 783
Tasteless 210
Shine 122
NaDa 44
Bale 34
ZergMaN 20
Icarus 10
Dota 2
NeuroSwarm122
febbydoto35
League of Legends
JimRising 639
Other Games
summit1g11391
WinterStarcraft529
C9.Mang0340
ViBE142
Mew2King52
Organizations
Other Games
gamesdonequick765
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 15 non-featured ]
StarCraft 2
• Berry_CruncH132
• practicex 29
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• Azhi_Dahaki19
• Diggity4
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
League of Legends
• Lourlo1247
Upcoming Events
The PondCast
3h 35m
OSC
9h 35m
Demi vs Mixu
Nicoract vs TBD
Babymarine vs MindelVK
ForJumy vs TBD
Shameless vs Percival
Replay Cast
17h 35m
Korean StarCraft League
1d 20h
CranKy Ducklings
2 days
WardiTV 2025
2 days
SC Evo League
2 days
BSL 21
2 days
Sziky vs OyAji
Gypsy vs eOnzErG
OSC
2 days
Solar vs Creator
ByuN vs Gerald
Percival vs Babymarine
Moja vs Krystianer
EnDerr vs ForJumy
sebesdes vs Nicoract
Sparkling Tuna Cup
3 days
[ Show More ]
WardiTV 2025
3 days
OSC
3 days
BSL 21
3 days
Bonyth vs StRyKeR
Tarson vs Dandy
Replay Cast
4 days
Wardi Open
4 days
StarCraft2.fi
4 days
Monday Night Weeklies
4 days
Replay Cast
4 days
WardiTV 2025
5 days
StarCraft2.fi
5 days
PiGosaur Monday
5 days
StarCraft2.fi
6 days
Tenacious Turtle Tussle
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...

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.