• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 18:12
CEST 00:12
KST 07:12
  • 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 Tall10HomeStory 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
Weekly Cups (June 30 - July 6): Classic Doubles2[BSL20] Non-Korean Championship 4x BSL + 4x China9Flash Announces Hiatus From ASL66Weekly Cups (June 23-29): Reynor in world title form?14FEL Cracov 2025 (July 27) - $8000 live event22
StarCraft 2
General
The GOAT ranking of GOAT rankings The SCII GOAT: A statistical Evaluation Weekly Cups (June 23-29): Reynor in world title form? Weekly Cups (June 30 - July 6): Classic Doubles Program: SC2 / XSplit / OBS Scene Switcher
Tourneys
RSL: Revival, a new crowdfunded tournament series FEL Cracov 2025 (July 27) - $8000 live event Sparkling Tuna Cup - Weekly Open Tournament WardiTV Mondays Korean Starcraft League Week 77
Strategy
How did i lose this ZvP, whats the proper response Simple Questions Simple Answers
Custom Maps
[UMS] Zillion Zerglings
External Content
Mutation # 481 Fear and Lava Mutation # 480 Moths to the Flame Mutation # 479 Worn Out Welcome Mutation # 478 Instant Karma
Brood War
General
BGH Auto Balance -> http://bghmmr.eu/ ASL20 Preliminary Maps [ASL19] Finals Recap: Standing Tall SC uni coach streams logging into betting site Flash Announces Hiatus From ASL
Tourneys
[BSL20] Non-Korean Championship 4x BSL + 4x China [BSL20] Grand Finals - Sunday 20:00 CET CSL Xiamen International Invitational The Casual Games of the Week Thread
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
Russo-Ukrainian War Thread US Politics Mega-thread Stop Killing Games - European Citizens Initiative Summer Games Done Quick 2024! Summer Games Done Quick 2025!
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
The Automated Ban List
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: 635 users

The Big Programming Thread - Page 144

Forum Index > General Forum
Post a Reply
Prev 1 142 143 144 145 146 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.
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 1031 Next
Please log in or register to reply.
Live Events Refresh
RotterdaM Event
16:00
Rotti Stream Rumble 4k Edition
RotterdaM741
Liquipedia
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
RotterdaM 741
ProTech67
ROOTCatZ 56
Livibee 53
JuggernautJason32
StarCraft: Brood War
Artosis 240
Rock 24
MaD[AoV]14
Stormgate
Nathanias73
Dota 2
NeuroSwarm45
League of Legends
Grubby4548
Counter-Strike
Fnx 2228
taco 728
Stewie2K688
flusha402
sgares146
Super Smash Bros
PPMD146
Heroes of the Storm
Liquid`Hasu569
Other Games
summit1g7854
tarik_tv2375
fl0m700
mouzStarbuck263
Mew2King84
ZombieGrub61
Maynarde17
Organizations
Other Games
gamesdonequick49954
BasetradeTV30
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 21 non-featured ]
StarCraft 2
• kabyraGe 268
• musti20045 36
• davetesta33
• IndyKCrew
• sooper7s
• Migwel
• AfreecaTV YouTube
• LaughNgamezSOOP
• intothetv
• Kozan
StarCraft: Brood War
• 80smullet 31
• Eskiya23 20
• STPLYoutube
• ZZZeroYoutube
• BSLYoutube
Dota 2
• masondota2985
League of Legends
• Jankos2288
• TFBlade1022
Other Games
• imaqtpie1968
• Shiphtur473
• WagamamaTV226
Upcoming Events
Replay Cast
1h 49m
Sparkling Tuna Cup
11h 49m
WardiTV European League
17h 49m
MaNa vs sebesdes
Mixu vs Fjant
ByuN vs HeRoMaRinE
ShoWTimE vs goblin
Gerald vs Babymarine
Krystianer vs YoungYakov
PiGosaur Monday
1d 1h
The PondCast
1d 11h
WardiTV European League
1d 13h
Jumy vs NightPhoenix
Percival vs Nicoract
ArT vs HiGhDrA
MaxPax vs Harstem
Scarlett vs Shameless
SKillous vs uThermal
uThermal 2v2 Circuit
1d 17h
Replay Cast
2 days
RSL Revival
2 days
ByuN vs SHIN
Clem vs Reynor
Replay Cast
3 days
[ Show More ]
RSL Revival
3 days
Classic vs Cure
FEL
3 days
RSL Revival
4 days
FEL
4 days
FEL
4 days
CSO Cup
4 days
BSL20 Non-Korean Champi…
4 days
Bonyth vs QiaoGege
Dewalt vs Fengzi
Hawk vs Zhanhun
Sziky vs Mihu
Mihu vs QiaoGege
Zhanhun vs Sziky
Fengzi vs Hawk
Sparkling Tuna Cup
5 days
RSL Revival
5 days
FEL
5 days
BSL20 Non-Korean Champi…
5 days
Bonyth vs Dewalt
QiaoGege vs Dewalt
Hawk vs Bonyth
Sziky vs Fengzi
Mihu vs Zhanhun
QiaoGege vs Zhanhun
Fengzi vs Mihu
Liquipedia Results

Completed

BSL Season 20
HSC XXVII
Heroes 10 EU

Ongoing

JPL Season 2
BSL 2v2 Season 3
Acropolis #3
KCM Race Survival 2025 Season 2
CSL 17: 2025 SUMMER
Copa Latinoamericana 4
Jiahua Invitational
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
CSL Xiamen Invitational
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.