• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 04:41
CET 09:41
KST 17:41
  • 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
Team Liquid Map Contest #22 - Presented by Monster Energy5ByuL: The Forgotten Master of ZvT30Behind the Blue - Team Liquid History Book19Clem wins HomeStory Cup 289HomeStory Cup 28 - Info & Preview13
Community News
Blizzard Classic Cup @ BlizzCon 2026 - $100k prize pool31Weekly Cups (March 9-15): herO, Clem, ByuN win42026 KungFu Cup Announcement6BGE Stara Zagora 2026 cancelled12Blizzard Classic Cup - Tastosis announced as captains18
StarCraft 2
General
Blizzard Classic Cup @ BlizzCon 2026 - $100k prize pool Potential Updates Coming to the SC2 CN Server Weekly Cups (March 2-8): ByuN overcomes PvT block Weekly Cups (August 25-31): Clem's Last Straw? Weekly Cups (March 9-15): herO, Clem, ByuN win
Tourneys
World University TeamLeague (500$+) | Signups Open RSL Season 4 announced for March-April Sparkling Tuna Cup - Weekly Open Tournament WardiTV Team League Season 10 KSL Week 87
Strategy
Custom Maps
Publishing has been re-enabled! [Feb 24th 2026]
External Content
The PondCast: SC2 News & Results Mutation # 517 Distant Threat Mutation # 516 Specter of Death Mutation # 515 Together Forever
Brood War
General
ASL21 General Discussion BGH Auto Balance -> http://bghmmr.eu/ Gypsy to Korea JaeDong's form before ASL BSL Season 22
Tourneys
[Megathread] Daily Proleagues [BSL22] Open Qualifiers & Ladder Tours Small VOD Thread 2.0 IPSL Spring 2026 is here!
Strategy
Simple Questions, Simple Answers Soma's 9 hatch build from ASL Game 2 Fighting Spirit mining rates
Other Games
General Games
General RTS Discussion Thread Stormgate/Frost Giant Megathread Nintendo Switch Thread Path of Exile Dawn of War IV
Dota 2
Official 'what is Dota anymore' discussion 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
Five o'clock TL Mafia Mafia Game Mode Feedback/Ideas Vanilla Mini Mafia TL Mafia Community Thread
Community
General
US Politics Mega-thread Things Aren’t Peaceful in Palestine Canadian Politics Mega-thread Russo-Ukrainian War Thread Mexico's Drug War
Fan Clubs
The IdrA Fan Club
Media & Entertainment
[Req][Books] Good Fantasy/SciFi books Movie Discussion! [Manga] One Piece
Sports
2024 - 2026 Football Thread Cricket [SPORT] Formula 1 Discussion Tokyo Olympics 2021 Thread General nutrition recommendations
World Cup 2022
Tech Support
Laptop capable of using Photoshop Lightroom?
TL Community
The Automated Ban List
Blogs
Funny Nicknames
LUCKY_NOOB
Money Laundering In Video Ga…
TrAiDoS
Iranian anarchists: organize…
XenOsky
FS++
Kraekkling
Shocked by a laser…
Spydermine0240
Unintentional protectionism…
Uldridge
ASL S21 English Commentary…
namkraft
Customize Sidebar...

Website Feedback

Closed Threads



Active: 3827 users

The Big Programming Thread - Page 133

Forum Index > General Forum
Post a Reply
Prev 1 131 132 133 134 135 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.
Millitron
Profile Blog Joined August 2010
United States2611 Posts
April 12 2012 00:02 GMT
#2641
On April 12 2012 07:37 MisterD wrote:
Show nested quote +
On April 12 2012 07:27 ObliviousNA wrote:
On April 12 2012 06:36 Millitron wrote:
On April 12 2012 01:06 phar wrote:
@ Above w/ the C++ & Java:

Depending on the scope of your need to communicate between C++ and Java, it may be worth investing some time into looking at JNI Bridge. Despite the fact that it may make you want to pull your hair out, if you are doing a lot of integration between the languages it'll potentially save you a lot of time.

