Author | Message | ||
---|---|---|---|
jackel n00b Posts: 41 | just done my 1st couple of C lesons & buzzin like a bee from it ;)
run it with Dev-C++ from bloodshed or whatever you prefer if you can be ahol3d cant get enough of this kinda stuff eh tr00ps hehe LOVIN IT >.< J@C | ||
bluebear n00b Posts: 32 | Your definition of the main procedure is incorrect. The standard library will call it with arguments. And the getch() function is defined in conio.h (windows) or curses.h (linux) and its not included in your sample. | ||
jackel n00b Posts: 41 | bb are you telling me i shud use the #include <stdlib.h> instead and getch(); stops or pauses the programme, correct me if am wrong LIKE THIS:
THE PROGRAMME RUNS OK Y0 BB remember im n00b at C but loving what im getting tought &what i can pick up & take inn & remember is giving me a buzz >.< THX for teh help br3 ;-) if you cud explain more detail where me going wrong me will be more happy "thing is though the prog runs and does what its meant to which i know is not much but still it prints that code out in the console window & says what its meant to so me is a lil bamb00zled man as i thought if it does what told then its right BUT plz do point me in direction of where i go wrong R€€Sp€CT -TE-J@C :| | ||
bluebear n00b Posts: 32 | The code should be:
Most compilers will accepts your code witch is a bit incorrect, but this version is comformat with the C ISO standard | ||
jackel n00b Posts: 41 | HEY BB // your code is uber man thx alot br3 very helpfull. We learn a new thing every day its also good to see other ways which more advanced than i was tought although my prog still cud run and give me same result your code is much neater & more advanced THX ITS ALWAYS GOOD TO GET SUM FEEDBACK ;-) R€€SPECT-COMING-@-YA ' -TE-jackel | ||
vickmaker Ametuar Posts: 127 | if jackels first post is tottally wrong then thats fkin crazy, as this is being taught to peeps as part of the 1st year degree in computing, also if getch(); isnt defined in <stdio.h> why is it recognised? this baffles me as we are meant to be getting taught C from the very start, but im guessing that stuff you are showing jack is beyond the scope of the actual course we are on so the first way the tutor thinks of that will do is what we must be getting, i feel like pulling the tutor up now, and saying have a look at this, and why are you showing us that, but as i say i guess he is assuming that 90% of the class is assholes who just need to be there to get a small peice of a bigger course, where as me and jack are taking coding classes only, so our tutor must just give the bare minimum required, and i guess we will get to this stuff in later more advanced installments of C to our RAM (brain LOL) bb you now know where to apply for a job if you come to the UK to work ever, LOL :wink: as there is no doubt our tutor is A.Guru, But must be tired of idiots wasting his time etc and has adapted his teaching methods to suit, which is a real shame as i like to start as i mean to go on, but looks like we will be wading thru a ton of crap before we see the goodness, which i suppose is better than NO CLASSES as i suppose if we learn the building blocks then only our imagination can limit what you build with them blocks :wink: thanks for this input br3 regards //v | ||
bluebear n00b Posts: 32 | Most compilers will accept int main(void). Even C++ compilers will, even though its against the ISO standard for C and C++. And the compiler shoud throw a warning. Actually the compiler should error out on the missing #include. But not all compilers do that. Especailly not borland that will accept many calls without them being included. Witch causes ppls to get bad habbits and so on. http://msdn2.microsoft.com/en-us/library/078sfkak.aspx <- getch() documentation states very clearly that its the conio.h its defined in. I think its a shame that a school do not teach C that is conformat with the standards. I think in the case at hand that they are using some old papers and courses. This is one of the warnings i get when compiling the code jackel posted: Compiling... main.c c:\test\main.c(11) : warning C4013: 'getch' undefined; assuming extern returning int ^^ Assumptions are NO-NO's in programming by the way ;) It might be that the program still works as the programmer intented it to, however, in larger scale applications this might cause nasty bugs that are hard to locate. In worst cases this code will cause undefined behaivoir. If i compile "my version" with Visual studio i get no errors nor warnings. Btw. i gladly accept a job in the UK if i can work from my home in denmark >.< | ||
jackel n00b Posts: 41 | HEYA BB thx alot for your examples br3 there cool & i think it shud be standard that college teaches us these examples too, as we shud be tought how to run these codes on different O.S`s & not just windows BUT i guess im jst getting tought the basics which i will take to a higher level when i get my quals >.< /* I WILL BECOME GOOD CODER FOR -TE- */ #include <stdio.h> #ifdef _WIN32 #include <conio.h> #else #include <curses.h> #endif R€€SP€CT-COMING-@-YA-BB ;) your freind J@C i c you all back in hub in a few more weeks |