• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 10:26
CEST 16:26
KST 23:26
  • 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 Tall8HomeStory 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 ASL44Weekly 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 Statistics for vetoed/disliked maps Esports World Cup 2025 - Final Player Roster How does the number of casters affect your enjoyment of esports? Weekly Cups (June 23-29): Reynor in world title form?
Tourneys
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 HomeStory Cup 27 (June 27-29)
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/ Help: rep cant save Flash Announces Hiatus From ASL BW General Discussion [ASL19] Finals Recap: Standing Tall
Tourneys
[Megathread] Daily Proleagues [BSL20] GosuLeague RO16 - Tue & Wed 20:00+CET The Casual Games of the Week Thread [BSL20] ProLeague LB Final - Saturday 20:00 CET
Strategy
Simple Questions, Simple Answers I am doing this better than progamers do.
Other Games
General Games
Nintendo Switch Thread Stormgate/Frost Giant Megathread 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
2024 - 2025 Football Thread NBA General Discussion Formula 1 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
from making sc maps to makin…
Husyelt
Blog #2
tankgirl
Game Sound vs. Music: The Im…
TrAiDoS
StarCraft improvement
iopq
Heero Yuy & the Tax…
KrillinFromwales
Trip to the Zoo
micronesia
Customize Sidebar...

Website Feedback

Closed Threads



Active: 571 users

The Big Programming Thread - Page 44

Forum Index > General Forum
Post a Reply
Prev 1 42 43 44 45 46 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.
mindoftw
Profile Joined April 2011
2 Posts
April 01 2011 17:19 GMT
#861
So ive got a question since there seems to be a lot of intelligent people on here. I am making a program in see and i am using malloc to allocate some memory to store integers in that block of memory.

Say for example i have something like:
number = (int*) malloc(userNum);

and then i want to store a number in each location how would i do that? I tried something like:
*primes+(*count) = i;

inside of a for loop, but its not actually storing "i" into the memory location. I have a memory leak and i was hoping someone could help me out.
Oracle
Profile Blog Joined May 2007
Canada411 Posts
Last Edited: 2011-04-01 17:33:22
April 01 2011 17:28 GMT
#862
First of all it should be malloc(sizeof(int)) i believe, havent used C in a while

second of all, your assignment makes no sense.

you are dereferences two pointers to integers (im assuming), then adding their values, and attempting to assign i to that?

try this

int *primes;

primes = malloc(k * sizeof(int)) (where k is the amount of primes youd like to store)

to get an array of prime integers

then prime[i] = ith prime (for assignment)


EDIT: Oh i see what you were trying to do

You were dereferencing incorrectly:

*(Primes+count) where count is an iterator should work
Kambing
Profile Joined May 2010
United States1176 Posts
April 01 2011 17:31 GMT
#863
On April 02 2011 02:19 mindoftw wrote:
So ive got a question since there seems to be a lot of intelligent people on here. I am making a program in see and i am using malloc to allocate some memory to store integers in that block of memory.

Say for example i have something like:
number = (int*) malloc(userNum);

and then i want to store a number in each location how would i do that? I tried something like:
*primes+(*count) = i;

inside of a for loop, but its not actually storing "i" into the memory location. I have a memory leak and i was hoping someone could help me out.


malloc(n) allocates (roughly) n bytes of data and returns a pointer to the beginning of that block.

If you are intending on using malloc to create an array of integers, you need the argument to malloc to be some multiple of the size of ints, e.g.,

numbers = malloc(sizeof(int) * 5)

allocates enough memory for 5 ints.

To utilize the space, you can use array-style notation to denote at which position you wish to store data, e.g.,

numbers[2] = i

stores the int i at the 2nd position (i.e., the 3rd element) of the block of memory you allocated. This is just short-hand for doing the manual pointer arithmetic and dereferencing the resulting pointer to access the storage location:

*(numbers+2) = i

where the "+2" really means "move the pointer 2 * sizeof(int) bytes over from numbers".

You attempt this with your code above but it doesn't work. Without knowing what the declarations of primes and count, I can't say for certain what they are doing, but if they are pointers, you actually dereferencing their values and adding them together on the left-hand side rather than doing pointer arithmetic.
DisneylandSC
Profile Joined November 2010
Netherlands435 Posts
Last Edited: 2011-04-01 18:30:53
April 01 2011 18:28 GMT
#864
Perhaps these are some useful links for people who want to begin learning python. I know that I personally really liked them.

