Thread: Help getting started with C

  1. #1
    Registered User
    Join Date
    Dec 2005
    Posts
    2

    Help getting started with C

    Hi

    I recently installed Turbo C by running install.exe
    It got installed in C:\TC directory.

    I created my first C program and saved it in some other directory C:\ABC

    On Command prompt it I use following statement: tc , it is not recognizing the command. So I did the following:

    edit c:\autoexec.bat

    I added following statement in that:
    set path=%path%;c:\tc\init.bat

    Save & Exit.

    Autoexec (hit enter to execute the file)

    but still I am not able to use commands in directories other than C:\TC

    Any suggestions?

  2. #2
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,218
    The PATH environment variable should be a semi-colon delimited list of directories, not files. Find the tc.exe file in that tc directory. Sometimes programs have a bin folder so if you don't find a c:\tc\tc.exe then maybe look for a c:\tc\bin\tc.exe. Whichever directory you find it in, add that directory to your path (i.e. "set path=%path%;c:\tc", or "set path=%path%;c:\tc\bin")

    Or get a compiler that isn't 10 years old Dev-C++ is a very decent one and it's free.
    Last edited by itsme86; 12-13-2005 at 11:51 AM.
    If you understand what you're doing, you're not learning anything.

  3. #3
    Registered User
    Join Date
    Dec 2005
    Posts
    2
    Thanks for the reply. I downloaded the Dev-C++ and compiled my programs. But after running the program I don't see the output in the results window.

    What could be the possibility?

  4. #4
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,218
    Once the program finishes the command window closes. Try adding a getchar() or something to the end of the program so it waits for user input. Or try running your program from inside the command window instead of just double-clicking the icon.
    If you understand what you're doing, you're not learning anything.

  5. #5
    Registered User ssharish2005's Avatar
    Join Date
    Sep 2005
    Location
    Cambridge, UK
    Posts
    1,732
    make sure that u call this sample follwing function before u call the getchar function. provided if you call getchar after the scanf function has called

    Code:
    void clear_buffer(void) // fucntion prototype
    
    void clear_buffer(void)
    {
           int ch;
    
           while((ch=getchar())!='\n' && ch!=EOF);
    }
    to know the reason of why to call this fucntion read the FAQ u will come to know some interesting reason

    ssharish2005

  6. #6
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    Code:
    void clear_buffer(void) // fucntion prototype
    ->
    Code:
    void clear_buffer(void); // fucntion prototype
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  7. #7
    Registered User
    Join Date
    Dec 2005
    Posts
    4
    Another way ...

    Code:
    #include <stdio.h>
    
    main()
    {
    
        /*
        ...
        ...
        ...
        */
    
        fflush(stdin);
        getchar();
    }

  8. #8
    Registered Luser cwr's Avatar
    Join Date
    Jul 2005
    Location
    Sydney, Australia
    Posts
    869
    kosodo,

    It is generally considered irritating when someone asks a question before reading the FAQ.

    It is generally considered extremely irritating when someone answers a question before reading the FAQ.

    Don't use fflush(stdin), ever.

  9. #9
    Registered User ssharish2005's Avatar
    Join Date
    Sep 2005
    Location
    Cambridge, UK
    Posts
    1,732
    Quote Originally Posted by dwks
    Code:
    void clear_buffer(void) // fucntion prototype
    ->
    Code:
    void clear_buffer(void); // fucntion prototype

    my typing mistake sorry

    ssharish2005

  10. #10
    Registered User
    Join Date
    Dec 2005
    Posts
    4
    Quote Originally Posted by cwr
    kosodo,

    It is generally considered irritating when someone asks a question before reading the FAQ.

    It is generally considered extremely irritating when someone answers a question before reading the FAQ.

    Don't use fflush(stdin), ever.
    Sorry, I didn't mean anything but try to help. Those lines of codes are learned from this training cource: http://www.vtc.com/products/cprog.htm. Once again, sorry! I'm reading the FAQ. couldn't imagine it is this helpful ...

  11. #11
    Registered Luser cwr's Avatar
    Join Date
    Jul 2005
    Location
    Sydney, Australia
    Posts
    869
    If you see fflush(stdin) in tutorial code (aside from telling you not to use it), then it's a spectacular indication to not trust anything else from it.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help getting started..matrices
    By BobDole11 in forum C Programming
    Replies: 7
    Last Post: 11-15-2008, 09:51 PM
  2. Help getting started :(
    By blackocellaris in forum C Programming
    Replies: 4
    Last Post: 11-05-2006, 06:50 PM
  3. Getting started
    By panzeriti in forum Game Programming
    Replies: 3
    Last Post: 06-28-2003, 10:13 AM
  4. How to get started?
    By anoopks in forum Linux Programming
    Replies: 0
    Last Post: 01-14-2003, 03:48 AM
  5. Need help getting started
    By Unregistered in forum C++ Programming
    Replies: 4
    Last Post: 09-02-2001, 11:08 PM