How to find ASCII value of character in c

Please support our C advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: May 2008
Posts: 38
Reputation: Software guy is an unknown quantity at this point 
Solved Threads: 2
Software guy Software guy is offline Offline
Light Poster

Re: How to find ASCII value of character in c

 
-1
  #11
Jul 9th, 2008
-> NOT using int main() == not good

i agree

BUT
  1. #include<stdio.h>
  2. int main()
  3. {
  4. printf("\nHello World!");
  5. return 0;/* I dont think my main should return an Integer*/
  6. }

I think i am right in this case. I dont have anything against int main(). But if we dont have to use it , we should make our life simple in terms of compiling. Because if your int main() doesnot have return 0; , you might get a warning or error in any C compiler in the world.

Some material to have a look at:
int main() vs void main()

http://www.eskimo.com/~scs/readings/...in.960823.html

So i agree with you , that i should use int main() , but a small program like printing ASCII and integer doesnot need that much of attention. :)
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,783
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 745
Team Colleague
Narue's Avatar
Narue Narue is offline Offline
Code Goddess

Re: How to find ASCII value of character in c

 
2
  #12
Jul 9th, 2008
>/* I dont think my main should return an Integer*/
It doesn't matter what you think. You still have to follow the rules. If you don't like it, go to C99 or C++ where 0 is returned automagically. And if you use C99, be sure to tell us so you don't get blasted for failing to return a value[1].

>I think i am right in this case.
I know you're not.

>But if we dont have to use it , we should make our life simple in terms of compiling.
That's the thing, you do have to use it unless your compiler offers an alternative. If your compiler doesn't offer an alternative, the behavior is undefined. You can't win this battle because nobody who's qualified to have an opinion on the matter will agree that saving a trivial line of code is worth undefined behavior.

>Some material to have a look at:
I've read it, but thanks anyway.

>So i agree with you , that i should use int main() , but a small program
>like printing ASCII and integer doesnot need that much of attention.
Rationalize it however you like, but I won't trust your code, and I'll encourage other people not to trust your code, because if you're that sloppy with a small program, who knows what kind of crap you write in larger programs.

[1] Of course, you'll probably still get blasted by the people who think it's a bad practice.
I'm here to prove you wrong.
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 38
Reputation: Software guy is an unknown quantity at this point 
Solved Threads: 2
Software guy Software guy is offline Offline
Light Poster

Re: How to find ASCII value of character in c

 
0
  #13
Jul 9th, 2008
lol,

I am not a Software engineer but i am an electronic engineer. I have done C++ and i am a Java addict. i know other languages too. But my point is , i am not doing anything wrong by putting void main (void)
I have done parallel to LCD interfacing using C. And if you call my void main sloppy , then that sloppiness worked. Saying this that i am wrong by using void main , is not acceptable, if its wrong it shouldn't work , but its compiling and running.
i admitted that you are right , but you cant say i am wrong and say my code is not trustable.
Reply With Quote Quick reply to this message  
Join Date: Dec 2005
Posts: 5,850
Reputation: Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute 
Solved Threads: 749
Team Colleague
Salem's Avatar
Salem Salem is offline Offline
Void main'ers are DOOMed

Re: How to find ASCII value of character in c

 
3
  #14
Jul 9th, 2008
How many times are you prepared to run across the road blindfolded, just because you managed to get across the first time without being run over?

Being right is a matter of attitude to solving the problem, not what your current compiler will let you get away with. Of course your next compiler may be a lot less lenient, but by then the damage has been done and you have to unlearn a bunch of crap (I know, I've been there).
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 38
Reputation: Software guy is an unknown quantity at this point 
Solved Threads: 2
Software guy Software guy is offline Offline
Light Poster

Re: How to find ASCII value of character in c

 
0
  #15
Jul 9th, 2008
Makes sense,
thanks Salem ;)
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,783
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 745
Team Colleague
Narue's Avatar
Narue Narue is offline Offline
Code Goddess

Re: How to find ASCII value of character in c

 
1
  #16
Jul 9th, 2008
>But my point is , i am not doing anything wrong by putting void main (void)
Do you honestly believe that you're not doing anything wrong by breaking an explicit rule?

>i admitted that you are right
No, you agreed with me superficially and then went right back to saying that your way isn't wrong.

I'm sorry Software guy, but you're a bad programmer and you shouldn't be writing code until you understand the problem with "it works for me" arguments.
I'm here to prove you wrong.
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 38
Reputation: Software guy is an unknown quantity at this point 
Solved Threads: 2
Software guy Software guy is offline Offline
Light Poster

Re: How to find ASCII value of character in c

 
1
  #17
Jul 9th, 2008
ok
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC