Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Fri 31 Oct 2014, 15:26
All times are UTC - 4
 Forum index » House Training » Beginners Help ( Start Here)
about GCC: how do I compile a 1.c file?
Moderators: Flash, Ian, JohnMurga
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [4 Posts]  
Author Message
Guest
Guest


PostPosted: Tue 17 Jan 2006, 23:49    Post subject:  about GCC: how do I compile a 1.c file?  

I created my file 1.c very simple like this :
Code:

#include <stdio.h>

main()
{
   int i;
   int j;
   printf("Put a number");
   scanf("%d",&i);
   j = i*i;
   printf("The result is %d",j);
}


then I use : gcc 1.c -o test1
But when I run test1 , there's nothing
So I how can I compile .c file and run it?
Back to top
GuestToo
Puppy Master

Joined: 04 May 2005
Posts: 4078

PostPosted: Wed 18 Jan 2006, 00:55    Post subject:  

it works for me ... do you have usr_devx.sfs installed?

# gcc 1.c -o test1
# ./test1
Put a number25
The result is 625#

(by the way, test1 is ok, but -o test may cause confusion ... there is already a system program called test)
Back to top
View user's profile Send private message 
Guest
Guest


PostPosted: Wed 18 Jan 2006, 06:35    Post subject:  

Thanks , I use rxvt and type ./test1 , it work . But why when I click on it , it don't work . And why it's ./test1 , it's not test1
Very Happy
Back to top
GuestToo
Puppy Master

Joined: 04 May 2005
Posts: 4078

PostPosted: Wed 18 Jan 2006, 07:01    Post subject:  

your program is a console (text mode) program

if you click on it, it runs, but you don't see anything, because you would have to run it in a terminal emulator (like rxvt), and clicking the program does not automatically run it in a terminal emulator

Linux usually sets up the PATH (in /etc/profile) to include various default directories, like /bin, /sbin, /usr/bin, etc etc etc ... it could include the current directory (.) in the PATH, but it does not ... this is supposed to be for security reasons ... Windows does include the current directory in the PATH

so if you want to run a program in the working directory, you have to specify the full PATH to the file ( ./ )
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 1 [4 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » House Training » Beginners Help ( Start Here)
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0537s ][ Queries: 11 (0.0164s) ][ GZIP on ]