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 Sun 21 Sep 2014, 12:27
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 Posts_count  
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:   Sort by:   
Page 1 of 1 Posts_count  
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
 Forum index » House Training » Beginners Help ( Start Here)
Jump to:  

Rules_post_cannot
Rules_reply_cannot
Rules_edit_cannot
Rules_delete_cannot
Rules_vote_cannot
You cannot attach files in this forum
You can download files in this forum


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