If your need is pretty simple though (e.g. is limited to literally just stuffing one chunk of data at one single point in java to one single point in C++), then JNI Bridge will be overkill.

I just need to start a C++ program and pass it a parameter from within a Java program. I may also want to get a little output from the C++ program, but I can probably do without it.

The Java program is a UI to enable easier access to a much larger C++ program. Right now, the C++ program is just run from command line, but the hope is that eventually non-CS people will be able to use it.


Ok, so I recommend redoing this with an executable that you know works. Try starting up IE or something basic, and stepping through your code. I'm unfamiliar with Java, but I've done this a lot with System.Diagnostics in .Net (Process and ProcessStartInfo classes) and I've been able to capture stdOUT and stdERR reliably.

This may be blatantly wrong (again unfamiliar with java), but doesnt your EXE spawn its own thread and execute when you call process.start() ? This means you're assigning output / input streams after the program has run. Just a guess.

Edit: Because of the class names 'Process' and 'ProcessBuilder' I'm assuming it functions similar to the .NET classes.


The process does start in a separate thread, hence you are assigning input and output streams _while_ the other process is running, not after. But any output occurring is buffered until you actually read it, so you don't miss anything. In fact, some programs you run this way will block because they are either waiting for input or because output buffers just run full and so their print to stdout gets blocked until you start reading from these streams.


I've just been trying it on Hello World right now, and it definitely works, when run on its own. Its when I try to call it from my Java program that I run into trouble.

What bothers me, is that it starts in another thread. Why doesn't the C++ program start its own runtime environment? Why does it get a thread in the Java program?
Who called in the fleet?
MisterD
Profile Blog Joined June 2010
Germany1338 Posts
April 12 2012 08:00 GMT
#2642
On April 12 2012 09:02 Millitron wrote:
Show nested quote +
On April 12 2012 07:37 MisterD wrote:
On April 12 2012 07:27 ObliviousNA wrote:
On April 12 2012 06:36 Millitron wrote:
On April 12 2012 01:06 phar wrote:
@ Above w/ the C++ & Java:

Depending on the scope of your need to communicate between C++ and Java, it may be worth investing some time into looking at JNI Bridge. Despite the fact that it may make you want to pull your hair out, if you are doing a lot of integration between the languages it'll potentially save you a lot of time.

If your need is pretty simple though (e.g. is limited to literally just stuffing one chunk of data at one single point in java to one single point in C++), then JNI Bridge will be overkill.

I just need to start a C++ program and pass it a parameter from within a Java program. I may also want to get a little output from the C++ program, but I can probably do without it.

The Java program is a UI to enable easier access to a much larger C++ program. Right now, the C++ program is just run from command line, but the hope is that eventually non-CS people will be able to use it.


Ok, so I recommend redoing this with an executable that you know works. Try starting up IE or something basic, and stepping through your code. I'm unfamiliar with Java, but I've done this a lot with System.Diagnostics in .Net (Process and ProcessStartInfo classes) and I've been able to capture stdOUT and stdERR reliably.

This may be blatantly wrong (again unfamiliar with java), but doesnt your EXE spawn its own thread and execute when you call process.start() ? This means you're assigning output / input streams after the program has run. Just a guess.

Edit: Because of the class names 'Process' and 'ProcessBuilder' I'm assuming it functions similar to the .NET classes.


The process does start in a separate thread, hence you are assigning input and output streams _while_ the other process is running, not after. But any output occurring is buffered until you actually read it, so you don't miss anything. In fact, some programs you run this way will block because they are either waiting for input or because output buffers just run full and so their print to stdout gets blocked until you start reading from these streams.


I've just been trying it on Hello World right now, and it definitely works, when run on its own. Its when I try to call it from my Java program that I run into trouble.

What bothers me, is that it starts in another thread. Why doesn't the C++ program start its own runtime environment? Why does it get a thread in the Java program?