-Overview of the program
http://code.google.com/intl/nl/edu/languages/google-python-class/

-The videos belonging to the above mentioned course
+ Show Spoiler +










And mayby also these 2 videos, which are a bit more thorough,
+ Show Spoiler +





mindoftw
Profile Joined April 2011
2 Posts
April 01 2011 20:23 GMT
#865
On April 02 2011 02:31 Kambing wrote:
Show nested quote +
On April 02 2011 02:19 mindoftw wrote:
So ive got a question since there seems to be a lot of intelligent people on here. I am making a program in see and i am using malloc to allocate some memory to store integers in that block of memory.

Say for example i have something like:
number = (int*) malloc(userNum);

and then i want to store a number in each location how would i do that? I tried something like:
*primes+(*count) = i;

inside of a for loop, but its not actually storing "i" into the memory location. I have a memory leak and i was hoping someone could help me out.


malloc(n) allocates (roughly) n bytes of data and returns a pointer to the beginning of that block.

If you are intending on using malloc to create an array of integers, you need the argument to malloc to be some multiple of the size of ints, e.g.,

numbers = malloc(sizeof(int) * 5)

allocates enough memory for 5 ints.

To utilize the space, you can use array-style notation to denote at which position you wish to store data, e.g.,

numbers[2] = i

stores the int i at the 2nd position (i.e., the 3rd element) of the block of memory you allocated. This is just short-hand for doing the manual pointer arithmetic and dereferencing the resulting pointer to access the storage location:

*(numbers+2) = i

where the "+2" really means "move the pointer 2 * sizeof(int) bytes over from numbers".

You attempt this with your code above but it doesn't work. Without knowing what the declarations of primes and count, I can't say for certain what they are doing, but if they are pointers, you actually dereferencing their values and adding them together on the left-hand side rather than doing pointer arithmetic.


You are a gentleman kind sir, helped me out a lot thanks.
Blisse
Profile Blog Joined July 2010
Canada3710 Posts
Last Edited: 2011-04-01 20:42:51
April 01 2011 20:41 GMT
#866
Top 61 of Junior Competition in the Canadian Computing Competition. Good for an amateur like me...
60/75, hurrah!

Here is the question I asked a few pages back. It's a .pdf, and I couldn't get Question 5. The solution they give makes me cry.

http://access.mmhs.ca/ccc/2011/2011JuniorProblems.pdf
There is no one like you in the universe.
Phrost
Profile Blog Joined May 2010
United States4008 Posts
April 01 2011 21:33 GMT
#867
Does anyone know of an alternate helper program like visual assist for Visual Studio 2010?

I'm writing C++ CLR applications in class and the lack of intellisense is making my brain explode.

I don't really want to pay $100 for a Visual Assist license =.=
iamphrost.tumblr.com // http://howtobebettermagicplayer.tumblr.com // twitter @phrost_
Glowbox
Profile Joined June 2010
Netherlands330 Posts
Last Edited: 2011-04-01 21:40:24
April 01 2011 21:39 GMT
#868
On April 02 2011 06:33 Phrost wrote:
Does anyone know of an alternate helper program like visual assist for Visual Studio 2010?

I'm writing C++ CLR applications in class and the lack of intellisense is making my brain explode.

I don't really want to pay $100 for a Visual Assist license =.=


I've been looking for an alternative for Visual Assist X (searched stackoverflow, google, tried 2 alternative addons) but VAX is really the best around.

(There are 'free' versions floating around on the internet, but are hard to find )
MisterD
Profile Blog Joined June 2010
Germany1338 Posts
Last Edited: 2011-04-01 21:55:32
April 01 2011 21:55 GMT
#869
On April 02 2011 05:41 Blisse wrote:
Top 61 of Junior Competition in the Canadian Computing Competition. Good for an amateur like me...
60/75, hurrah!

Here is the question I asked a few pages back. It's a .pdf, and I couldn't get Question 5. The solution they give makes me cry.

http://access.mmhs.ca/ccc/2011/2011JuniorProblems.pdf


