winson
asked on
automaticly run the C source code
ok, i have a few C source code in particular folder
i need to build a application that will automaticly run the source code
And the application will be linking to a C compiler (let say Turbo C)
In the checking process, i need to input value to test the output. the input value will be keep in the database.
The problem is how do i interact with the Turbo C. I been able to callout the program but how do i input the value from database that i extract out
And finally get the output
THANX
i need to build a application that will automaticly run the source code
And the application will be linking to a C compiler (let say Turbo C)
In the checking process, i need to input value to test the output. the input value will be keep in the database.
The problem is how do i interact with the Turbo C. I been able to callout the program but how do i input the value from database that i extract out
And finally get the output
THANX
ASKER
ok
let's make this simple
if i have a C source code, normally i have to open Turbo C(or Borland C) to compile and run the program.
in order to test the program whether if it is correct, i must manually click the run button and key in the input value to test if the source code output the right value
but i want to automate this step with a application only
hope this clear
THANX A LOT
let's make this simple
if i have a C source code, normally i have to open Turbo C(or Borland C) to compile and run the program.
in order to test the program whether if it is correct, i must manually click the run button and key in the input value to test if the source code output the right value
but i want to automate this step with a application only
hope this clear
THANX A LOT
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
one thing i have to remind you that,
now you can use scanf to get data input
you should use the arguments in your main instead
so that no interaction within your program.
since after vb execute your program the DOS screen will be disappeared,
so that i think u better write the output into a text file instead of using printf to display the result.
now you can use scanf to get data input
you should use the arguments in your main instead
so that no interaction within your program.
since after vb execute your program the DOS screen will be disappeared,
so that i think u better write the output into a text file instead of using printf to display the result.
ASKER
sorry for the delay if reply
the last request is how do i use the shell in VB programming
can u please give me a clearer picture
i haven't use the shell in VB before
THANX AGAIN
the last request is how do i use the shell in VB programming
can u please give me a clearer picture
i haven't use the shell in VB before
THANX AGAIN
ASKER
sorry for the delay if reply
the last request is how do i use the shell in VB programming
can u please give me a clearer picture
i haven't use the shell in VB before
THANX AGAIN
the last request is how do i use the shell in VB programming
can u please give me a clearer picture
i haven't use the shell in VB before
THANX AGAIN
Here i quoted a sample code from MSDN.
' Specifying 1 as the second argument opens the application in
' normal size and gives it the focus.
Dim RetVal
RetVal = Shell("C:\WINDOWS\CALC.EXE ", 1) ' Run Calculator.
So you may change the above to:
RetVal = Shell("C:\TC\BIN\TC.EXE mobilephone.c -o mobilephone.exe", 6)
6 stands for Window is displayed as an icon. The currently active window remains active.
If you need further help, i can email you a html which show details on VB Shell function.
or you can go to msdn.microsoft.com and then search Shell function.
' Specifying 1 as the second argument opens the application in
' normal size and gives it the focus.
Dim RetVal
RetVal = Shell("C:\WINDOWS\CALC.EXE
So you may change the above to:
RetVal = Shell("C:\TC\BIN\TC.EXE mobilephone.c -o mobilephone.exe", 6)
6 stands for Window is displayed as an icon. The currently active window remains active.
If you need further help, i can email you a html which show details on VB Shell function.
or you can go to msdn.microsoft.com and then search Shell function.
ASKER
yes
please mail me the details
but you have to give me time to digest this things before the point is given
THANX ANYWAY
please mail me the details
but you have to give me time to digest this things before the point is given
THANX ANYWAY
ASKER
my email
pohkheng@tm.net.my
pohkheng@tm.net.my
ASKER
one last question
u said
"so that i think u better write the output into a text file instead of using printf to display the result. "
can i do it the printf way and how am i going to get the output value
u said
"so that i think u better write the output into a text file instead of using printf to display the result. "
can i do it the printf way and how am i going to get the output value
The method of how to interact your VB program and your C program is that:
try to get rid of asking user to input (your test values) for example scanf
so you may ask, how do i input those test values?!?!
i recommend you try to define parameters in your main()
so that you can execute your C program like this:
myCProg.exe "data1", "data2", "data3"
the no. of parameters depends on the no. of your test data input (no. of scanf) in your C program.
so that you can combine to above technique with using VB Shell command.
try to get rid of asking user to input (your test values) for example scanf
so you may ask, how do i input those test values?!?!
i recommend you try to define parameters in your main()
so that you can execute your C program like this:
myCProg.exe "data1", "data2", "data3"
the no. of parameters depends on the no. of your test data input (no. of scanf) in your C program.
so that you can combine to above technique with using VB Shell command.
ASKER
ok
if i now change the Turbo C to Borland C++
can i do the same thing
if i now change the Turbo C to Borland C++
can i do the same thing
yup!
as you know how to invoke the compiler in Borland C++
i think the filename may be bcc.exe or bc.exe something like that
the most important is that it supports command-line operation
so that no IDE is loaded while performing the compilation.
Good Luck!
as you know how to invoke the compiler in Borland C++
i think the filename may be bcc.exe or bc.exe something like that
the most important is that it supports command-line operation
so that no IDE is loaded while performing the compilation.
Good Luck!
ASKER
About the code below
how do i get the input
ok, let say that i want to input 2 value and add it up
the result be write to a file
can you please show me the coding for this
THANX A LOT
#include <iostream.h>
#include <string.h>
void main( int argc, char *argv[], char *envp[] )
{
int iNumberLines = 0; // Default is no line numbers.
// If more than .EXE filename supplied, and if the
// /n command-line option is specified, the listing
// of environment variables is line-numbered.
if( argc == 2 && stricmp( argv[1], "/n" ) == 0 )
iNumberLines = 1;
// Walk through list of strings until a NULL is encountered.
for( int i = 0; envp[i] != NULL; ++i )
{
if( iNumberLines )
cout << i << ": " << envp[i] << "\n";
}
}
how do i get the input
ok, let say that i want to input 2 value and add it up
the result be write to a file
can you please show me the coding for this
THANX A LOT
#include <iostream.h>
#include <string.h>
void main( int argc, char *argv[], char *envp[] )
{
int iNumberLines = 0; // Default is no line numbers.
// If more than .EXE filename supplied, and if the
// /n command-line option is specified, the listing
// of environment variables is line-numbered.
if( argc == 2 && stricmp( argv[1], "/n" ) == 0 )
iNumberLines = 1;
// Walk through list of strings until a NULL is encountered.
for( int i = 0; envp[i] != NULL; ++i )
{
if( iNumberLines )
cout << i << ": " << envp[i] << "\n";
}
}
ASKER
sorry
it is not
"how do i get the input"
but "how i put the input"
it is not
"how do i get the input"
but "how i put the input"
So, in your VB calling program,
call this program like this:
shell "calc " & num1[i] & " " & num2[i]
which inside a for loop (for your no. of pairs of the test data)
tell me if you still have problems.
#include <iostream.h>
#include <string.h>
#include <stdlib.h>
void main( int argc, char *argv[], char *envp[] ) {
float lfNum1, lfNum2;
lfNum1 = atof(argv[1]);
lfNum2 = atof(argv[2]);
cout << lfNum1 + lfNum2 << "\n";
}
call this program like this:
shell "calc " & num1[i] & " " & num2[i]
which inside a for loop (for your no. of pairs of the test data)
tell me if you still have problems.
#include <iostream.h>
#include <string.h>
#include <stdlib.h>
void main( int argc, char *argv[], char *envp[] ) {
float lfNum1, lfNum2;
lfNum1 = atof(argv[1]);
lfNum2 = atof(argv[2]);
cout << lfNum1 + lfNum2 << "\n";
}
r u going to implement to by using a vb function named Shell?
If it is true, now you have a problem on how to put the test value from a database to perform some kind of 'stress test'?
m i understand your problem precisely?
i need further info.
would u mind to tell me the details of your test program?
i dont understand one thing:
what u mean automcatically run the source code...
- u mean compile your source code?
or
- execute your test program?