I don't know if it gets an actual java thread or if the JVM just forks off a regular operating system thread to run it in, why does that make a difference? you don't see it anyways.
Gold isn't everything in life... you need wood, too!
Deleted User 101379
Profile Blog Joined August 2010
4849 Posts
April 12 2012 08:29 GMT
#2643
On April 12 2012 07:02 mazerr wrote:
Hi TeamLiquid! Long-time (2yr) lurker here, and I finally decided to post, because I need some help! Lengthy read below, but if any of you programming wizards could give some advice I'd appreciate it! I cross-posted this on reddit careeradvice but don't know if I'll get any responses there.

First, a little about my background:

I'm a 23 year old currently living at home. I was a very 'gifted' person when I was younger, ie got As in school w/o effort, played violin and ended up winning a nation-wide HS competition and performed in Carnegie Hall, won local Math competitions, etc, all with very minimal effort. Because of this I developed a superiority complex and became very apathetic regarding what I wanted to do, as I was good at a number of things and a lot of people were pushing me to do 'their' thing. I didn't know what I wanted to do. So I promptly got into a decent engineering school (Rose-Hulman) spent all my time playing WoW, and bombed out. This shattered my superiority complex and triggered depression, which deteriorated over the years to the point where I was living at home, morbidly obese, smoking, and pissing in bottles and letting food rot in my room while I played video games.

