Find the answer to your Linux question:
Results 1 to 4 of 4
Hello, I've just tried both ubuntu and fedora in VMWare (virtual pc), I've managed to make this little program Code: #include <stdio.h> int main() { printf("Hello\n"); return 0; } I ...
  1. #1
    Just Joined!
    Join Date
    Dec 2007
    Posts
    2

    c program doesn't output text in terminal

    Hello,

    I've just tried both ubuntu and fedora in VMWare (virtual pc), I've managed to make this little program

    Code:
    #include <stdio.h>
    int main()
    {
    printf("Hello\n");
    return 0;
    }
    I compile and link it like this

    gcc -o test test.c

    But when I run it (by typing test) in the terminal, nothing is displayed, and I get no error message.

    However If I run it in the gdb debugger, the text is displayed.

    Since I've tried this both in Ubuntu and Fedora with the same results, I'm thinking there must be something about linux that I don't know

    thanks for any help,

    --
    Sigurd Lerstad

  2. #2
    Linux Engineer wje_lf's Avatar
    Join Date
    Sep 2007
    Location
    Mariposa
    Posts
    1,192
    There is already a real live program called "test".

    Go to a directory which does not contain your test program and say this at the command line:
    Code:
    which test
    to see where that other program is. Then do this at the command line:
    Code:
    echo $PATH
    to see the list of directories which bash will search for a program, and the order in which it searches them. I'm thinking that the directory
    Code:
    .
    is near the end of that list.

    Rename your program to something like test1 (at least in the compiled form; you can still name the source test.c if you like), and your problem should disappear.

    Hope this helps.
    --
    Bill

    Old age and treachery will overcome youth and skill.

  3. #3
    Just Joined!
    Join Date
    Dec 2007
    Posts
    2
    Quote Originally Posted by wje_lf View Post
    There is already a real live program called "test".

    Hope this helps.
    Thanks, that helped

    --
    Sigurd Lerstad

  4. #4
    scm
    scm is offline
    Linux Engineer
    Join Date
    Feb 2005
    Posts
    1,044
    Hint: call your test programs "try".

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...