well what they specify there should be a tree of some sorts (graph theory!). Basically, what you need to do to get the solution is running a graph scanning algorithm, such as "depth"- or "breadth first search" from all nodes except marc's node (the Nth node), each of these produces a set of reachable nodes. Then you can chose an arbitrary combination of all those sets and get a feasible solution. Putting all possible combinations of sets together gives you the final result.

Example image (green nodes are nodes reached by the graph scanning from the respective initial node) for the example solution presented in your pdf:

[image loading]
Gold isn't everything in life... you need wood, too!
OPSavioR
Profile Joined March 2010
Sweden1465 Posts
April 04 2011 09:01 GMT
#870
Anyone know a good Flash guide i mean i dont know shit about it and i have to finish my project
i dunno lol
Garrl
Profile Blog Joined February 2010
Scotland1972 Posts
April 04 2011 09:07 GMT
#871
On April 04 2011 18:01 OPSavioR wrote:
Anyone know a good Flash guide i mean i dont know shit about it and i have to finish my project


14cc every game.

But seriously, it's impossible to know what level you're at to offer you guides; tell us a reference point as to how much coding you've done before.
Craton
Profile Blog Joined December 2009
United States17246 Posts
April 04 2011 19:22 GMT
#872
On March 23 2011 03:36 TheBB wrote:
Did we do this yet?

K&R greatly irks me due to the lack of symmetry. I find it much harder to keep track of what goes together and what doesn't.
twitch.tv/cratonz
Siniyas
Profile Joined January 2011
Germany66 Posts
April 04 2011 19:31 GMT
#873
General question for guys with programming experience in java. Is good to learn JSP at this time? I find it very intrigueing and would like to get into it, but all over the it is written, that its dying, since it is now deprecrated as a view for servlets and it seems JSF is taking over.

So what should i learn if i want to get into dynamic web design with java?
Let it rip
Badjas
Profile Blog Joined October 2008
Netherlands2038 Posts
April 04 2011 19:34 GMT
#874
Siniyas, if it is deprecated, don't start learning it. Whenever functionality gets deprecated, it is picked up by a new API that is better in one or more ways. For example, a more consistent API, easier to optimize on the implementation side, new features that wouldn't fit nice in the old API, etc.

Find out what the intended replacement is. (I can't advice you on any specifics with Java)
I <3 the internet, I <3 you
_Spooky_
Profile Blog Joined June 2009
United States71 Posts
April 06 2011 00:55 GMT
#875
Hey guys,

I have a question corresponding to Tokenizer's and String[] in Java.

I have a code where the input is a String[] and my professor said we have to use token method to get the input into Pig Latin.

I have the code complete except I don't know how to get the array into a string so I can use the token method. Which calls for Tokenizer (String str)

I have a feeling that I'm over thinking it though.
Thanks for any help
As a well-spent day brings happy sleep, so a life well spent brings happy death. -Da Vinci
slained
Profile Blog Joined October 2006
Canada966 Posts
April 06 2011 01:07 GMT
#876
Is anyone in Toronto fluent in C enough to help me out. I could trade sc2 lessons for programming perhaps lol ^^

Kinda stuck on a sockets assignment atm, c isn't so intuitive for me with all the memory problems.
stafu
Profile Blog Joined January 2009
Australia1196 Posts
April 06 2011 01:23 GMT
#877
On April 06 2011 09:55 _Spooky_ wrote:
Hey guys,

I have a question corresponding to Tokenizer's and String[] in Java.

I have a code where the input is a String[] and my professor said we have to use token method to get the input into Pig Latin.

I have the code complete except I don't know how to get the array into a string so I can use the token method. Which calls for Tokenizer (String str)

I have a feeling that I'm over thinking it though.
Thanks for any help

Look up StringTokenizer in the Java documentation (which is really good, btw).

Can you elaborate on what the input is? Is it just a String? or a String array?

To get each word out, StringTokenizer st = new StringTokenizer(yourInputString), then nextWord = st.nextToken(). You should probably use StringBuffer to create the resulting string.
kuresuti
Profile Blog Joined December 2009
1393 Posts
April 06 2011 11:56 GMT
#878
If anyone would be kind enough to help me out it would be appreciated!

I have a loadList function which reads the lines of a file and stores them in an array of strings. The code seems to work, I've tried it with local variables and such, it just doesn't want to save them in the array when exiting the function. What confuses me is that I've used the EXACT same method elsewhere where it works as expected.

+ Show Spoiler [Function that works] +


int main()
{
string s[MAX_SIZE];
int i = 0;
addName(s, i); // This works fine
}

int addName(string names[], int &curSize)
{
system("cls");

string t;

getline(cin, t);
names[curSize] = t;

curSize++;

return 0;
}
]


