954,499 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

system command not working in C functions.pls help

Dear Friends,

I am developing a small project in which the users have to fill a form from which it will be saved into a database.

Here i wanted to scan a particular folder in the hard-drive contineously so as to know if there is any new file saved in it.

Hence i have written a program(program 1) to do this task and i want to call this program in another c program which collects the data from users and hence while the users are filling the form,the program 1 would contineously scan the hard-drive so as to detect a particular file and if present would flash a message to the user.

I have tried using system command but to no use.

Please help.

Note : I am using Borland Turboc3 3.0 compiler.

Thanks & Regards
Rituraj Raina

riturajraina
Newbie Poster
12 posts since Sep 2004
Reputation Points: 10
Solved Threads: 0
 

>I have tried using system command but to no use.
How did you try it? Is this in a separate thread? Does it not work because of a syntax error or something else? Be as specific as possible and give code examples. Otherwise you'll get nothing but stoney silence.

>Note : I am using Borland Turboc3 3.0 compiler.
Jeez, get a newer compiler. :rolleyes:

Narue
Bad Cop
Administrator
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
 

>I have tried using system command but to no use. How did you try it? Is this in a separate thread? Does it not work because of a syntax error or something else? Be as specific as possible and give code examples. Otherwise you'll get nothing but stoney silence.

>Note : I am using Borland Turboc3 3.0 compiler. Jeez, get a newer compiler. :rolleyes:

Dear Narue,
Here is the section of the code that i used :

#include
#include
#include
#include


int main(void)
{
clrscr();
printf("About to spawn command interpreter and run a DOS command\n");
system("dir");
getch();
return 0;
}

When executed ,it just shows on the screen the string written in printf when i include file #include

When i tried using #include or #include then it flashes an error: "Unable to include file cstdlib.h or cstdlib.

If you have some solution then kindly help.

Also if i were to upgrade the compiler ,then which compiler should i use and from where i can get one?

riturajraina
Newbie Poster
12 posts since Sep 2004
Reputation Points: 10
Solved Threads: 0
 

Hi, Riturajraina

I tried your piece of code in Dev-C++ 4.9.9.0 compiler (available for free download at www.bloodshed.net ), and it's working just fine (just delete the clrscr command)...

frrossk
Posting Whiz in Training
220 posts since Sep 2004
Reputation Points: 17
Solved Threads: 9
 

I ment replace clrscr() with system ("cls") (it's equivalent, and it does another system call for you :cool: )

frrossk
Posting Whiz in Training
220 posts since Sep 2004
Reputation Points: 17
Solved Threads: 9
 

>If you have some solution then kindly help.
Get a newer compiler. Your problem is that you're trying to use modern C++ with an ancient compiler that doesn't know what modern C++ is.

>then which compiler should i use and from where i can get one?
Dev-C++ is a good one. Search google for Bloodshed's web site where you can download it for free.

Narue
Bad Cop
Administrator
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
 

Dear Narue/Frrossk,

Thanks for all your help.

I have downloaded Dev compiler and executed the system command which worked fine.

But now i am facing a new problem.

I tried to compile the c++ source code files which i have written in the Turboc3 3.0 compiler .It is flashing a no. of error messages like "In file included in file goto.cpp" etc.

When i compile the same source files in Turboc3 3.0 compiler,then it doesn't display any error messages and the program is executing fine.

I am sorry to trouble you again & again but request you to please get me out of this.

Its a very embarassing situation.

Thanks again
Rituraj

riturajraina
Newbie Poster
12 posts since Sep 2004
Reputation Points: 10
Solved Threads: 0
 

>But now i am facing a new problem.
Post one of the programs that doesn't compile with Dev-C++ and does with Turbo C++. Most likely you're using a library that extension that Dev-C++ doesn't support.

Narue
Bad Cop
Administrator
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
 

i suppose i may give you a solution. are you an intermediate user of C? if so then try in this way-

1. go to run
2. use command.com to execute
3. go to tc.exe by providing entire path of the TC compiler folder
4. #include in your code and compile your code
5. then go to exit from the TC compiler. file -> exit option
6. now u r in dos prompt again
7. write the name of program exe and then you will find the out put that will show the sub directories of the current directories.

please do let me know whether it worked or not?

memehboob
Newbie Poster
4 posts since Jan 2008
Reputation Points: 10
Solved Threads: 0
 

>please do let me know whether it worked or not?
Factoring in that this thread is four years old and the OP hasn't posted in two years, I'd say that's unlikely.

Narue
Bad Cop
Administrator
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You