|
|||||||
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
#1 |
|
Member (8 bit)
Join Date: Jun 2004
Location: Canada
Posts: 164
|
compiling programs in C not recognizing files
I'm new to programming, I've done a little programming in a class at school using pascal, and now I'm attempting C. Anyway my problem comes when I attempt to compile the text file. the file is saved as hello.c, the compiler is installed properly, in the command prompt I'm navigated to the right directory, but when I type gcc hello.c I get an error saying:
GCC: hello.c: No such file or directory GCC: no input files so, any idea what's going on? |
|
|
|
|
|
#2 |
|
Member (6 bit)
Join Date: Feb 2005
Posts: 35
|
gcc - o hello.exe -Wall hello.c
Try this, this will create hello.exe file into same directory where your hello.c is. then you can use dos to run the program. HOPE THIS HELPS |
|
|
|
|
|
#3 |
|
Member (8 bit)
Join Date: Jun 2004
Location: Canada
Posts: 164
|
ah quick response... sadly I'm getting the same error. anything else you can think of?
|
|
|
|
|
|
#4 |
|
Member (6 bit)
Join Date: Feb 2005
Posts: 35
|
Here is a link to solution, i think its easier to link then typing much of the same.
http://www.delorie.com/djgpp/v2faq/faq8_1.html HOPE THIS HELPS |
|
|
|
|
|
#5 |
|
Member (7 bit)
Join Date: May 2004
Posts: 103
|
What o/s are you using?
If you are running windows you could try to drag and drop your source file on to the compiler. I think it may be a problem with your path variable. you could try typing the complete path to the file. (IE gcc c:\source\hello.c) If gcc responds with no input files it is because it cant find the file your telling it to compile. |
|
|
|
|
|
#6 |
|
Member (8 bit)
Join Date: Jun 2004
Location: Canada
Posts: 164
|
ahh one problem solved! windows did in fact save hello.c with the .txt extension. now, when I try to compile, I get the error "hello.c:7:2: warning: no new line at end of file" so whats happening now? lol. thanks for helping out a newb everyone
|
|
|
|
|
|
#7 |
|
Member (6 bit)
Join Date: Feb 2005
Posts: 35
|
I'm not saying that gcc is not good. but there is a IDE call dev-c++( its just named that but it does work with c).it is easy to use for newbie.
i use that and find it easy to use(I'm newbie too but not that new.) http://ftp1.sourceforge.net/dev-cpp/devcpp4.zip IF the programm you trying to write works with dev than give it a try with gcc. The error you getting is just the warning so the programm should work. Last edited by hETUL; 05-26-2005 at 07:21 PM. |
|
|
|
|
|
#8 |
|
Member (8 bit)
Join Date: Jun 2004
Location: Canada
Posts: 164
|
#include
int main() { printf("Hello World\n"); return 0; } ok, theres the program... it did compile, so now how do i run it? when i try and open the .exe counterpart, it opens a command prompt window momentarily but nothing happens. oh my. lol. such newb questions
|
|
|
|
|
|
#9 |
|
Member (10 bit)
Join Date: Jul 2002
Location: University of California, Santa Barbara
Posts: 800
|
You need to execute the program from the command line, because right now it opens a command line, prints it out, finishes the program, and exits the windows.
If you're already in the command line, it will print this out, but because you're already in a command line window it won't exit. Or you can add a pause command to the end of your program, I think you need to include stdlib.h and execute system("pause"); |
|
|
|
|
|
#10 |
|
Member (8 bit)
Join Date: Jun 2004
Location: Canada
Posts: 164
|
perfect, thanks everyone for your help! my problems have been solved, now I should be able to get on to learning the language. thanks again
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|