+ Show Spoiler [Function that doesn't work] +


int main()
{
string s[MAX_SIZE];
int i = 0;
loadList(s, "asd.txt"); // This does not want to store the file contents in s[];
}

int loadList(string names[], const string fileName)
{
ifstream f(fileName.c_str());
int p = 0;
string t;

while(!f.eof())
{
getline(f, t); // Tested this multiple times in different ways, it seems to work.
names[p] = t; // I've checked names[p] multiple times after this, and it does store t;
p++;
}

f.close();

return 0;
}


I've removed some unnecessary code from there, to keep it clean. Any ideas as to what could be wrong?
tofucake
Profile Blog Joined October 2009
Hyrule19029 Posts
April 06 2011 14:54 GMT
#879
The solution is &
Liquipediaasante sana squash banana
kuresuti
Profile Blog Joined December 2009
1393 Posts
April 06 2011 16:24 GMT
#880
On April 06 2011 23:54 tofucake wrote:
The solution is &


Could you clarify?
Prev 1 42 43 44 45 46 1031 Next
Please log in or register to reply.
Live Events Refresh
Next event in 1h 35m
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
Harstem 545
Lowko422
ProTech66
StarCraft: Brood War
Britney 47569
Rain 5500
Sea 3484
Jaedong 1870
EffOrt 1197
BeSt 457
Stork 407
actioN 293
ZerO 283
ToSsGirL 272
[ Show more ]
Snow 205
Light 158
hero 102
Mong 74
Sharp 72
Shinee 61
Pusan 53
Mind 47
Sea.KH 46
Rush 40
sSak 36
PianO 28
Terrorterran 24
Nal_rA 22
Noble 18
GoRush 13
ajuk12(nOOB) 12
Sacsri 11
yabsab 11
sorry 10
soO 8
SilentControl 8
IntoTheRainbow 7
JulyZerg 7
zelot 3
scan(afreeca) 2
Dota 2
qojqva3530
XcaliburYe496
Counter-Strike
byalli250
markeloff218
edward68
kRYSTAL_26
Super Smash Bros
Mew2King140
Other Games
hiko1148
B2W.Neo938
DeMusliM758
crisheroes344
Happy256
ArmadaUGS108
KnowMe54
QueenE38
ZerO(Twitch)24
Organizations
StarCraft: Brood War
Kim Chul Min (afreeca) 6
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 14 non-featured ]
StarCraft 2
• StrangeGG 71
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• blackmanpl 3
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
League of Legends
• Nemesis7512
• TFBlade765
Upcoming Events
WardiTV European League
1h 35m
ByuN vs NightPhoenix
HeRoMaRinE vs HiGhDrA
Krystianer vs sebesdes
MaxPax vs Babymarine
SKillous vs Mixu
ShoWTimE vs MaNa
Replay Cast
9h 35m
RSL Revival
19h 35m
herO vs SHIN
Reynor vs Cure
OSC
22h 35m
WardiTV European League
1d 1h
Scarlett vs Percival
Jumy vs ArT
YoungYakov vs Shameless
uThermal vs Fjant
Nicoract vs goblin
Harstem vs Gerald
FEL
1d 1h
Korean StarCraft League
1d 12h
CranKy Ducklings
1d 19h
RSL Revival
1d 19h
FEL
2 days
[ Show More ]
Sparkling Tuna Cup
2 days
RSL Revival
2 days
FEL
2 days
BSL: ProLeague
3 days
Dewalt vs Bonyth
Replay Cast
4 days
Replay Cast
4 days
The PondCast
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
YaLLa Compass Qatar 2025

Upcoming

CSLPRO Last Chance 2025
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.