You are not logged in.

Dear visitor, welcome to QtForum.org. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

rokrsa

Beginner

  • "rokrsa" is male
  • "rokrsa" started this thread

Posts: 10

Location: India

Occupation: Student

  • Send private message

1

Friday, July 29th 2005, 11:17am

Unable to use system command

hello frenz,
I am really surprised that i am not able to use the system() functuion , neither the fork or the exec command.
I know there is something like kdeinitExec , but still is it possible to use system() ?

Plz help me out.

Latem

Intermediate

  • "Latem" is male

Posts: 278

Location: New Brunswick, Canada

Occupation: Student/Programmer

  • Send private message

2

Thursday, August 4th 2005, 5:09pm

AFAIK, there is no reason why you shouln't be able use those functions. What do you mean by not being able to use them? It doesn't compile? It compiles fine, but doesn't do anything when run? More details and sample code would be helpful. Also there are higher-level methods of doing what these would be used for, which may be appropriate instead.

Latem
The march of progress:
C:
printf("%10.2f", x);
C++:
cout << setw(10) << setprecision(2) << showpoint << x;
Java:
java.text.NumberFormat formatter = java.text.NumberFormat.getNumberInstance();
formatter.setMinimumFractionDigits(2);
formatter.setMaximumFractionDigits(2);
String s = formatter.format(x);
for (int i = s.length(); i < 10; i++) System.out.print(' ');
System.out.print(s);

rokrsa

Beginner

  • "rokrsa" is male
  • "rokrsa" started this thread

Posts: 10

Location: India

Occupation: Student

  • Send private message

3

Monday, August 8th 2005, 1:00pm

hiiii
i think u miss took my problem....
My prob was dat i am unable 2 use the system() function in KDevelop ..eg

system("play 1.wav");

This gives me error on compilation and says dat system function not defined.
But when u use the gcc compiler to compile the prg it works finely

Plz help me out !!!!!!!!!!

ronak

  • "wysota" is male

Posts: 4,276

Location: Warsaw, POLAND

  • Send private message

4

Monday, August 8th 2005, 1:11pm

#include <stdlib.h> would probably help. Alternatively you can put "int system(const char*);", the result will be the same.

rokrsa

Beginner

  • "rokrsa" is male
  • "rokrsa" started this thread

Posts: 10

Location: India

Occupation: Student

  • Send private message

5

Monday, August 8th 2005, 1:28pm

Hey,
i did try out the #include <stdlib.h>
It doesnt work.

U said me to declare int system(const char*);
But that wud giv me a new function nd i wudnt be able 2 use the functionality of the normal system function

  • "wysota" is male

Posts: 4,276

Location: Warsaw, POLAND

  • Send private message

6

Monday, August 8th 2005, 1:45pm

Quoted

Originally posted by rokrsa
Hey,
i did try out the #include <stdlib.h>
It doesnt work.


What errors do you get?

Quoted


U said me to declare int system(const char*);
But that wud giv me a new function nd i wudnt be able 2 use the functionality of the normal system function


No, that would be a declaration of a system function and its definition would be taken from libc. If you look at the header files, it's exactly the same what you have there.

Source code

1
2
$ grep "int system" /usr/include/stdlib.h
extern int system (__const char *__command);

rokrsa

Beginner

  • "rokrsa" is male
  • "rokrsa" started this thread

Posts: 10

Location: India

Occupation: Student

  • Send private message

7

Monday, August 8th 2005, 2:14pm

can u explain me clearly ?
exactly wat do i need 2 write?

  • "wysota" is male

Posts: 4,276

Location: Warsaw, POLAND

  • Send private message

8

Monday, August 8th 2005, 3:43pm

Please show us the exact errors you get from the compiler.