473,320 Members | 1,876 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Student question on external calls.

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).
Jul 22 '05 #1
8 1495
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 **
Jul 22 '05 #2
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
Jul 22 '05 #3
> 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).
Jul 22 '05 #4
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").
Jul 22 '05 #5
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
Jul 22 '05 #6
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
Jul 22 '05 #7
>
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
Jul 22 '05 #8
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
Jul 22 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Dariusz | last post by:
I currently have a layout that is part written in SHTML - in other words, it gets processed by the web server to execute any calls for PHP or Perl code as well as the html (and external imported...
3
by: Linus Nikander | last post by:
After trying to manually reverse-engineer a piece of code i've been handed using Visio I figure someone must have developed a tool that can do automatically in 5 minutes what took me 2 hours. ...
2
by: Juan Manuel Alegría B. | last post by:
Hi group I have been making a windows service to execute an external application. I use a timer control, I can execute the application but does't appear as a normal windows, just I see it in the...
8
by: Scott Allen | last post by:
Hello, I'm new to C++ development and I'm trying out figure out the cause of an 'unresolved external symbol' error that I'm receiving when compiling. Here is some history on what I'm doing: I...
47
by: Richard Hayden | last post by:
Hi, I have the following code: /******************************** file1.c #include <iostream> extern void dummy(); inline int testfunc() {
1
by: stevo | last post by:
What causes C# to generate code to call the same external DLL 2 different ways? At one point in the app, it calls the entry point like this (disassembled) and it bombs with a null reference:...
0
by: zxcv | last post by:
I have inherited an app that is using java to generate images that it loads into a PDF via external-graphic in XSL-FO. The problem I have is that my architecture environment is going to require in...
2
by: Maydogg6 | last post by:
I need a hand with some stubborn link errors. I'm trying to recreate and old program from 6.0 into .NET, but for some reason when I try to compile I'm getting linking errors for all my function...
3
by: pompeyoc | last post by:
Hi. I was wondering if anyone out here knows if there is a limit to the size of an external stored procedure? I am currently using VB programs in Windows to call small COBOL stored procs residing...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.