Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Student question on external calls.

Reply
Thread Tools

Student question on external calls.

 
 
Hagar
Guest
Posts: n/a
 
      04-20-2004
I am currently learning C++ and am into a project for the end of the
semester finals. Everything is rosy except for one feature that I want
to include and can't find in my very large and expensive C++ books. Plus,
I don't want to ask the instructor because that will give my project away.

How do you call an external non C++ program, or possibly a system
function? For instance, I have some very good Perl modules from my last
class that parse text files and I would like to call them from a menu in
my C program. (Why the heck, you say? Because in theory, my program can
call external scripts that can be changed by the assumed user and if they
were compiled into MAIN then they would be fixed functions. Remember,
this is for credit, not deployment.)

But I don't find anything (or maybe don't recognize it) in
my manuals - calling, external calls, external functions, system, system
calls, etc - apparently none of the above. I even spent some time in the
local Booksamillion looking through their stacks (for free, I admit it)
and didn't find the keyword I am looking for.

What is interesting is that I can easily call a C program from a Perl
script, but not the other way around.

Anybody?

Thanks all
Hagar (but not too horrible).
 
Reply With Quote
 
 
 
 
Rakesh Kumar
Guest
Posts: n/a
 
      04-20-2004
Therez a C function by name - 'system (<path_to_exec> ) ' that can do
what you want ! Check it out in google.

Hagar wrote:

> I am currently learning C++ and am into a project for the end of the
> semester finals. Everything is rosy except for one feature that I want
> to include and can't find in my very large and expensive C++ books. Plus,
> I don't want to ask the instructor because that will give my project away.
>
> How do you call an external non C++ program, or possibly a system
> function? For instance, I have some very good Perl modules from my last
> class that parse text files and I would like to call them from a menu in
> my C program. (Why the heck, you say? Because in theory, my program can
> call external scripts that can be changed by the assumed user and if they
> were compiled into MAIN then they would be fixed functions. Remember,
> this is for credit, not deployment.)
>
> But I don't find anything (or maybe don't recognize it) in
> my manuals - calling, external calls, external functions, system, system
> calls, etc - apparently none of the above. I even spent some time in the
> local Booksamillion looking through their stacks (for free, I admit it)
> and didn't find the keyword I am looking for.
>
> What is interesting is that I can easily call a C program from a Perl
> script, but not the other way around.
>
> Anybody?
>
> Thanks all
> Hagar (but not too horrible).


--

--
Rakesh Kumar
** Remove nospamplz from my email address for my real email **
 
Reply With Quote
 
 
 
 
Jeff Schwab
Guest
Posts: n/a
 
      04-20-2004
Hagar wrote:

> How do you call an external non C++ program, or possibly a system
> function? For instance, I have some very good Perl modules


....

> What is interesting is that I can easily call a C program from a Perl
> script, but not the other way around.


To pass arbitrary commands to your execution environment, use the
"system" function from <cstdlib>. Perl also has excellent facilities
for being embedded in C and C++ programs.

http://search.cpan.org/~abergman/pon.../perlembed.pod

3rd-party libraries are available to make it even easier. E.g., see:

http://search.cpan.org/~jtobey/pickle-0.5.1/pickle.pod
 
Reply With Quote
 
Hagar
Guest
Posts: n/a
 
      04-20-2004
> But I don't find anything (or maybe don't recognize it) in
> my manuals - calling, external calls, external functions, system, system



Thanks guys. Interestingly, system is what perl uses to call outside the
main code. But... There is not a single reference to the system command
in either of my C++ books, or popen or exec which others have suggested -
apparently, students aren't supposed to move outside of the box.

Obviously, what I need is a genuwine C++ book from a non-college
bookstore. However, even though those don't cost as much as the ripoff
price of textbooks, they still are not cheap, studentwise. Maybe I can
code some rich kids homework for the price

Thanks
Hagar (but not too horrible).
 
Reply With Quote
 
red floyd
Guest
Posts: n/a
 
      04-20-2004
