Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > I am learning C: a little problem with a simple source code

Reply
Thread Tools

I am learning C: a little problem with a simple source code

 
 
zemir
Guest
Posts: n/a
 
      11-01-2011
I have tried to resolve with other ways as well as i understand but i
was not able to resolve it; only this way works such as i want. I have
changed cost Pi from float to bouble and i have changed c control
value from '121' to 'y'. Now all works fine. I think this binary can
run well on any other windows pc as well as run on my pc. The only
problem is if anyone want to change the name of binary but i think
this is not a common choice.

On Nov 1, 8:06 pm, Ian Collins <(E-Mail Removed)> wrote:
> > void main() {

>
> This should be int main(). On modern compilers, this won't compile
> because you are returning values.

Yes, of course........... int main() is more right but my choice is
such common that it is not more a error......
 
Reply With Quote
 
 
 
 
zemir
Guest
Posts: n/a
 
      11-01-2011
I have tried to resolve with other ways as well as i understand but i
was not able to resolve it; only this way works such as i want. I have
changed cost Pi from float to bouble and i have changed c control
value from '121' to 'y'. Now all works fine. I think this binary can
run well on any other windows pc as well as run on my pc. The only
problem is if anyone want to change the name of binary but i think
this is not a common choice.

On Nov 1, 8:06 pm, Ian Collins <(E-Mail Removed)> wrote:
> > void main() {

>
> This should be int main(). On modern compilers, this won't compile
> because you are returning values.

Yes, of course........... int main() is more right but my choice is
such common that it is not more a error......
 
Reply With Quote
 
 
 
 
Ben Bacarisse
Guest
Posts: n/a
 
      11-01-2011
James Kuyper <(E-Mail Removed)> writes:
> On 11/01/2011 02:51 PM, zemir wrote:

<snip>
>> c=getch();

>
> You also haven't bothered to check for the possibility that getch()
> might have failed.


If it's the getch I remember, it can't fail -- by which I mean there is
no error return that can tell you anything.

<snip>
--
Ben.
 
Reply With Quote
 
zemir
Guest
Posts: n/a
 
      11-01-2011
I have tried to resolve with other ways as well as i understand but i
was not able to resolve it; only this way works such as i want. I have
changed cost Pi from float to bouble and i have changed c control
value from '121' to 'y'. Now all works fine. I think this binary can
run well on any other windows pc as well as run on my pc. The only
problem is if anyone want to change the name of binary but i think
this is not a common choice.

On Nov 1, 8:06 pm, Ian Collins <(E-Mail Removed)> wrote:
> > void main() {

>
> This should be int main(). On modern compilers, this won't compile
> because you are returning values.

Yes, of course........... int main() is more right but my choice is
such common that it is not more a error......
 
Reply With Quote
 
James Kuyper
Guest
Posts: n/a
 
      11-01-2011
On 11/01/2011 04:17 PM, zemir wrote:
....
> On Nov 1, 8:06 pm, Ian Collins <(E-Mail Removed)> wrote:
>>> void main() {

>>
>> This should be int main(). On modern compilers, this won't compile
>> because you are returning values.

> Yes, of course........... int main() is more right but my choice is
> such common that it is not more a error......


Just because it's a popular error doesn't make it cease to be an error.
Get it right now, while you're still learning. The fewer bad habits you
pick up now, while you're still new to the language, the less you'll
have to unlearn before you can be employable.
 
Reply With Quote
 
Ian Collins
Guest
Posts: n/a
 
      11-01-2011
On 11/ 2/11 09:19 AM, zemir wrote:
> I have tried to resolve with other ways as well as i understand but i
> was not able to resolve it; only this way works such as i want. I have
> changed cost Pi from float to bouble and i have changed c control
> value from '121' to 'y'. Now all works fine. I think this binary can
> run well on any other windows pc as well as run on my pc. The only
> problem is if anyone want to change the name of binary but i think
> this is not a common choice.
>
> On Nov 1, 8:06 pm, Ian Collins<(E-Mail Removed)> wrote:
>>> void main() {

>>
>> This should be int main(). On modern compilers, this won't compile
>> because you are returning values.

> Yes, of course........... int main() is more right but my choice is
> such common that it is not more a error......


Well it is an error if you use a decent compiler. In addition to being
simply wrong, a void function can't return a value!

--
Ian Collins
 
Reply With Quote
 
zemir
Guest
Posts: n/a
 
      11-01-2011
On Nov 1, 9:24 pm, James Kuyper <(E-Mail Removed)> wrote:
> On 11/01/2011 04:17 PM, zemir wrote:
> ...
>
> > On Nov 1, 8:06 pm, Ian Collins <(E-Mail Removed)> wrote:
> >>> void main() {

>
> >> This should be int main(). On modern compilers, this won't compile
> >> because you are returning values.

> > Yes, of course........... int main() is more right but my choice is
> > such common that it is not more a error......

>
> Just because it's a popular error doesn't make it cease to be an error.
> Get it right now, while you're still learning. The fewer bad habits you
> pick up now, while you're still new to the language, the less you'll
> have to unlearn before you can be employable.


Ok, from now and in the future i will use always "int main()"
I am sure thai it is the right choice.
 
Reply With Quote
 
Ian Collins
Guest
Posts: n/a
 
      11-01-2011
On 11/ 2/11 09:23 AM, zemir wrote:
> I have tried to resolve with other ways as well as i...


You don't have to post 3 times!

--
Ian Collins
 
Reply With Quote
 
zemir
Guest
Posts: n/a
 
      11-01-2011
On Nov 1, 9:24 pm, James Kuyper <(E-Mail Removed)> wrote:
> On 11/01/2011 04:17 PM, zemir wrote:
> ...
>
> > On Nov 1, 8:06 pm, Ian Collins <(E-Mail Removed)> wrote:
> >>> void main() {

>
> >> This should be int main(). On modern compilers, this won't compile
> >> because you are returning values.

> > Yes, of course........... int main() is more right but my choice is
> > such common that it is not more a error......

>
> Just because it's a popular error doesn't make it cease to be an error.
> Get it right now, while you're still learning. The fewer bad habits you
> pick up now, while you're still new to the language, the less you'll
> have to unlearn before you can be employable.


Ok, from now and in the future i will use always "int main()"
I am sure thai it is the right choice.
 
Reply With Quote
 
zemir
Guest
Posts: n/a
 
      11-01-2011
On Nov 1, 9:27 pm, Ian Collins <(E-Mail Removed)> wrote:
> On 11/ 2/11 09:23 AM, zemir wrote:
>
> > I have tried to resolve with other ways as well as i...

>
> You don't have to post 3 times!
>
> --
> Ian Collins


ok, i have a little problem with my browser.........now i have solved,
i hope.....
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[I'm learning C]: Learning to use ucontext Andrey Popp C Programming 5 01-31-2012 01:05 AM
1 little 2 little 3 little Kennedys dale Digital Photography 0 03-23-2008 01:03 PM
having a little problem with some code for a little game I am creating. ThaDoctor C++ 3 09-28-2007 03:28 PM
Learning C and Learning Make/Configure/Building/Linking Hal Vaughan C Programming 7 03-21-2006 05:07 PM
e-learning, (collaborative learning environment) collinm Java 1 09-08-2005 09:52 PM



Advertisments