I have step-by-step overcome this, and am now trying to get my life back on track, but I need to move out, my parents can simply no longer support me (nor do I wish them to). I REALLY desperately want to begin a career as a programmer. Out of all of the things I've done, I like it the most by far (barring music which I love too personally to want it as a job). I've dabbled in a number of different languages (Python, AS3 (lol), C, Java, and Obj-C) and I really enjoy them all equally, I enjoy just the process of coding and pick it up relatively quickly as far as I can judge (ie finished a semester's course-work of a few of them in a month).

I need to move out within a few months, but I have enough money to support myself for around a year. What I would LIKE to be able to do is to pick a language and become proficient enough at it within a year to support myself (around 18k USD a year where I live) by either freelance, web-design, independent flash-game development, anything really. I realize without a degree getting a steady job would near impossible. So what I would like to know (apologies for the length of the post) is is this possible, or is it just a pipe-dream? Please do keep in mind I can learn things extremely quickly, but I realize there's a significant portion of it that can't be brute-forced. And if it is possible, what language and career should I focus on?

The alternative is for me to find a regular minimum-wage job and try to go to school and learn programming on the side, but in this economy I'd be working most of my time and likely wouldn't have my degree until I'm close to 30, and the thought of just starting my career at thirty makes me have a sick feeling in my stomach :/

TL;DR: Can someone who is able to learn things relatively quickly learn programming to a degree that is able to support them, and if so, what language and/or area of programming should they focus on?

Thank you for your time!


Somehow reading this post made me angry...

Programming is no "get rich fast" scheme, it requires a lot of dedication, hard work and _experience_. Yes, you can become a web designer by copy-pasting a lot of stuff together, a child could do that. However, you will need a lot more time for everything than an experienced programmer, which means in the end you will have to provide your services either for more money than your competitors or work around minimum wage (or below) anyways.

Get a minimum wage job and start to develop websites or flash stuff on the side, get experience, get references and _then_ you might make it. Otherwise you will be just another of those webdesigners that live by the scraps of what the bigger fish don't want to do.

You might also want to apply at professional companies anyways. You can get jobs without a degree if you can prove that you really know how to program. Tell them you are willing to do an internship for free for a month to prove your skills... just make sure you actually have the skills.

If you really want to go freelance, there are 2 major groups these days:
1. Web stuff: HTML5, a lot of JavaScript, easy to learn, a lot of competition, comparatively easy to get jobs but low win margins these days. The time of the bubble is long gone.
2. Smartphone apps: HTML5 and JS with a converter to native code is ok for a lot of small applications but usually you either need Java for Android or a Mac and Objective-C for iphone development. Harder to learn, less competition, harder to find jobs but the win margins can be significantly higher than for Web stuff.
tofucake
Profile Blog Joined October 2009
Hyrule19196 Posts
April 12 2012 14:21 GMT
#2644
A portfolio is more important than a degree in the programming world. Make stuff, then on interviews you can say "look at these things I've made" and then you get a job.
Liquipediaasante sana squash banana
phar
Profile Joined August 2011
United States1080 Posts
April 12 2012 17:27 GMT
#2645
On April 12 2012 17:29 Morfildur wrote:
Programming is no "get rich fast" scheme, it requires a lot of dedication, hard work and _experience_. Yes, you can become a web designer by copy-pasting a lot of stuff together, a child could do that. However, you will need a lot more time for everything than an experienced programmer, which means in the end you will have to provide your services either for more money than your competitors or work around minimum wage (or below) anyways.

This 100x

Study up:

http://learnpythonthehardway.org/book/
http://www.khanacademy.org/#computer-science
Who after all is today speaking about the destruction of the Armenians?
Millitron
Profile Blog Joined August 2010
United States2611 Posts
April 12 2012 21:19 GMT
#2646
On April 12 2012 17:00 MisterD wrote:
Show nested quote +
On April 12 2012 09:02 Millitron wrote:
On April 12 2012 07:37 MisterD wrote:
On April 12 2012 07:27 ObliviousNA wrote:
On April 12 2012 06:36 Millitron wrote:
On April 12 2012 01:06 phar wrote:
@ Above w/ the C++ & Java:

Depending on the scope of your need to communicate between C++ and Java, it may be worth investing some time into looking at JNI Bridge. Despite the fact that it may make you want to pull your hair out, if you are doing a lot of integration between the languages it'll potentially save you a lot of time.

If your need is pretty simple though (e.g. is limited to literally just stuffing one chunk of data at one single point in java to one single point in C++), then JNI Bridge will be overkill.

I just need to start a C++ program and pass it a parameter from within a Java program. I may also want to get a little output from the C++ program, but I can probably do without it.

The Java program is a UI to enable easier access to a much larger C++ program. Right now, the C++ program is just run from command line, but the hope is that eventually non-CS people will be able to use it.


Ok, so I recommend redoing this with an executable that you know works. Try starting up IE or something basic, and stepping through your code. I'm unfamiliar with Java, but I've done this a lot with System.Diagnostics in .Net (Process and ProcessStartInfo classes) and I've been able to capture stdOUT and stdERR reliably.

This may be blatantly wrong (again unfamiliar with java), but doesnt your EXE spawn its own thread and execute when you call process.start() ? This means you're assigning output / input streams after the program has run. Just a guess.

Edit: Because of the class names 'Process' and 'ProcessBuilder' I'm assuming it functions similar to the .NET classes.


The process does start in a separate thread, hence you are assigning input and output streams _while_ the other process is running, not after. But any output occurring is buffered until you actually read it, so you don't miss anything. In fact, some programs you run this way will block because they are either waiting for input or because output buffers just run full and so their print to stdout gets blocked until you start reading from these streams.


I've just been trying it on Hello World right now, and it definitely works, when run on its own. Its when I try to call it from my Java program that I run into trouble.

What bothers me, is that it starts in another thread. Why doesn't the C++ program start its own runtime environment? Why does it get a thread in the Java program?


I don't know if it gets an actual java thread or if the JVM just forks off a regular operating system thread to run it in, why does that make a difference? you don't see it anyways.

I think it does make a difference though. I think why I can't get any output is that it does start a Java thread, and then control never goes back to the original thread, because the C++ one never ends.
Who called in the fleet?
MisterD
Profile Blog Joined June 2010
Germany1338 Posts
April 12 2012 23:17 GMT
#2647
no, the process start returns control flow immediately. if you want to wait for the process to end, you explicitly have to call process.waitFor();

try the following: make a very simple program that does nothing but start the c++ program and then System.out.println("hello"); and execute it. You will see the "hello" immediately after the c++ program has started.
Gold isn't everything in life... you need wood, too!
DaPyro
Profile Blog Joined January 2012
Serbia131 Posts
Last Edited: 2012-04-15 10:10:21
April 15 2012 10:08 GMT
#2648
Can someone help me with a php function please

Im creating a function to create 3 drop down lists, the lists are in two arrays either
1.
$colors = array('White' =>'white','Black'=> 'black', 'Red'=>'red','Green'=>'green','Blue'=>'blue','Yellow'=>'yellow','Orange'=>'orange');

or
$fancy_colors = array('cyan' => '33CCFF', 'gold' => 'F5B800', 'pink' => 'FF33CC', 'lime' => 'CCFF33');


my 3 calls are:

selectBox($colors, "Text Color:", "textColor");
selectBox( $colors, "Background Color:", "backColor");
selectBox( $fancy_colors, "Box Color:", "boxColor");


my function:

function selectBox( $list, $title, $name)
{
echo "<p>""$title""<select name=""$name"">";
foreach ($list as $key => $value)
echo "<option value=" . "$value" . ">" . "$key" ." </option>";
echo "</select></p>";
return $value;
}


can anyone help me with why it wont work?
Drone so hard motherfuckers wanna fine me. Whats 50k minerals to a nigga like me? can you please remind me
MisterD
Profile Blog Joined June 2010
Germany1338 Posts
Last Edited: 2012-04-15 11:25:01
April 15 2012 11:22 GMT
#2649
your echo lines with these """""" look rather confusing, i'd assume there's some error in there. I remember from when i wrote some php a few years back, i always put {$variable} in {} because it'd screw up regularly otherwise, maybe try that. but a more readable way to write these things would probably be, to write all html as ' strings and put the $ values in manually without the "-string magic:

echo '<p>'.$title.'<select name="'.$name.'">";


it's not as obvious here but it helps a lot when not using strings, e.g. you can write

echo '<p style="color:red">';

without having to double quote anything etc.


for more help without us having to guess what happens, post some output that gets created. "doesn't work" gives absolutely no indication as to what might be wrong, and a lot of people don't have a php execution environment around and probably won't set one up to test your code themselves to find this information. If it gives an error, post it. If it gives screwed up output, post that.
Gold isn't everything in life... you need wood, too!
tofucake
Profile Blog Joined October 2009
Hyrule19196 Posts
April 15 2012 12:07 GMT
#2650
echo "

$title

Aresien
Profile Blog Joined February 2009
United Kingdom305 Posts
April 19 2012 20:54 GMT
#2651
Hey guys, I was hoping I could get a little bit of help with a project I have due soon.

Basically i've been asked to create a top-down shooter game using Python (pygame). The interesting part of the project though is to create power-ups/weapons that are created in game (not pre-defined). I'm now at the stage where I have the base game which features all the other stuff required, but I still have to implement the power-ups. I'm super rusty with Python right now (not used it for a year or so), does anyone have any suggestions for going about this? Just looking for general ideas, any help would be appriciated!
RoyGBiv_13
Profile Blog Joined August 2010
United States1275 Posts
April 19 2012 21:38 GMT
#2652
On April 12 2012 07:02 mazerr wrote:
Hi TeamLiquid! Long-time (2yr) lurker here, and I finally decided to post, because I need some help! Lengthy read below, but if any of you programming wizards could give some advice I'd appreciate it! I cross-posted this on reddit careeradvice but don't know if I'll get any responses there.

First, a little about my background:

I'm a 23 year old currently living at home. I was a very 'gifted' person when I was younger, ie got As in school w/o effort, played violin and ended up winning a nation-wide HS competition and performed in Carnegie Hall, won local Math competitions, etc, all with very minimal effort. Because of this I developed a superiority complex and became very apathetic regarding what I wanted to do, as I was good at a number of things and a lot of people were pushing me to do 'their' thing. I didn't know what I wanted to do. So I promptly got into a decent engineering school (Rose-Hulman) spent all my time playing WoW, and bombed out. This shattered my superiority complex and triggered depression, which deteriorated over the years to the point where I was living at home, morbidly obese, smoking, and pissing in bottles and letting food rot in my room while I played video games.

I have step-by-step overcome this, and am now trying to get my life back on track, but I need to move out, my parents can simply no longer support me (nor do I wish them to). I REALLY desperately want to begin a career as a programmer. Out of all of the things I've done, I like it the most by far (barring music which I love too personally to want it as a job). I've dabbled in a number of different languages (Python, AS3 (lol), C, Java, and Obj-C) and I really enjoy them all equally, I enjoy just the process of coding and pick it up relatively quickly as far as I can judge (ie finished a semester's course-work of a few of them in a month).

I need to move out within a few months, but I have enough money to support myself for around a year. What I would LIKE to be able to do is to pick a language and become proficient enough at it within a year to support myself (around 18k USD a year where I live) by either freelance, web-design, independent flash-game development, anything really. I realize without a degree getting a steady job would near impossible. So what I would like to know (apologies for the length of the post) is is this possible, or is it just a pipe-dream? Please do keep in mind I can learn things extremely quickly, but I realize there's a significant portion of it that can't be brute-forced. And if it is possible, what language and career should I focus on?

The alternative is for me to find a regular minimum-wage job and try to go to school and learn programming on the side, but in this economy I'd be working most of my time and likely wouldn't have my degree until I'm close to 30, and the thought of just starting my career at thirty makes me have a sick feeling in my stomach :/

TL;DR: Can someone who is able to learn things relatively quickly learn programming to a degree that is able to support them, and if so, what language and/or area of programming should they focus on?

Thank you for your time!


Hi Mazerr! I am an alum from Rose-hulman, and Id love to offer some advice for how to learn programming. You should not feel bad about bombing out of such a school. Its learning style is not for everyone, and I barely survived my way through it. What others have said about picking up programming is definitely true. It takes years of experience before you can turn it into a living.

Dont be discouraged by that! Most people settle into their careers later in life. Getting out of high school, doing well in college, then starting at an entry level position is not the norm.

First bit of advice)
I suggest you find a local hackerspace (google is your friend), and get involved. Those are the local DIY/startup guys, and they love bright self driven people. If you do end up having a natural talent and drive, youll find yourself being picked up before you can even program.

Next bit)
Programming is a big word that means a whole lot of nothing. You could be an embedded programmer, a web programmer (back or front end), a high speed programmer, automotive programmer, open source, high reliability, secure, game designer, etc.. The list goes on and on. You're going to end up pidgeonholing yourself at some point, probably after your first 3 years (it takes about that long to get a handle of basic algorithms and concepts). Focus not on the specific part, but the general feel of what it takes to program. You don't need a degree for that, and good employers will know this, and invest their own money to train you to be good at the specific thing they need you for. Its easier and cheaper to find someone trainable and teach them than it is to pay more for the right fit.

