• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EST 15:47
CET 21:47
KST 05:47
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
RSL Revival - 2025 Season Finals Preview8RSL Season 3 - Playoffs Preview0RSL Season 3 - RO16 Groups C & D Preview0RSL Season 3 - RO16 Groups A & B Preview2TL.net Map Contest #21: Winners12
Community News
$21,000 Rongyi Cup Season 3 announced (Jan 22-Feb 7)4Weekly Cups (Dec 29-Jan 4): Protoss rolls, 2v2 returns6[BSL21] Non-Korean Championship - Starts Jan 103SC2 All-Star Invitational: Jan 17-1822Weekly Cups (Dec 22-28): Classic & MaxPax win, Percival surprises3
StarCraft 2
General
Weekly Cups (Dec 29-Jan 4): Protoss rolls, 2v2 returns SC2 All-Star Invitational: Jan 17-18 Weekly Cups (Dec 22-28): Classic & MaxPax win, Percival surprises Chinese SC2 server to reopen; live all-star event in Hangzhou Starcraft 2 Zerg Coach
Tourneys
$21,000 Rongyi Cup Season 3 announced (Jan 22-Feb 7) WardiTV Winter Cup WardiTV Mondays SC2 AI Tournament 2026 OSC Season 13 World Championship
Strategy
Simple Questions Simple Answers
Custom Maps
Map Editor closed ?
External Content
Mutation # 507 Well Trained Mutation # 506 Warp Zone Mutation # 505 Rise From Ashes Mutation # 504 Retribution
Brood War
General
BGH Auto Balance -> http://bghmmr.eu/ I would like to say something about StarCraft BW General Discussion StarCraft & BroodWar Campaign Speedrun Quest Data analysis on 70 million replays
Tourneys
[Megathread] Daily Proleagues [BSL21] Grand Finals - Sunday 21:00 CET [BSL21] Non-Korean Championship - Starts Jan 10 SLON Grand Finals – Season 2
Strategy
Game Theory for Starcraft Simple Questions, Simple Answers Current Meta [G] How to get started on ladder as a new Z player
Other Games
General Games
Awesome Games Done Quick 2026! General RTS Discussion Thread Nintendo Switch Thread Stormgate/Frost Giant Megathread Should offensive tower rushing be viable in RTS games?
Dota 2
Official 'what is Dota anymore' discussion
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Deck construction bug Heroes of StarCraft mini-set
TL Mafia
Vanilla Mini Mafia Mafia Game Mode Feedback/Ideas
Community
General
US Politics Mega-thread Russo-Ukrainian War Thread Things Aren’t Peaceful in Palestine Trading/Investing Thread The Big Programming Thread
Fan Clubs
White-Ra Fan Club
Media & Entertainment
Anime Discussion Thread
Sports
2024 - 2026 Football Thread Formula 1 Discussion
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
The Automated Ban List TL+ Announced
Blogs
Life Update and thoughts.
FuDDx
How do archons sleep?
8882
Psychological Factors That D…
TrAiDoS
James Bond movies ranking - pa…
Topin
StarCraft improvement
iopq
Customize Sidebar...

Website Feedback

Closed Threads



Active: 2808 users

The Big Programming Thread - Page 144

Forum Index > General Forum
Post a Reply
Prev 1 142 143 144 145 146 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.
Kich
Profile Joined April 2011
United States339 Posts
June 20 2012 17:46 GMT
#2861
Hey all, newly graduated comp-sci student here. I've been spending the last few weeks looking for jobs on whatever sites I personally know about, but they almost unanimously require 5-7 years of experience and if they don't they're asking me to be an expert in something I either have no knowledge or little knowledge of..

Anyways, I was wondering if any of you knew of some good programming oriented job finding websites?
Mandarinez
Profile Blog Joined July 2011
United States52 Posts
June 20 2012 18:51 GMT
#2862
I have a question about some basic python functions. How is the Add function coded into python? is it a lower level machine language function? and is "+" coded from "add"?
Anacletus
Profile Blog Joined April 2012
United States733 Posts
June 20 2012 19:43 GMT
#2863
Have you checked out http://gun.io/ ? It's hiring right now and normally has some spots open. You should also check out http://news.ycombinator.com/ - there are normally jobs listed in there a good bit of the time, and links to other places with job openings. You could also check out https://www.interviewstreet.com/challenges/. I've done a few and it's interesting to say the least, but does require some time investment.

