Thread: Need Help!!

  1. #1
    Registered User
    Join Date
    Apr 2010
    Posts
    1

    Need Help!!

    Hi there
    i have some questions in C program and i straggled to find right answer.
    1- What is the different between void main and in main(void). 2- what is parameter in c program? 3-In loop what the different between ++i And i++? 4- what the benfits of the loop(for and while)and when we need to use them?
    I know it seems to be stupid questions for some people but i am new in c program.
    Thanks

  2. #2
    Registered User claudiu's Avatar
    Join Date
    Feb 2010
    Location
    London, United Kingdom
    Posts
    2,094
    Read the FAQ of this site. All the answers to these questions are there.
    1. Get rid of gets(). Never ever ever use it again. Replace it with fgets() and use that instead.
    2. Get rid of void main and replace it with int main(void) and return 0 at the end of the function.
    3. Get rid of conio.h and other antiquated DOS crap headers.
    4. Don't cast the return value of malloc, even if you always always always make sure that stdlib.h is included.

  3. #3
    Registered User
    Join Date
    Dec 2007
    Posts
    2,675
    Being new to programming is not a license to be lazy. Search engines and FAQs exist precisely for finding answers to questions such as these.

  4. #4
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,817
    Welcome, now live from the Forum Guidelines:
    Tips for Efficient and Successful Posting

    1. Don't use all caps.

    2. Use descriptive subject lines. Do not put URGENT!, or NEED HELP NOW, etc. in your title; it will not make people look at it any faster. Doing this makes many old time helpers on this board not look at the post at all.
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

  5. #5
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by Majed View Post
    4- what the benfits of the loop(for and while)and when we need to use them?
    You don't need to use them at all unless you are writing a computer program, in which case the use value will quickly become obvious.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  6. #6
    Registered User
    Join Date
    Mar 2010
    Posts
    98
    with any function the type comes first. the parameter/s go inside the brackets.

    void main(void)

    type main(parameter)
    function name= main

    int main(void)
    type=integer


    a parameter is a value passed to a function. I don't think that's the best way to say it though.

    Read the faq for more accurate answers.

Popular pages Recent additions subscribe to a feed