Finally)
Anything is possible, and you really can live off of <20kUSD a year anywhere in the world. You wont get the 20k in your first year learnign to program, though. There is a TON of competition, so focus on getting somewhere EVENTUALLY, not just right that moment.

Any sufficiently advanced technology is indistinguishable from magic
CecilSunkure
Profile Blog Joined May 2010
United States2829 Posts
April 19 2012 22:51 GMT
#2653
On April 20 2012 05:54 Aresien wrote:
Hey guys, I was hoping I could get a little bit of help with a project I have due soon.

Basically i've been asked to create a top-down shooter game using Python (pygame). The interesting part of the project though is to create power-ups/weapons that are created in game (not pre-defined). I'm now at the stage where I have the base game which features all the other stuff required, but I still have to implement the power-ups. I'm super rusty with Python right now (not used it for a year or so), does anyone have any suggestions for going about this? Just looking for general ideas, any help would be appriciated!

You can create a class for your powerup. The class can have data members for the x and y coordinates. I haven't used Pygame for a couple years so I don't remember how images are stored, but I'm sure you can figure out how to get the image onto the powerup if you've completed those other things. Then you can have a method for the functionality of the powerup, and call this method when the player is detected as in collision with the powerup.

If you want advice on how to place the powerups in your levels, there's a lot of ways to do that. The easiest to get set up and working would just be a function that places the powerup within the level at a specified coordinate.
snively
Profile Blog Joined August 2011
United States1159 Posts
April 23 2012 21:50 GMT
#2654
i have some questions. first of all, let me say i suck at programming, so my questions might be wrongly worded or just plain stupid. or both.