Good luck job hunting sir!
http://talk-to-stimey-please.1324083.n2.nabble.com/
billy5000
Profile Blog Joined December 2010
United States865 Posts
June 20 2012 23:32 GMT
#2864
On June 18 2012 14:15 sluggaslamoo wrote:
Show nested quote +
On June 13 2012 08:23 RoyGBiv_13 wrote:
On June 13 2012 08:10 mcc wrote:
On June 13 2012 07:57 Defury wrote:
On June 13 2012 06:01 KaiserJohan wrote:
On June 12 2012 21:22 mcc wrote:
On June 12 2012 20:50 stafu wrote:
In my slightly biased opinion, learn C first, then C++. If you can learn C and C++ to a decent degree, everything else is easy.

C is not the best first language really. I think the old way of Pascal->C->C++->whatever is still the best. You can replace Pascal with similarly clear not OOP language and you can replace C++ with Java/C# as they have better designed OOP aspects. Reason is that before learning OOP you should learn proper structural programming and OOP aspects of Java/C# just get in the way of achieving this goal. C is bad at this as it has a lot of "unnatural" quirks. So after you master basics of structural programming , you move to C to learn the whole pointer and memory management thing. After that OOP. C# may be more natural choice due to the previous step being C, but it does not really matter.


I agree completely, well said.
I started with functional language Moscow ML and then C and then Java at university, and that is really good.


Would Pascal -> C# -> Java -> VB.net work?

Isn't pascal severely out dated and not worth learning?

Depends what you mean by not worth learning. Basically no language is worth learning in the long run just because of itself. Languages change and new ones emerge, the point of that succession was to hypothesize what is the best way to become a well rounded programmer. The point is not to learn the language, but to gain more general skills. Languages can be learned very quickly and in the process of learning are only as importnant as far as they help you to achieve that goal. Pascal is clear enough language, without too many quirks, so it fits the role of good language to teach basics of structural programming. Actually any modern practical language is probably bad for that role as they all need to support too many features that are not useful in learning process, but are crucial in practice.

As for your progression, I think the lack of C/C++ is kind of a weakness. But more importantly why would you move from C# to Java (joking ) and from Java to VB.Net (not joking ). VB is work of the devil.


Agree with this guy ^

Its been said a million times before, but worth repeating that there is no linear progression to these things, and there is no right way to learn programming. I learned off Pascal when I was 13, before I even know what a real program was or that there ever were other languages. It worked, because then when I saw C and Java, I at least knew how to run my own program. (Best skill to learn from C/Pascal is the ability to just run the damn thing, which is an often overlooked skill)

I'd say that you should start with Python or Java though, because being able to do something out the gate is the best feeling. If you enjoy writing your own data structures, and coming up with awesome solutions, you'll end up picking up C/C++, whereas if you like the OOP parts of those languages, you'll move towards even higher level languages.

Also, VB is the work of the devil.


Show nested quote +
On June 13 2012 22:44 Tobberoth wrote:
On June 13 2012 07:57 Defury wrote:
On June 13 2012 06:01 KaiserJohan wrote:
On June 12 2012 21:22 mcc wrote:
On June 12 2012 20:50 stafu wrote:
In my slightly biased opinion, learn C first, then C++. If you can learn C and C++ to a decent degree, everything else is easy.

C is not the best first language really. I think the old way of Pascal->C->C++->whatever is still the best. You can replace Pascal with similarly clear not OOP language and you can replace C++ with Java/C# as they have better designed OOP aspects. Reason is that before learning OOP you should learn proper structural programming and OOP aspects of Java/C# just get in the way of achieving this goal. C is bad at this as it has a lot of "unnatural" quirks. So after you master basics of structural programming , you move to C to learn the whole pointer and memory management thing. After that OOP. C# may be more natural choice due to the previous step being C, but it does not really matter.


I agree completely, well said.
I started with functional language Moscow ML and then C and then Java at university, and that is really good.


Would Pascal -> C# -> Java -> VB.net work?

Isn't pascal severely out dated and not worth learning? Would I be better off starting with something like python?

