Thread: c question

  1. #1
    Registered User
    Join Date
    Nov 2010
    Posts
    53

    Question c question

    I got my code ready and I want to run it , but not from putty or something can edit it,

    I want to use my code like .exe file. Could any1 tell me how to do it? dont know the formal word for it.

  2. #2
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Is "putty" an editor?
    Does it not come with a compiler?

    Check the user's manuals for it... you may find you already have an executable but just don't know it.

  3. #3
    Registered User claudiu's Avatar
    Join Date
    Feb 2010
    Location
    London, United Kingdom
    Posts
    2,094
    Ehh.. so you want to "build" your code into an executable?

    If you have a nice IDE that should probably be able to do it for you, if not you can always use a makefile.
    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.

  4. #4
    Registered User claudiu's Avatar
    Join Date
    Feb 2010
    Location
    London, United Kingdom
    Posts
    2,094
    Quote Originally Posted by CommonTater View Post
    Is "putty" an editor?
    Does it not come with a compiler?

    Check the user's manuals for it... you may find you already have an executable but just don't know it.
    I think he is referring to Putty the SSH client:

    PuTTY: a free telnet/ssh client

    He is probably working remotely or something and can't figure out how to create an executable on the remote machine.
    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.

  5. #5
    Registered User
    Join Date
    Nov 2010
    Posts
    53
    Quote Originally Posted by claudiu View Post
    Ehh.. so you want to "build" your code into an executable?

    If you have a nice IDE that should probably be able to do it for you, if not you can always use a makefile.
    whats IDE and makefile? never touched those

  6. #6
    Registered User
    Join Date
    Nov 2010
    Posts
    53
    Quote Originally Posted by CommonTater View Post
    Is "putty" an editor?
    Does it not come with a compiler?

    Check the user's manuals for it... you may find you already have an executable but just don't know it.
    oh the putty is a thing where I log into school and putty contains emacs and vim etc. I use emacs
    Last edited by p595285902; 11-28-2010 at 11:44 AM.

  7. #7
    Registered User claudiu's Avatar
    Join Date
    Feb 2010
    Location
    London, United Kingdom
    Posts
    2,094
    Ok, so clearly you are working remotely and using an editor (emacs) on the remote school server to edit your code there. What compiler do you use to compile your code?
    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.

  8. #8
    Registered User
    Join Date
    Nov 2010
    Posts
    53
    everytime i compile we type
    gcc -Wall

    I dont know if its gcc or not

  9. #9
    Registered User claudiu's Avatar
    Join Date
    Feb 2010
    Location
    London, United Kingdom
    Posts
    2,094
    Ok, so if you have a single source file for your whole program then just do:

    gcc -Wall <sourcefile> -o <file_to_run>

    e.g.

    gcc -Wall program.c -o program

    Then type ./program to run it.
    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.

  10. #10
    Registered User
    Join Date
    Oct 2008
    Posts
    1,262
    I think the OP wants a windows executable file. Well, the technical term is "compiling", look for a good windows compiler for C online. Maybe people here can suggest a free compiler.

  11. #11
    Registered User claudiu's Avatar
    Join Date
    Feb 2010
    Location
    London, United Kingdom
    Posts
    2,094
    If you need a compiler for Windows just use the Pelles C that has been suggested or minGW.
    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.

  12. #12
    Registered User
    Join Date
    Nov 2010
    Posts
    2
    i want a program using c
    to calculate the age of given date of birth.
    please solve my problem

  13. #13
    Registered User claudiu's Avatar
    Join Date
    Feb 2010
    Location
    London, United Kingdom
    Posts
    2,094
    Quote Originally Posted by dilkash View Post
    i want a program using c
    to calculate the age of given date of birth.
    please solve my problem
    1) Please solve your own problem, this is not a homework delivery service.

    2) Please use your own separate thread for questions

    3) Please read the Homework FAQ

    4) Please make an attempt to your problem and post that before asking for help. We will not do your homework for you but we can help along with various issues.
    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.

  14. #14
    Registered User
    Join Date
    Nov 2010
    Posts
    2
    to calculate te age of given date of birth

  15. #15
    Registered User
    Join Date
    Oct 2008
    Posts
    1,262
    Quote Originally Posted by dilkash View Post
    to calculate te age of given date of birth
    Are you for real? You seem to have the intelligence of a spam-bot.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Question bout my work
    By SirTalksAlots in forum C Programming
    Replies: 4
    Last Post: 07-18-2010, 03:23 PM
  2. A question about a question
    By hausburn in forum C++ Programming
    Replies: 3
    Last Post: 04-25-2010, 05:24 AM
  3. Alice....
    By Lurker in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 06-20-2005, 02:51 PM
  4. Debugging question
    By o_0 in forum C Programming
    Replies: 9
    Last Post: 10-10-2004, 05:51 PM
  5. Question...
    By TechWins in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 07-28-2003, 09:47 PM