now, lets say i am using c++, and i declare a pointer to an integer, and i intend to use it as a dynamically-sized array.
as far as i know, the computer stores bits sequentially, and variables are just chunks of space in memory, in a line.
how does the computer know where to save room for the array? if i declare another integer, how does the computer know where to put it so that it doesnt block the space for the dynamic array? for that matter, does the memory for each part of the array have to next to each other at all? if not, how does the computer know which parts of memory are part of the array and which aren't?

TLDR: how does the computer allocate memory for dynamically-sized arrays?
My religion is Starcraft
MisterD
Profile Blog Joined June 2010
Germany1338 Posts
April 23 2012 23:23 GMT
#2655
it doesn't, you have to do that yourself with malloc / calloc / free.
Gold isn't everything in life... you need wood, too!
Glowbox
Profile Joined June 2010
Netherlands330 Posts
April 23 2012 23:35 GMT
#2656
On April 24 2012 08:23 MisterD wrote:
it doesn't, you have to do that yourself with malloc / calloc / free.


He mentions C++, so why suggest the C-way of allocating? Instead, use new/delete; http://en.wikipedia.org/wiki/New_(C++)
MisterD
Profile Blog Joined June 2010
Germany1338 Posts
April 23 2012 23:37 GMT
#2657
On April 24 2012 08:35 Glowbox wrote:
Show nested quote +
On April 24 2012 08:23 MisterD wrote:
it doesn't, you have to do that yourself with malloc / calloc / free.


