LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-24-2005, 02:03 AM   #1
Infernal211283
Member
 
Registered: Nov 2004
Location: Mid. East / Israel
Distribution: Slackware 10.2, Gentoo
Posts: 157

Rep: Reputation: 30
Question Compiling and executing (C++)


I was going through a list of commands and i saw a command "source"
if i understand correctly it executes commands from files, so i had to try it..

i created a file with a basic loop with c programming, it is very basic:

int a=0, b=5;
while(b>0)
{
a++;
b--;
printf("%d",a);
}

but it wont run... i tried to add the "#include"s and "void main ()" but it didn't change anything...

so i want to know if:
1) source command is running C programming language?
2) is it possible to just create a file with vim and "source" run it or do i have to use some special compiler?

Thank you.
 
Old 02-24-2005, 04:50 AM   #2
__J
Senior Member
 
Registered: Dec 2004
Distribution: Slackware, ROCK
Posts: 1,973

Rep: Reputation: 46
Re: Compiling and executing (C++)

Quote:
Originally posted by Infernal211283
I was going through a list of commands and i saw a command "source"
if i understand correctly it executes commands from files, so i had to try it..

i created a file with a basic loop with c programming, it is very basic:

int a=0, b=5;
while(b>0)
{
a++;
b--;
printf("%d",a);
}

but it wont run... i tried to add the "#include"s and "void main ()" but it didn't change anything...

so i want to know if:
1) source command is running C programming language?
2) is it possible to just create a file with vim and "source" run it or do i have to use some special compiler?

Thank you.
did you have a look at man source?

the way source it typically used is to "reread" scripts, like if you changed something in your /etc/profile and wanted it to take effect right away you would do:

source /etc/profile

to reread the profile and apply the changes. It will not do what you're trying to do above. the only way to run C code is compiling ( since c code starts before main, something has to put the initialization code in the executable and thats where the compiler comes in).
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP not Executing Sometimes Herbalist Programming 3 06-20-2005 07:41 PM
Executing from cgi theonebeyond Programming 4 10-04-2004 11:30 PM
executing on startup moschi Linux - General 7 09-06-2004 12:49 PM
Need help with 'Executing' in Linux. v8n3t Linux - Software 2 04-16-2004 11:10 AM
Executing fbset suriyamohan Linux - Software 3 04-28-2003 07:04 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:48 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration