• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 14:09
CEST 20:09
KST 03:09
  • 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
[ASL19] Finals Recap: Standing Tall9HomeStory Cup 27 - Info & Preview18Classic wins Code S Season 2 (2025)16Code S RO4 & Finals Preview: herO, Rogue, Classic, GuMiho0TL Team Map Contest #5: Presented by Monster Energy6
Community News
Flash Announces Hiatus From ASL50Weekly Cups (June 23-29): Reynor in world title form?12FEL Cracov 2025 (July 27) - $8000 live event16Esports World Cup 2025 - Final Player Roster16Weekly Cups (June 16-22): Clem strikes back1
StarCraft 2
General
The SCII GOAT: A statistical Evaluation The GOAT ranking of GOAT rankings How does the number of casters affect your enjoyment of esports? Statistics for vetoed/disliked maps Esports World Cup 2025 - Final Player Roster
Tourneys
Master Swan Open (Global Bronze-Master 2) RSL: Revival, a new crowdfunded tournament series [GSL 2025] Code S: Season 2 - Semi Finals & Finals $5,100+ SEL Season 2 Championship (SC: Evo) FEL Cracov 2025 (July 27) - $8000 live event
Strategy
How did i lose this ZvP, whats the proper response Simple Questions Simple Answers
Custom Maps
[UMS] Zillion Zerglings
External Content
Mutation # 480 Moths to the Flame Mutation # 479 Worn Out Welcome Mutation # 478 Instant Karma Mutation # 477 Slow and Steady
Brood War
General
BGH Auto Balance -> http://bghmmr.eu/ Player “Jedi” cheat on CSL Unit and Spell Similarities Help: rep cant save Flash Announces Hiatus From ASL
Tourneys
[Megathread] Daily Proleagues [BSL20] Grand Finals - Sunday 20:00 CET Small VOD Thread 2.0 [BSL20] GosuLeague RO16 - Tue & Wed 20:00+CET
Strategy
Simple Questions, Simple Answers I am doing this better than progamers do.
Other Games
General Games
Stormgate/Frost Giant Megathread Nintendo Switch Thread Path of Exile What do you want from future RTS games? Beyond All Reason
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
Heroes of StarCraft mini-set
TL Mafia
TL Mafia Community Thread Vanilla Mini Mafia
Community
General
US Politics Mega-thread Things Aren’t Peaceful in Palestine Russo-Ukrainian War Thread Trading/Investing Thread The Games Industry And ATVI
Fan Clubs
SKT1 Classic Fan Club! Maru Fan Club
Media & Entertainment
Anime Discussion Thread [Manga] One Piece [\m/] Heavy Metal Thread
Sports
Formula 1 Discussion 2024 - 2025 Football Thread NBA General Discussion TeamLiquid Health and Fitness Initiative For 2023 NHL Playoffs 2024
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
Blogs
Culture Clash in Video Games…
TrAiDoS
from making sc maps to makin…
Husyelt
Blog #2
tankgirl
StarCraft improvement
iopq
Trip to the Zoo
micronesia
Customize Sidebar...

Website Feedback

Closed Threads



Active: 772 users

The Big Programming Thread - Page 133

Forum Index > General Forum
Post a Reply
Prev 1 131 132 133 134 135 1031 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
Hyrule19030 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
Hyrule19030 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 1031 Next
Please log in or register to reply.
Live Events Refresh
Big Brain Bouts
16:00
#97
RotterdaM680
Liquipedia
FEL
16:00
Polish Championship: Qualifier
IndyStarCraft 227
CranKy Ducklings71
Liquipedia
WardiTV European League
16:00
Swiss Groups Day 2
YoungYakov vs ShamelessLIVE!
uThermal vs Fjant
Nicoract vs goblin
Harstem vs Gerald
WardiTV851
TKL 253
Liquipedia
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
RotterdaM 680
TKL 253
IndyStarCraft 227
Hui .187
UpATreeSC 75
StarCraft: Brood War
Britney 30653
Calm 3783
Rain 2340
Horang2 881
Larva 458
BeSt 232
Mind 182
Movie 82
Mong 70
sas.Sziky 48
[ Show more ]
Barracks 47
Shinee 33
yabsab 32
soO 20
Free 19
Shine 13
Dewaltoss 9
Stormgate
NightEnD11
Dota 2
Gorgc12527
qojqva3066
League of Legends
Grubby3293
singsing2146
Counter-Strike
ScreaM2894
fl0m1629
Foxcn372
byalli247
Other Games
FrodaN1291
Beastyqt605
Fuzer 255
Trikslyr57
ZombieGrub22
Nathanias14
Organizations
Other Games
BasetradeTV24
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 16 non-featured ]
StarCraft 2
• intothetv
• AfreecaTV YouTube
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Dota 2
• WagamamaTV532
League of Legends
• Nemesis5061
• Jankos1520
• TFBlade1053
Other Games
• imaqtpie867
• Shiphtur377
Upcoming Events
Korean StarCraft League
8h 51m
CranKy Ducklings
15h 51m
RSL Revival
15h 51m
ByuN vs Cham
herO vs Reynor
FEL
21h 51m
RSL Revival
1d 15h
Clem vs Classic
SHIN vs Cure
FEL
1d 17h
BSL: ProLeague
1d 23h
Dewalt vs Bonyth
Replay Cast
3 days
Sparkling Tuna Cup
3 days
The PondCast
4 days
[ Show More ]
Replay Cast
5 days
RSL Revival
5 days
Replay Cast
6 days
RSL Revival
6 days
Liquipedia Results

Completed

Proleague 2025-06-28
HSC XXVII
Heroes 10 EU

Ongoing

JPL Season 2
BSL 2v2 Season 3
BSL Season 20
Acropolis #3
KCM Race Survival 2025 Season 2
CSL 17: 2025 SUMMER
Copa Latinoamericana 4
Championship of Russia 2025
RSL Revival: Season 1
Murky Cup #2
BLAST.tv Austin Major 2025
ESL Impact League Season 7
IEM Dallas 2025
PGL Astana 2025
Asian Champions League '25
BLAST Rivals Spring 2025
MESA Nomadic Masters
CCT Season 2 Global Finals
IEM Melbourne 2025

Upcoming

2025 ACS Season 2: Qualifier
CSLPRO Last Chance 2025
2025 ACS Season 2
CSLPRO Chat StarLAN 3
K-Championship
uThermal 2v2 Main Event
SEL Season 2 Championship
FEL Cracov 2025
Esports World Cup 2025
StarSeries Fall 2025
FISSURE Playground #2
BLAST Open Fall 2025
BLAST Open Fall Qual
Esports World Cup 2025
BLAST Bounty Fall 2025
BLAST Bounty Fall Qual
IEM Cologne 2025
FISSURE Playground #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 © 2025 TLnet. All Rights Reserved.