He mentions C++, so why suggest the C-way of allocating? Instead, use new/delete; http://en.wikipedia.org/wiki/New_(C++)


oops ^^ haven't used anything c-like in ages ^^ actually never really learned c++, just used it for a bunch of things without knowing what i was doing x.X but well, worked out and doesn't really hurt for study tasks :D
Gold isn't everything in life... you need wood, too!
RoTaNiMoD
Profile Blog Joined January 2004
United States558 Posts
April 23 2012 23:43 GMT
#2658
snively:

When you declare variables without pointers in c++, they are indeed analogous to being "chunks of space in memory, in a line". These variables are stored on the stack. However, dynamic arrays, allocated with the new keyword, are stored in the heap. The heap can be viewed as a vast chunk of available memory, whereas the stack is comparatively limited. Compilers handle the details of heap storage differently, but when you declare an array of 120 items, the metadata of that memory is stored somewhere. The new keyword returns a pointer to the start of the array, but the compiler maintains information about how many elements that array contains, such that when you delete[], everything ends up fine and dandy.

For more information, google/wiki stack vs heap memory.
RoTaNiMoD
Profile Blog Joined January 2004
United States558 Posts
Last Edited: 2012-04-23 23:56:49
April 23 2012 23:55 GMT
#2659
DaPyro:

Assuming that double double-quotes is a way of escaping a single double-quote, your code seems to be fine. Very confusing to look at, but functionally OK. We're gonna need a little more description of what the problem is.

Also, please for the love of God, either A) encase your strings in single quotes so you can use double quotes normally, and use the dot operator to concatenate your php variables, or B) keep with the double quote enclosure but use single-quotes for the HTML. I prefer option A personally, but they each have their merits.