Whats your reasoning for that progression? Why not start with C# and then not learn the others? Do you have any need for any of those languages? I'd say that out of those languages, C# is probably the most useful one in a professional context, with Java in close second (but it depends on your area, java is used a lot more in many contexts) while the other two languages are not all that useful. VB.net is used by a lot of corporations but 1. It's extremely easy to learn if you know C# and 2. nowadays, .NET languages are interchanagble, so you could technically write your code in C# and then convert it to VB.net automagically.


I agree, but there is an order in which you should learn paradigms which is why Pascal/C should be learned first, followed by Java/C#, followed by Javascript/Ruby/Lisp, followed by Haskell, etc.

You should learn the paradigms in this order.

Structured -> Object Oriented -> Imperative Functional -> Declarative Functional.

Going backwards is far more difficult and you will learn a lot slower and develop bad habits. Learning them in the order mentioned above will ensure that you have the best chance of having stronger fundamentals when learning programming.

For example, you need to know functional decomposition to do any language, but you only need to know object decomposition in OOP/FP. Learning Pascal first teaches functional decomposition because that's the primary skill required in structured programming.

Functional decomposition can be (and should be) applied to Java, but with Java there is a bigger focus on object decomposition, which can't be applied to Pascal. The catch is that object decomposition is a lot harder when you don't understand functional decomposition and you end up coming up with some really awkward designs. There is nothing more frustrating than seeing objects decomposed without a second thought applied to functional decomposition, because the developer who coded it started with Java.

So if you want to progress in the a way that ensures the best chance of being a solid programmer, you should follow the order mentioned above.

Not everybody learned it this way, and I'm sure there's some experts out there that started with Haskell. But just from my own experience I think this is the best way.



Just out of curiosity, what time frame am I looking at for the average programmer?
Tiger got to hunt, bird got to fly; Man got to sit and wonder, 'Why, why, why?' Tiger got to sleep, bird got to land; Man got to tell himself he understand. Vonnegut
snakeeyez
Profile Joined May 2011
United States1231 Posts
Last Edited: 2012-06-21 00:45:43
June 21 2012 00:42 GMT
#2865
My advice is java and web programming on PC I dont see anything becoming more important then those right now. Mainframe I think cobol and jcl which is what I now use.
chiboni
Profile Joined June 2011
15 Posts
June 21 2012 12:27 GMT
#2866
Hi there,

I have following problem with java and reading bytes from an socket inputstream.

When I run the code, 2 bytes from the 6 bytes I want to read differ from the bytes I track with wireshark.
Java extends the bytes with an prefix 'ffffff' which negates them. This only occures on byte 2 and 3.

Does anyone have an idea how to solve this or what the problem is ?

code below


