Go Back   PCMech Forums > Help & Discussion > Web Design / Development

Need Some Help? Type Your Keywords Here:

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Old 05-25-2005, 07:05 PM   #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?
Nickoli is offline   Reply With Quote
Old 05-25-2005, 07:12 PM   #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
hETUL is offline   Reply With Quote
Old 05-25-2005, 07:31 PM   #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?
Nickoli is offline   Reply With Quote
Old 05-26-2005, 06:57 AM   #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
hETUL is offline   Reply With Quote
Old 05-26-2005, 06:59 AM   #5
Member (7 bit)
 
shaticus's Avatar
 
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.
shaticus is offline   Reply With Quote
Old 05-26-2005, 02:10 PM   #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
Nickoli is offline   Reply With Quote
Old 05-26-2005, 07:18 PM   #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.
hETUL is offline   Reply With Quote
Old 05-26-2005, 08:26 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
Nickoli is offline   Reply With Quote
Old 05-26-2005, 09:54 PM   #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");
mattg2k4 is offline   Reply With Quote
Old 05-27-2005, 05:16 PM   #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
Nickoli is offline   Reply With Quote
Reply

Bookmarks

Still Need Help? Type Your Keywords Here:


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 07:23 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
SEO by vBSEO 3.6.0 PL2