Edit: I think I spoke too soon. I imagine you are expecting some sort of functionality to result from your line of "return $value;". Whatever functionality that is, I'm not even sure, but it's not going to work how you have it set up. What is your goal with the presented code?
MisterD
Profile Blog Joined June 2010
Germany1338 Posts
April 24 2012 09:27 GMT
#2660
On April 24 2012 08:55 RoTaNiMoD wrote:
Edit: I think I spoke too soon. I imagine you are expecting some sort of functionality to result from your line of "return $value;". Whatever functionality that is, I'm not even sure, but it's not going to work how you have it set up. What is your goal with the presented code?


well yes, return $value is stupid there because $value isn't bound to a value outside of the foreach loop. But since he's using echo, the code should be printed out anyways. It might however not be in the right position on the site, search the generated html source for the tags that this piece of code writes to find that out.
Gold isn't everything in life... you need wood, too!
Prev 1 131 132 133 134 135 1032 Next
Please log in or register to reply.
Live Events Refresh
Next event in 1h 20m
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
ProTech128
StarCraft: Brood War
Sea 8971
Hm[arnc] 1568
BeSt 608
Larva 381
Leta 90
Nal_rA 89
Soma 48
sSak 40
NotJumperer 33
Bale 23
[ Show more ]
ToSsGirL 16
zelot 12
eros_byul 0
Dota 2
XaKoH 772
NeuroSwarm166
Counter-Strike
Stewie2K1173
Super Smash Bros
Westballz32
Other Games
Sick161
ViBE134
Livibee87
Mew2King40
Organizations
Other Games
gamesdonequick686
Dota 2
PGL Dota 2 - Main Stream190
Other Games
BasetradeTV65
StarCraft: Brood War
UltimateBattle 22
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 12 non-featured ]
StarCraft 2
• Berry_CruncH227
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
League of Legends
• HappyZerGling141
Upcoming Events
RSL Revival
1h 20m
herO vs MaxPax
Rogue vs TriGGeR
BSL
11h 20m
Replay Cast
15h 20m
Replay Cast
1d
Afreeca Starleague
1d 1h
Sharp vs Scan
Rain vs Mong
Wardi Open
1d 3h
Monday Night Weeklies
1d 8h
Sparkling Tuna Cup
2 days
Afreeca Starleague
2 days
Soulkey vs Ample
JyJ vs sSak
Replay Cast
3 days
[ Show More ]
Afreeca Starleague
3 days
hero vs YSC
Larva vs Shine
Kung Fu Cup
3 days
Replay Cast
3 days
KCM Race Survival
4 days
The PondCast
4 days
WardiTV Team League
4 days
Replay Cast
4 days
WardiTV Team League
5 days
RSL Revival
6 days
Cure vs Zoun
WardiTV Team League
6 days
BSL
6 days
Liquipedia Results

Completed

Jeongseon Sooper Cup
WardiTV Winter 2026
Underdog Cup #3

Ongoing

KCM Race Survival 2026 Season 1
BSL Season 22
CSL Elite League 2026
RSL Revival: Season 4
Nations Cup 2026
NationLESS Cup
BLAST Open Spring 2026
ESL Pro League S23 Finals
ESL Pro League S23 Stage 1&2
PGL Cluj-Napoca 2026
IEM Kraków 2026
BLAST Bounty Winter 2026
BLAST Bounty Winter Qual

Upcoming

ASL Season 21
Acropolis #4 - TS6
2026 Changsha Offline CUP
CSL 2026 SPRING (S20)
CSL Season 20: Qualifier 1
Acropolis #4
IPSL Spring 2026
Kung Fu Cup 2026 Grand Finals
HSC XXIX
uThermal 2v2 2026 Main Event
IEM Cologne Major 2026
Stake Ranked Episode 2
CS Asia Championships 2026
Asian Champions League 2026
IEM Atlanta 2026
PGL Astana 2026
BLAST Rivals Spring 2026
CCT Season 3 Global Finals
IEM Rio 2026
PGL Bucharest 2026
Stake Ranked Episode 1
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.