TI3 Western Qualifiers Recap
[WCS EU] Season 1 Finals -…
[SPL] Round 5 Week 3 Revie…
[GSTL] Week 10 - Prime Tim…
[WCS KR] Innovation vs. Sy…
This Week in Starcraft 2: …
TL Site Changes
[WCS EU] Grubby, MMA, Ret …
Pizza: All Tiers Reached
Vici and RisingStars Advan…
Up&Down groups for 2013 WC…
HerO, Revival Interviews -…
Get 50% off Papa John's pi…
TL Advertising Features
US Politics Megathread
The XBox One
Ice Fingers while gaming
Men's Fashion Thread
Creative Writing Thread
TL Site Changes
Ask TL Staff Anything
The Automated Ban List
TL.net Ten Commandments
Barcraft Ludwigshafen
The Keen Fanclub
The SeleCT Fanclub
NuBrGNi's Stream
[Stream] Mystery
Any fix for Twitch tv lag?
Simple Questions Simple An…
The Ultimate Headphone/Aud…
very low FPS, plz help
Computer Build Resource Th…
[Interview] NSH vs MVP 2…
Incredible Miracle spons…
GM / Master map hacker a…
New Starcraft Song by Be…
This Week in Starcraft 2…
Pizza: All Tiers Reached
SC2 LR Resources
LaG Gaming 1000$ Tournament
Ottawa's Got Game! Estimat…
[GSTL] NSH vs MVP 2013 S1
[WCS EU] Finals Day 1 Prem…
[D] MVPs build order vs TL…
[L][D]HotS Terran Mech Res…
[G] The MAN Train: Immorta…
[G] [D] Parting's PvP Prol…
The HotS Protoss Help Me T…
[D] (4) Reclamation (2v2 B…
OneGoal: A better SC2 [Pro…
Work In Progress Melee Maps
[A] Starbow
Map Jam & Challenge #5
The Great Dota 2 Key Req…
[Stream] Fachh[P]worstpl…
General Discussion
The International Intera…
Beyond the Summit and TL…
Dota 2 QQ thread
[G-1] LAN Finals
[D2L] Fnatic vs. Mouz
RaidCall EMS One Americas …
Starladder Season 6
Dota 2 General LR thread
Simple Questions, Simple A…
Question: Luna Item Build
[G]uide to Lifestealer
Newly ported Hero discussi…
[G] In-Game Dota Guide for…
broodwar merchandise
snipealots 24/7 afreeca …
SC SUM - StarCraft Super…
[D] New BW Server
BW Liquibet Season 25
2 Artificial Intelligenc…
D Ranks Teamleague Season 4
Defiler Tour #57 [75$]
[GC S3] Gambit's Cup Semif…
[TLS2] Results and Standings
[R&S] 13th SOSPA Ranking T…
Simple Questions, Simple A…
Increasing APM/EAPM
Practice Partner Thread
Challenger map on Starcraf…
Magic: The Gathering Onl…
FINALLY! - The 2013 NHL …
2012 - 2013 Football Thr…
UFC 160: Velasquez vs Bi…
Champions League/Europa …
Mafia Podcast!
[T] Bastard "Mini" Mafia!
[M][N] Les Mafia
General Training Recommend…
Creating a healthy grocery…
Running Thread
Leta - Movie
Michael - skyline
Anytime - Beast
By.Hero - Shuttle
Anytime - Pusan
Customize Sidebar...

Website Feedback

Closed Threads


IRC Web Chat

TeamSpeak 3 (57 users)


Active: 5347 users

The Big Programming Thread - Page 111

Forum Index > General Forum 1 2 3 4 5 6 7 8 9 10 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 200 296 297 298 299 300 301 302 303 304 305 306
 
 ranshaked   United States. January 26 2012 14:05. Posts 810
Profile Blog # 

On January 26 2012 13:29 Kentor wrote:
that's where you end your braces? my head hurts...

and you need to initialize your loop counter variable.
plus you are never changing the variable sum. look at your program. at what point do you assign the variable sum anything new? certainly not this line

total=sum+number;



+ Show Spoiler +

This is what I've got all together now. The problem is this:

I feel like I'm reading this thing wrong. I set it to run 5 tests. It works, but it only stores the LAST value that is more than 500.

For instance, I can type in, 5, 30, 20, 30, 25 and it will output 625...It only stores the last value that is over the 500 when multiplied. Shouldn't it be storing and adding them?
Should it go 30*30=900, so it stores 30 in the sum, then it sees 30 again, so it adds another 30 to the sum to equal 60, and then it sees 25 so it adds 25 to the sum, which will equal 85 and then multiples 85*85 to get 7225?

Does my sum have to be changed to sum=total or something? God I wish someone would just give me the answer so I can work it backward and see what's going on :/ I feel like an idiot when stuff doesn't click.
Old Post

 
 Kentor  *   United States. January 26 2012 14:24. Posts 5776
Profile Blog # 
here's my answer

+ Show Spoiler +
Old Post

 
 ranshaked   United States. January 26 2012 14:38. Posts 810
Profile Blog # 
Thank you, I finally figured it out :/ I wish we could have used a while loop :/ He specifically wanted us to us FOR, which really annoys me. Anyway, I got it working.

I used sum+=number to store it ;X

thank you a lot
Old Post

 
 Terranist   United States. January 26 2012 15:19. Posts 2287
Profile Blog # 
just beginning here. trying an exercise from my text. the exercise is to "make a carpool savings calculator" in C. any help on what i'm doing wrong would be much appreciated because i cannot figure it out.

running the program
+ Show Spoiler +

why does it not accept the first input when asking how many miles i drive per day and why are the calculations messed up?

the code
+ Show Spoiler +
The Show of a Lifetime
Old Post

 
 Kentor  *   United States. January 26 2012 15:36. Posts 5776
Profile Blog # 
try taking out "\n" in scanf
Old Post

 
 ObliviousNA   United States. January 26 2012 15:44. Posts 448
Profile # 
Taking the \n out of scanf will eliminate your 'double entry' for the first scanf, but your real error here is that you are using & (ampersands) on the printf statements at the end. The ampersand refers to a pointer (you're passing in the memory location essentially), so printing the memory results in garbage. In all likelihood, it was just keeping/printing what was in the buffer already.

That should fix it.
Last edit: 2012-01-26 16:07:18
Theory is when you know everything but nothing works. Practice is when everything works but no one knows why. In our lab, theory and practice are combined: nothing works and no one knows why.
Old Post

 
 Terranist   United States. January 27 2012 05:57. Posts 2287
Profile Blog # 
thanks for the help guys. your advice really helped. i'm getting better at this one step at a time.
The Show of a Lifetime
Old Post

 
 Millitron   United States. January 27 2012 07:28. Posts 1251
Profile Blog # 
I don't have any question right now or anything, I just wanted to talk about how awesome sockets are.

I just started programming for my Networking class, and wow, sockets are pretty boss.

Who else loves sockets?
Who called in the fleet?
Old Post

 
 scarymeerkat   Canada. January 28 2012 00:51. Posts 107
Profile # 
another question here:

+ Show Spoiler +

I have that code, and what it is supposed to do is read in 100 int's from a text file. I read them into a temporary string, then convert that string to an integer and put the integer into an array. However, I'm encountering problems that have nothing to do with the integer array. When I run this code with a file that has a few 1 digit int's and mostly 2 digits ints, only around the first 50 are printed out by this: printf("%s ", tmp);
There is also a little bit of funky spacing when this occurs. However, if I run it with a different file, consisting entirely of 1 digit integers, all are printed out successfully.

I used an online random number generator to generate the numbers in the first file, and the output it gave had some funky spacing. However, I went through and got rid of all the tabs etc. that I could see so that hopefully each line was in the form:

11\n

The other thing is, I didn't expect that to make a difference, because tmp is only 2 char's big! And I called fgets with 3 as the second argument.

Is there something wrong with my code? Or is there some kind of unseen character in the text file I am using that is somehow screwing something up.

This is the problematic text file: num.txt - 291 bytes

EDIT: After a bit more searching, I found my problem. The problem was not with the file, but just the fact that it was reading in 2 digit numbers. I feel a bit silly now, because fgets was only reading in "11" of "11\n" leaving the \n untouched. Then the next time fgets was called, it would grab the newline, and do the same thing with that, resulting in appx. half my input being deprecated.
Last edit: 2012-01-28 01:44:29
"From... BootySmackarack" - Artosis reading GOM interview questions
Old Post

 
 robih   Austria. January 28 2012 04:38. Posts 962
Profile # 
hey guys

I'd like to contribute to some SC2 opensource project, but my google search didn't really give good results.

do you know about any where i could help?
Old Post

 
 ObliviousNA   United States. January 28 2012 05:19. Posts 448
Profile # 

On January 28 2012 00:51 scarymeerkat wrote:
another question here:

+ Show Spoiler +

I have that code, and what it is supposed to do is read in 100 int's from a text file. I read them into a temporary string, then convert that string to an integer and put the integer into an array. However, I'm encountering problems that have nothing to do with the integer array. When I run this code with a file that has a few 1 digit int's and mostly 2 digits ints, only around the first 50 are printed out by this: printf("%s ", tmp);
There is also a little bit of funky spacing when this occurs. However, if I run it with a different file, consisting entirely of 1 digit integers, all are printed out successfully.

I used an online random number generator to generate the numbers in the first file, and the output it gave had some funky spacing. However, I went through and got rid of all the tabs etc. that I could see so that hopefully each line was in the form:

11\n

The other thing is, I didn't expect that to make a difference, because tmp is only 2 char's big! And I called fgets with 3 as the second argument.

Is there something wrong with my code? Or is there some kind of unseen character in the text file I am using that is somehow screwing something up.

This is the problematic text file: num.txt - 291 bytes

EDIT: After a bit more searching, I found my problem. The problem was not with the file, but just the fact that it was reading in 2 digit numbers. I feel a bit silly now, because fgets was only reading in "11" of "11\n" leaving the \n untouched. Then the next time fgets was called, it would grab the newline, and do the same thing with that, resulting in appx. half my input being deprecated.


You probably figured this out, but you'll want to use one of the 'getline' functions to consume text until \n or EOF is reached. Also (and I'm no expert in c syntax) you'll want to phrase it something like this:

int index = 0;
while(getline(stream, stringVariable) != null)
{
if(index > arrayLength - 1)
{
break; //printout - shouldn't happen if your array/file are same size
}

stringArray[index++] = stringVariable;
//or
intArray[index++] = Convert.ToInteger(stringVariable);


}

fClose(stream);


This is generally considered safer/better, because it won't crash if you try to read past the end of the file. Also, you can change the amount of data you read in the file with only 1 variable.
Last edit: 2012-01-28 05:27:50
Theory is when you know everything but nothing works. Practice is when everything works but no one knows why. In our lab, theory and practice are combined: nothing works and no one knows why.
Old Post

 
 mmp   United States. January 28 2012 05:57. Posts 2126
Profile Blog # 

On January 28 2012 04:38 robih wrote:
hey guys

I'd like to contribute to some SC2 opensource project, but my google search didn't really give good results.

do you know about any where i could help?

What did you have in mind? You'll probably have to start it yourself.
I (λ (foo) (and (<3 foo) ( T_T foo) (RAGE foo) )) Starcraft
Old Post

 
 Bigpet   Germany. January 29 2012 06:15. Posts 526
Profile # 

On January 28 2012 05:57 mmp wrote:

Show nested quote +


What did you have in mind? You'll probably have to start it yourself.

well the TL App is tangentially SC2 related : http://www.teamliquid.net/forum/viewmessage.php?topic_id=304078

also there are several SC2 replay format parser like: https://github.com/GraylinKim/sc2reader/wiki
I'm NOT the caster with a similar nick
Old Post

 
 Jaso   United States. January 29 2012 08:27. Posts 1505
Profile Blog # 
With little to no knowledge in programming and an AP Computer Science book, about how long do you guys think it would take to learn Java to a high enough level to get a 5 on the AP test? (in hours, probably.)
derp
Old Post

 
 mmp   United States. January 29 2012 08:37. Posts 2126
Profile Blog # 

On January 29 2012 08:27 Jaso wrote:
With little to no knowledge in programming and an AP Computer Science book, about how long do you guys think it would take to learn Java to a high enough level to get a 5 on the AP test? (in hours, probably.)

Never took the AP comp sci, but at a glance it doesn't appear very relevant beyond basic OOP principles.

Read this to get started: http://docs.oracle.com/javase/tutorial/java/index.html
I (λ (foo) (and (<3 foo) ( T_T foo) (RAGE foo) )) Starcraft
Old Post

 
 Patriot.dlk   Sweden. January 29 2012 08:42. Posts 5444
Profile Blog # 
Recently tried some groovy. Mind blown!

Seriously awesome. Anyone else had the same experience?
Old Post

 
 mmp   United States. January 29 2012 08:54. Posts 2126
Profile Blog # 

On January 29 2012 08:42 Patriot.dlk wrote:
Recently tried some groovy. Mind blown!

Seriously awesome. Anyone else had the same experience?

Yeah, a friend and I used it for an nlp project. By the time we were done we barely understand what we had written inside all of the closures. What a bitch to debug.
I (λ (foo) (and (<3 foo) ( T_T foo) (RAGE foo) )) Starcraft
Old Post

 
 mmp   United States. January 29 2012 08:54. Posts 2126
Profile Blog # 

On January 29 2012 08:54 mmp wrote:

Show nested quote +


Yeah, a friend and I used it for an nlp project. By the time we were done we barely understand what we had written inside all of the closures. What a bitch to debug.

But it was groovy!
I (λ (foo) (and (<3 foo) ( T_T foo) (RAGE foo) )) Starcraft
Old Post

 
 Rainling   United States. January 29 2012 12:56. Posts 182
Profile # 
Edit: Fixed
Last edit: 2012-02-18 10:46:12
I think the real problem with it all ... is that people choose to identify with an ideology. Instead I think a person should only *use* ideologies to view issues. HawaiianPig
Old Post

 
 Crazyeyes   Canada. January 29 2012 17:02. Posts 1329
Profile Blog # 
Alright, I've got a little question for you guys. I'm currently in third year university, major in computer science. Before University, I honestly didn't even know what programming was.

So anyways. As I've mentioned, I'm third year. All of my knowledge in computer programming comes from my classes. I'll admit I'm not the best student, but I do pay attention when I can and I'm not exactly failing my way through this. I don't ever program on my free time or read programming-related things that aren't school related.

So far, we've pretty much only learned Java when it comes to useful programmming languages. I did a bit in Scheme, a very small amount in Assembly (I forgot most of it, honestly. It was horrible), some HTML... and I'm currently learning C. Much harder than I expected. Pointers sorta confuse me sometimes.

The thing is, I feel like I don't know anything. I feel like pepole who have way less education than me are more capable than I am. I've never said "I've made a script to do...."
I dont even know what that is.

What I hope is going on is that I'm being given the basic (and hopefully more advanced, too) programming skills and knowledge that can be applied to all computer science, and then the more specific things I'll be able to pick up without too much effort. I'm hoping that when I sit down and am told to do X at some random job, I'll be able to do it and be surprised with how much I know.
I'm just not very sure.

So, to any of you who come from a similar background (learned everything at school), can you shed some light on your situation? Is this normal?
Last edit: 2012-01-29 17:03:54
WeeEEeeEEEeeEEEeeeEEee!!
Old Post

1 2 3 4 5 6 7 8 9 10 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 200 296 297 298 299 300 301 302 303 304 305 306
Please log in or register to reply.
 
Refresh
StarCraft: Brood War
StarCraft 2
Dota 2
Other Notable Streams
[ Show 59 non-featured ]

» Recent SC2 Results
» Premier SC2 Tournaments

The Little App Factory