Re: [Dev-C++] SYSTEM() don't work in Dev-c++ ??
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Luigi S. <gi...@li...> - 2001-07-17 18:09:16
|
First: when you need the function "system" you should include <stdlib.h>.
then the prototype of "system" says:
int system(const char *s);
this means that you are allowed to pass only one string to "system", in
other words: "system" resembles "puts" and not "printf".
Try the following:
---
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX_BUF 50 /* "echo " and var will surely fit in it */
int main()
{
char var[15];
char buf[MAX_BUF];
printf("\nType the environment that u want see the value: ");
scanf("%s",&var);
strcpy(buf, "echo ");
strcat(buf, var);
system(buf);
return(0);
}
At 14.21 17/07/01 -0300, you wrote:
>Hi,
>
>I'm trying to use the system() function in dev-c++ ... but it don't work
>....
>
>I was trying of this mode:
>
>#include <stdio.h>
>#include <conio.h>
>
>int main()
>{
> char var[15];
>
> printf("\nType the environment that u want see the value: ");
> scanf("%s",&var);
>
> system("echo %s",var);
>
> return(0);
>}
>
>Then when i try compile this program i get the error:
>
>16 f:\dev-c_~1\untitl~1.cpp
> implicit declaration of function `int system(...)'
>
>
>Why ?? The system() is a function of stdio.h ?? why it don't work ... please
>show me the correct mode ... if i'm making something wrong ...
>
>thkz
>
>Cheers
>
>[ ]'s
>
>
>_______________________________________________
>Dev-cpp-users mailing list
>Dev...@li...
>http://lists.sourceforge.net/lists/listinfo/dev-cpp-users
---
gisan
|