Hagar wrote:
>>But I don't find anything (or maybe don't recognize it) in
>>my manuals - calling, external calls, external functions, system, system

>
>
>
> Thanks guys. Interestingly, system is what perl uses to call outside the
> main code. But... There is not a single reference to the system command
> in either of my C++ books, or popen or exec which others have suggested -
> apparently, students aren't supposed to move outside of the box.
>
> Obviously, what I need is a genuwine C++ book from a non-college
> bookstore. However, even though those don't cost as much as the ripoff
> price of textbooks, they still are not cheap, studentwise. Maybe I can
> code some rich kids homework for the price


No. popen() and exec() won't be in any book describing C++, as they
aren't part of the Standard. They would be in a book describing "C++
Programming in a [YOUR_OS_HERE] Environment".

I don't recall whether system() is part of the Standard either, but it
would be described in the second type of book ("C++ for XXX Environment").
 
Reply With Quote
 
Default User
Guest
Posts: n/a
 
      04-20-2004
Hagar wrote:

> Thanks guys. Interestingly, system is what perl uses to call outside the
> main code. But... There is not a single reference to the system command
> in either of my C++ books,


That's a failing.

> or popen or exec which others have suggested -


There are no such things in C++. Some implementations have extensions by
these names, but unless your book specificially covers that platform, it
would not be unusual for it not to mention them. You don't mention which
books you are using.

> apparently, students aren't supposed to move outside of the box.


I don't understand this statement.

> Obviously, what I need is a genuwine C++ book from a non-college
> bookstore. However, even though those don't cost as much as the ripoff
> price of textbooks, they still are not cheap, studentwise. Maybe I can
> code some rich kids homework for the price


Check your local public library, it may have useful books.


Brian Rodenborn
 
Reply With Quote
 
Default User
Guest
Posts: n/a
 
      04-20-2004
red floyd wrote:

> I don't recall whether system() is part of the Standard either, but it
> would be described in the second type of book ("C++ for XXX Environment").


Yes, it is.



Brian Rodenborn
 
Reply With Quote
 
Hagar
Guest
Posts: n/a
 
      04-20-2004
>
>> Thanks guys. Interestingly, system is what perl uses to call outside the
>> main code. But... There is not a single reference to the system command
>> in either of my C++ books,

>
> That's a failing.



As my instructor says, textbooks are to make publishers money - they have
nothing to do with teaching or learning - unfortunately, they are also
mandated by the state based on the amount of donations received by
politicians from publishers.


n't supposed to move outside of the box.
>
> I don't understand this statement.
>

Just some minor sarcasm.


> Check your local public library, it may have useful books.
>


Brian - You are not from East Texas, are you? In our only public library
there are books about the latest advances in V2 rocketry, history books
that speculate on what the world will be like after WWII ends, the latest
research on vacuum tube radios, and info on something called a wire
recorder that actually records voices.

Oh yes. There is also a programming book. It is about Autocoder
that runs on an IBM 1401 ??? (whatever the heck that is).


I think I better wait till I have the money to visit a real Dallas book
store.

Hagar
 
Reply With Quote
 
Default User
Guest
Posts: n/a
 
      04-20-2004
Hagar wrote:

> > Check your local public library, it may have useful books.
> >

>
> Brian - You are not from East Texas, are you?


No.

> Oh yes. There is also a programming book. It is about Autocoder
> that runs on an IBM 1401 ??? (whatever the heck that is).


Almost any library can get books via inter-library loan.




Brian Rodenborn
 
Reply With Quote
 
 
 
Reply

Thread Tools

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 Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
student question John Python 3 01-08-2011 06:33 PM
SystemC : Can a CS student do it? GoodProggie101 VHDL 0 02-29-2004 06:15 PM
REQ: Question on how to call functions (New JavaScript Student) Sue Javascript 5 12-15-2003 05:24 AM
REQ: New Question Form ( new JavaScript Student ) Sue Javascript 8 12-13-2003 11:37 PM
A student's question Chen Bin VHDL 7 09-04-2003 04:39 PM



Advertisments