running a program

This is a discussion on running a program within the Linux Programming forums, part of the Platform Specific Boards category; I am currently learning 'C' and wish to test my programs but when I try to run it its not ...

  1. #1
    Registered User
    Join Date
    Oct 2001
    Posts
    66

    running a program

    I am currently learning 'C' and wish to test my programs but when I try to run it its not working. Why is this?

    e.g. Lets say the famous hello program. if a compile it then try to run it it just gives me a message command not found.

    user:$ gcc -o hello hello.c
    user:$ hello
    error hello:bash command not found
    user:$

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,555
    The current directory is not in your path

    So type
    ./hello

  3. #3
    Comment your source code! Lynux-Penguin's Avatar
    Join Date
    Apr 2002
    Posts
    533
    when you get into programs you may want to keep for universal or personal use put them in either
    /usr/local/bin
    or
    /home/[username]/bin

    put it in the top one if you wish for anyone to use it
    put it in your own bin if you want to be the only one available to it command-line wise
    lets say I created a program called tax.c
    here is what I would do to allow myself and only myself to use it
    [user@machine folder]$ gcc tax.c -o tax
    [ compile ]
    [user@machine folder]$ chmod 760 tax; mv tax /home/user/bin
    [ to execute: ]
    [user@machine folder]$ tax
    [ Program initiated ]
    Asking the right question is sometimes more important than knowing the answer.
    Please read the FAQ
    C Reference Card (A MUST!)
    Pointers and Memory
    The Essentials
    CString lib

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Program running long
    By smarta_982002 in forum Windows Programming
    Replies: 3
    Last Post: 03-27-2008, 05:24 AM
  2. Running my program in the background
    By shoobsie in forum Windows Programming
    Replies: 4
    Last Post: 10-09-2005, 02:38 AM
  3. Replies: 3
    Last Post: 09-05-2005, 08:57 AM
  4. Why is my program running away?
    By badkitty in forum C++ Programming
    Replies: 4
    Last Post: 09-19-2001, 04:27 PM
  5. Running program
    By muffin in forum C Programming
    Replies: 5
    Last Post: 08-30-2001, 10:57 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21