...
SomeFrame frame = new SomeFrame ();
byte[] readingHeader = new byte[6];
while((socketInStream.read(readingHeader,0,readingHeader.length))!=-1) {
System.out.println(Integer.toHexString(readingHeader[2]));
System.out.println(Integer.toHexString(readingHeader[3]));

frame.setHeader(readingHeader);
socketInStream.read(frame.data);

//do something else ...


Deleted User 61629
Profile Blog Joined March 2010
1664 Posts
June 21 2012 12:29 GMT
#2867
--- Nuked ---
Akka
Profile Joined August 2010
France291 Posts
June 21 2012 12:46 GMT
#2868
@billy5000

Learning tons of languages just for the sake of learning stuff doesn't seem to be a terribly good idea to me. Just learn how to program in C, then learn how to program well in C, then depending on what you need choose whatever language is best suited to what you need or want to do. There is no such thing as a perfect road to follow in order to become a badass programmer, but as you get involved in projects you will eventually learn tons of things and be able to show off how many languages you know.

If you work seriously you should be able to program well enough in C to be able to do anything you want in a year or so (considering you have no prior experience in programming). I'm talking about simple video games, FTP or IRC clients, graphical interfaces, etc.
The best way to begin is this book : http://en.wikipedia.org/wiki/The_C_Programming_Language combined with heavy google-fu practice.

Other than that, I must admit I'm rather surprised not to see more talk about html5/js game development here ^^
MisterD
Profile Blog Joined June 2010
Germany1338 Posts
Last Edited: 2012-06-21 13:08:36
June 21 2012 13:04 GMT
#2869
On June 21 2012 21:27 chiboni wrote:
Hi there,

I have following problem with java and reading bytes from an socket inputstream.

When I run the code, 2 bytes from the 6 bytes I want to read differ from the bytes I track with wireshark.
Java extends the bytes with an prefix 'ffffff' which negates them. This only occures on byte 2 and 3.

Does anyone have an idea how to solve this or what the problem is ?

code below


...
SomeFrame frame = new SomeFrame ();
byte[] readingHeader = new byte[6];
while((socketInStream.read(readingHeader,0,readingHeader.length))!=-1) {
System.out.println(Integer.toHexString(readingHeader[2]));
System.out.println(Integer.toHexString(readingHeader[3]));

frame.setHeader(readingHeader);
socketInStream.read(frame.data);

//do something else ...




keep in mind, that a java byte is signed:

The byte data type is an 8-bit signed two's complement integer. It has a minimum value of -128 and a maximum value of 127 (inclusive). The byte data type can be useful for saving memory in large arrays, where the memory savings actually matters. They can also be used in place of int where their limits help to clarify your code; the fact that a variable's range is limited can serve as a form of documentation.


so the bytes you are looking for might just be
int byteValue = byte;
if(byteValue < 0) byteValue += 256
sysout(Integer.toHexString(byteValue);
Gold isn't everything in life... you need wood, too!
chiboni
Profile Joined June 2011
15 Posts
June 21 2012 13:36 GMT
#2870
On June 21 2012 22:04 MisterD wrote:
Show nested quote +
On June 21 2012 21:27 chiboni wrote:
Hi there,

I have following problem with java and reading bytes from an socket inputstream.

When I run the code, 2 bytes from the 6 bytes I want to read differ from the bytes I track with wireshark.
Java extends the bytes with an prefix 'ffffff' which negates them. This only occures on byte 2 and 3.

Does anyone have an idea how to solve this or what the problem is ?

code below


...
SomeFrame frame = new SomeFrame ();
byte[] readingHeader = new byte[6];
while((socketInStream.read(readingHeader,0,readingHeader.length))!=-1) {
System.out.println(Integer.toHexString(readingHeader[2]));
System.out.println(Integer.toHexString(readingHeader[3]));

frame.setHeader(readingHeader);
socketInStream.read(frame.data);

//do something else ...




keep in mind, that a java byte is signed:

Show nested quote +
The byte data type is an 8-bit signed two's complement integer. It has a minimum value of -128 and a maximum value of 127 (inclusive). The byte data type can be useful for saving memory in large arrays, where the memory savings actually matters. They can also be used in place of int where their limits help to clarify your code; the fact that a variable's range is limited can serve as a form of documentation.


so the bytes you are looking for might just be
int byteValue = byte;
if(byteValue < 0) byteValue += 256
sysout(Integer.toHexString(byteValue);



Thanks!!!!
Searched for hours and couldnt find the reason.
ZpuX
Profile Blog Joined December 2002
Sweden1230 Posts
June 21 2012 15:55 GMT
#2871
Hiyo,

I wonder where to go from MATLAB.... From what I have heard MATLAB isn't really a programming language and it is mostly used for it's ability to handle values and matrix's. I knew some c++ from high school, or more like, I knew what the different loops did but I just couldn't understand the syntax and I had no real interest in learning it. But at uni we had an introduction course to MATLAB (engineering) where my friend helped me out a little bit in the beginning, and then everything just came quite easy from there. I wouldn't say I'm good at it, but if there is a problem I know where to search and I don't usually have any problems finding a solution.

Anyway, a lot of the jobs which I am looking at isn't really interested in MATLAB but want java, c etc, and I wonder if I will have any benefit from my previous skills in MATLAB and from where from where I should start? Which language resembles MATLAB the most and what kind of problems will I be looking at in the beginning?
Really, play for fun!
arthurrr157
Profile Joined November 2010
United States118 Posts
June 21 2012 17:55 GMT
#2872
I think recommending people who have done no programming start with C is an idealistic idea spread about too much on here. For somebody who is still trying to become interested in programming it would be easier albeit a less efficient path to take.

I started out learning C++ but I had no idea where the tutorial was going. I had no idea when I was going to be able to actually use the things I had been learning for something other than math so it was very difficult. The lpthw (learn python the hard way) tutorial was excellent for getting an introduction into programming in general and I feel now that if I decided to learn C I could follow it through and not get bored.
Diamond 1v1 Zerg
Cloud
Profile Blog Joined November 2004
Sexico5880 Posts
Last Edited: 2012-06-21 21:39:28
June 21 2012 18:10 GMT
#2873
The language you pick up doesn't matter if you're really dedicated. If you're not, then I'd suggest something with which you can observe quick (graphical) results. So I'd say start with ruby (do a ruby on rails tutorial) or with python (with learn python the hard way) and start with web development. Also, the order in which you learn different paradigms doesn't matter. Learning functional programming before object oriented programming won't "teach you bad habits" or anything. Paradigms are just a way of thinking just like languages and which one you start with doesn't matter, what matters is what you do with it.
BlueLaguna on West, msg for game.
RoyGBiv_13
Profile Blog Joined August 2010
United States1275 Posts
Last Edited: 2012-06-21 18:14:31
June 21 2012 18:11 GMT
#2874
On June 22 2012 00:55 ZpuX wrote:
Hiyo,

I wonder where to go from MATLAB.... From what I have heard MATLAB isn't really a programming language and it is mostly used for it's ability to handle values and matrix's. I knew some c++ from high school, or more like, I knew what the different loops did but I just couldn't understand the syntax and I had no real interest in learning it. But at uni we had an introduction course to MATLAB (engineering) where my friend helped me out a little bit in the beginning, and then everything just came quite easy from there. I wouldn't say I'm good at it, but if there is a problem I know where to search and I don't usually have any problems finding a solution.

Anyway, a lot of the jobs which I am looking at isn't really interested in MATLAB but want java, c etc, and I wonder if I will have any benefit from my previous skills in MATLAB and from where from where I should start? Which language resembles MATLAB the most and what kind of problems will I be looking at in the beginning?


The matlab syntax is very close to C. I suggest sticking with MATLAB, and looking for jobs that use it or SIMULINK or even LABVIEW. They are usually higher paying than typical programming jobs.

If you really want to shift gears, then look at how other languages integrate with MATLAB. I haven't played around with it since college, but IIRC, Java, Python, FORTRAN, and C will all integrate smoothly with MATLAB. If you have a sample project that does this, your job prospects go through the roof since integration is a nontrivial task that few people know how to do. It's definately a fun activity too.

For a starting problem, try writing a Python program that opens a UI frontend for the user to invoke MATLAB scripts with

Python GUI sample program: http://stackoverflow.com/questions/2310130/how-to-write-gui-in-python
One way to integrat: http://claymore.engineer.gvsu.edu/~steriana/Python/pymat.html
Any sufficiently advanced technology is indistinguishable from magic
Frigo
Profile Joined August 2009
Hungary1023 Posts
June 21 2012 20:10 GMT
#2875
http://www.planetgeek.ch/2012/06/12/acceptance-test-driven-development/
http://www.fimfiction.net/user/Treasure_Chest
fabiano
Profile Blog Joined August 2009
Brazil4644 Posts
June 21 2012 20:48 GMT
#2876
Guys... being a programmer is not about which language you know.

Being a programmer is to take a problem and find a solution with whatever tools you have available. If you happen to know 5 programming languages, you then have 5 different tools to solve your problem, so you pick the language most suitable for the job.

If none of the languages you know are fit for the task, it doesn't mean you won't be able to solve the problem. After all the correct way to find a solution is not to think "how would I solve problem X with language Y", but to develop diagrams/pseudo-codes and then figuring it out which language is the best suitable.

So what I mean is that no matter which language you learn first, what really matters when learning programming is all the thinking that goes behind the implementation of the solution.

"Learn Java first!"
"Learn C first!!"
"No, learn Scheme first!"

It doesn't matter which language you learn first, what really matters is that you develop new ways of thinking to solve a given problem. That's why we learn different paradigms in the university.

So if you are just starting, try to learn whatever language you can find great resources to learn from. Learning a language is just the beginning, so if you picked up C++ and someone says "no, you should've gone for Java!!", just ignore him.

A good way to figure out which language you want to learn first is to ask yourself what do you want to develop.

If you want to create games, pick up C++ as you will find tons of resources to learn from.
If you want to create cross-platform software, learn Java.
If you want to create mobile apps, either Java (Android) or Objective-C (will need Apple products though, fucking iOS).
If you want to work closer to the OS, learn C.
Web? PHP or Python.
AI? Prolog.

Programming can be extremely fun and sometimes extremely painful, it all depends if you like what you are doing.
"When the geyser died, a probe came out" - SirJolt
ranshaked
Profile Blog Joined August 2010
United States870 Posts
June 21 2012 21:12 GMT
#2877
I'm typing from my phone, so please bare with me. I had an assignment that I handed in that was not complete because I could not figure out how to do division. Basically the assignment is like this:
Randomly generate a math sign (+*/-) and two random numbers and ask the user to solve the problem. Everything works properly except the division. I know that it is because I'm using integers, but when I caste them as floats in my if or switch statements (tried both) it either gets 0.000000 all the time or it messes up the other integers. The final line needs to print the answer. Because it is random, I'm struggling with the final answer, everything will wok except division

I'll post the code later. Thanks
Abductedonut
Profile Blog Joined December 2010
United States324 Posts
Last Edited: 2012-06-21 22:01:19
June 21 2012 22:00 GMT
#2878
On June 22 2012 06:12 ranshaked wrote:
I'm typing from my phone, so please bare with me. I had an assignment that I handed in that was not complete because I could not figure out how to do division. Basically the assignment is like this:
Randomly generate a math sign (+*/-) and two random numbers and ask the user to solve the problem. Everything works properly except the division. I know that it is because I'm using integers, but when I caste them as floats in my if or switch statements (tried both) it either gets 0.000000 all the time or it messes up the other integers. The final line needs to print the answer. Because it is random, I'm struggling with the final answer, everything will wok except division

I'll post the code later. Thanks


I whipped up some quick code for you. It's by no means pretty. Here you go. Assuming you're using C, same principles should apply in C++. Next time, specify which language you use!

+ Show Spoiler +


#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int main(int argc, char *argv[])
{
int randomNum = 0, randomNum2 = 0, mathOperator = 0;
float result = 0, answer = 0;
srand ( time(NULL) );

char map[4] = {'-','+','*','/'};

while( 1 )
{
randomNum = rand()%100; //Truncated it to a limit of 100, so that you don't get ridiculous numbers...
printf("%i ",randomNum);
mathOperator = rand()%4;
printf("%c ",map[mathOperator] );
randomNum2 = rand()%100;
printf("%i",randomNum2);

switch ( map[mathOperator] )
{
case '-':
result = randomNum - randomNum2;
break;
case '+':
result = randomNum + randomNum2;
break;
case '*':
result = randomNum * randomNum2;
break;
case '/':
result = (float)randomNum / ( (float)randomNum2 );
printf(" Result is: %f ",result);
break;
}

//How come the divison never works??
//It's because of round-off errors within the computer. Trying looking at:
//http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm
printf(" \nWhat is the answer? ");
scanf("%f",&answer);
printf("you entered: %f \n",answer);
fflush(stdin);

if ( answer == result )
printf("Correct! \n");
}

return 0;
}



The basic idea between comparing floats is that you must have a general "error" range that you're okay with.

Most floats, when printed, will get rounded off. So it may seem like the answer is 1.3333334 but in memory its actually stored as 1.333333333333333333333. So when you do the comparison, it gets jacked up. Read the article I commented in the code.

Also, does anyone have expierence with Microsoft's Media Foundation? I've been trying to use MF to capture to a hwnd using D3D and I'm having a really hard time. Would appreciate any help.
Azerbaijan
Profile Blog Joined January 2010
United States660 Posts
June 22 2012 03:06 GMT
#2879
Ok, I am new to programming as of about 3 weeks ago. I have decided to learn C first which has so far been extremely challenging but I'm really enjoying it. My Grandpa gave me a copy of "The C Programming Language" and I've been follwing the first chapter's examples and exercises and then experimenting with what I'm learning in my own simple programs. I made a pretty simple number guessing that I'm pretty proud of but I used the scanf function which I have sinced learned is not a good choice for serious programming because its inefficient and doesnt error check very well. So I've gotten to the part in my book that explains getchar and putchar and I'm having a problem with getting the example programs to run.

+ Show Spoiler +
#include <stdio.h>
#include <stdlib.h>

main()
{
double nc;

for (nc = 0; getchar() != EOF; ++nc)
;
printf("%.0f\n", nc);
}


Sorry I haven't been able to figure out how to post the code properly
Anyway if I'm reading that right the loop is checking how many characters I enter until it encounters a null and then should be printing its count. The program runs fine with the compiler not giving me any errors but it won't give me any output and I really don't know why. Im using code blocks to compile if that might be part of the issue. Anyone know what I am missing here?
Ultraliskhero
Profile Joined April 2010
Canada249 Posts
June 22 2012 03:25 GMT
#2880
@Azerbaijan

It looks like your loop's stop condition is comparing with a EOF, not a null.
If you're using a windows machine, typing in (control)Z may be able to stop your program and thus print out the output.
(I tried it and it worked for me)
Prev 1 142 143 144 145 146 1032 Next
Please log in or register to reply.
Live Events Refresh
Next event in 7h 13m
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
UpATreeSC 178
IndyStarCraft 168
JuggernautJason134
BRAT_OK 106
SteadfastSC 105
EmSc Tv 22
StarCraft: Brood War
Britney 15836
EffOrt 286
Shuttle 162
Larva 70
Rock 40
Killer 38
Dota 2
Gorgc5657
Counter-Strike
adren_tv97
Other Games
Grubby5653
tarik_tv2748
FrodaN2267
Liquid`RaSZi2248
Beastyqt946
Harstem465
Liquid`Hasu410
Mlord408
mouzStarbuck368
Pyrionflax266
B2W.Neo231
KnowMe194
ArmadaUGS174
QueenE75
TKL 68
Dewaltoss53
ZombieGrub29
DeMusliM28
Liquid`Ken1
Organizations
Other Games
gamesdonequick42494
StarCraft 2
EmSc Tv 22
EmSc2Tv 22
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 19 non-featured ]
StarCraft 2
• Hupsaiya 61
• sooper7s
• Migwel
• AfreecaTV YouTube
• LaughNgamezSOOP
• intothetv
• IndyKCrew
• Kozan
StarCraft: Brood War
• 80smullet 26
• FirePhoenix14
• STPLYoutube
• ZZZeroYoutube
• BSLYoutube
Dota 2
• Ler54
League of Legends
• Doublelift4349
• Nemesis2655
Other Games
• imaqtpie1701
• Shiphtur325
• WagamamaTV251
Upcoming Events
SOOP
7h 13m
SHIN vs GuMiho
Cure vs Creator
The PondCast
13h 13m
Wardi Open
15h 13m
Big Gabe XPERIONCRAFT
16h 13m
AI Arena Tournament
23h 13m
Sparkling Tuna Cup
1d 13h
WardiTV Invitational
1d 16h
IPSL
1d 23h
DragOn vs Sziky
Replay Cast
2 days
Wardi Open
2 days
[ Show More ]
Monday Night Weeklies
2 days
WardiTV Invitational
3 days
WardiTV Invitational
4 days
The PondCast
5 days
Liquipedia Results

Completed

Proleague 2026-01-08
WardiTV 2025
META Madness #9

Ongoing

C-Race Season 1
IPSL Winter 2025-26
OSC Championship Season 13
eXTREMESLAND 2025
SL Budapest Major 2025
ESL Impact League Season 8
BLAST Rivals Fall 2025
IEM Chengdu 2025
PGL Masters Bucharest 2025

Upcoming

BSL 21 Non-Korean Championship
CSL 2025 WINTER (S19)
Escore Tournament S1: W4
Acropolis #4
IPSL Spring 2026
Bellum Gens Elite Stara Zagora 2026
HSC XXVIII
Rongyi Cup S3
Thunderfire SC2 All-star 2025
Big Gabe Cup #3
Nations Cup 2026
Underdog Cup #3
NA Kuram Kup
BLAST Open Spring 2026
ESL Pro League Season 23
ESL Pro League Season 23
PGL Cluj-Napoca 2026
IEM Kraków 2026
BLAST Bounty Winter 2026
BLAST Bounty Winter Qual
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.