Hi,
I'm trying to get this program to read, then print, the output from another short program (hw7.c) it compiles fine but then does not return the values I want it to. I'm assuming I have a problem with my fscanf function. Any help would be great. -
-
/* the idea is to read the ouput from hw7.c and return these values */
-
#include <stdio.h>
-
#define FILENAME "hw7.c"
-
int main(void)
-
{
-
/* declare and initialize variables */
-
float max, min;
-
FILE *hw7;
-
-
/* open input program */
-
-
hw7 = fopen("hw7.c", "r");
-
if ( hw7 == NULL)
-
printf("Error opening hw7. \n");
-
/* good to go above here */
-
-
fscanf(hw7, "%f %f", &max, &min);
-
-
/*print summary */
-
printf("Max: %f \n", max);
-
printf("Min: %f \n", min);
-
-
/* close input program */
-
-
fclose(hw7);
-
-
return 0;
-
}
-
Thanks,
Joel
4 3600
Hi,
I'm trying to get this program to read, then print, the output from another short program (hw7.c) it compiles fine but then does not return the values I want it to. I'm assuming I have a problem with my fscanf function. Any help would be great. -
-
/* the idea is to read the ouput from hw7.c and return these values */
-
#include <stdio.h>
-
#define FILENAME "hw7.c"
-
int main(void)
-
{
-
/* declare and initialize variables */
-
float max, min;
-
FILE *hw7;
-
-
/* open input program */
-
-
hw7 = fopen("hw7.c", "r");
-
if ( hw7 == NULL)
-
printf("Error opening hw7. \n");
-
/* good to go above here */
-
-
fscanf(hw7, "%f %f", &max, &min);
-
-
/*print summary */
-
printf("Max: %f \n", max);
-
printf("Min: %f \n", min);
-
-
/* close input program */
-
-
fclose(hw7);
-
-
return 0;
-
}
-
Thanks,
Joel
If u are reading the C code , how u can use a float to read it.
It shuld be a char buffer u shuld be using.
Raghuram
If you are really going to read the output from another program, then you have to execute that program and not just read its source code.
Maybe you could run hw7.c and store its output in a file, then run this program and read from that file, rather than reading from hw7.c (which will have you reading C code).
HI...
if i understand you correctlly, you must create your exe file from hw7.cpp program and use API createProcess to run it and then use Pipe to read output from it.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Rafal Lagowski |
last post by:
Hi all
This is my small problem ...
I have a program which make a long long statistic (about 2 minutes)
It enough to timeout in my browser (or squid proxy of client)
I want first make a...
|
by: federico |
last post by:
Hello, how can I make a program respond to another program's input request?
For example, this code:
Process.Start("unrar.exe", "e D:\temp\key.rar D:temp2")
SendKeys.SendWait("test~")
will...
|
by: utab |
last post by:
Dear all,
I am making a system call to the well known Gnuplot with
system("gnuplot");
gnuplot opens if I only supply this command but I would like to pipe
that command line in my C++...
|
by: Stuart Moore |
last post by:
I've tried searching for the following, but I've had no luck.
I want to execute another program from within my C++ program, and read
it's stdout in a similar way to reading from a file. I do not...
|
by: 31337one |
last post by:
Hello everyone,
I am using a python script as a way to test another program that I have
written in C++. The program cannot be altered. It needs to stay the way
it is.
I need to simulate a few...
|
by: Netaro |
last post by:
Well...
So, i have a program. A normal program, which does something, and so..
and i have another program, which wants to run the first program....
So, there are 2 questions about that problem...
|
by: jrbush82 |
last post by:
I am trying to read the standard out of another program into an array or string in my C++ program. I need to read each line individually because based on the output depends on what the program will...
|
by: parajaganesh |
last post by:
I have a program which results some output (it is in an array). These outputs need to be passed to another program for further process.
Anybody help me to do this...?
|
by: WackoZacho |
last post by:
I've tried searching on Google and for other questions similar to mine, but all I get are results on how to use the LostFocus event or Deactivate, etc., but I'm under the impression each of these...
|
by: maximus tee |
last post by:
hi all,
i wrote a simple GUI with 2 buttons. Button1 is to launch another program. Button2 is to run test. When I click Button1, it will launch another program. After launching the program, my...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |