Connecting Tech Pros Worldwide Forums | Help | Site Map

reg 'system' function--- wid a simple code!

Harsh_forC
Guest
 
Posts: n/a
#1: Dec 30 '05
hello folks,

here i m inserting d very simple code tat im trying to execute..
but still gettin d same error msg,.." Not enuf memory"

#include<stdlib.h>
#include<stdio.h>

void main(void)
{
int p;

p=system("time");

if(p<0)
{
perror("Error:");
exit(1);
}
}


i also tried executing dis code in my frd's comp. whoz havin double d
memory
than im havin..
but still gettin d same msg.

wat to do?


Albert
Guest
 
Posts: n/a
#2: Dec 30 '05

re: reg 'system' function--- wid a simple code!


The program should work.

Richard Heathfield
Guest
 
Posts: n/a
#3: Dec 30 '05

re: reg 'system' function--- wid a simple code!


Harsh_forC said:
[color=blue]
> hello folks,
>
> here i m inserting d very simple code tat im trying to execute..
> but still gettin d same error msg,.." Not enuf memory"[/color]

If you are getting that error message, consider replacing your operating
system with one written by someone who knows English.
[color=blue]
>
> #include<stdlib.h>
> #include<stdio.h>
>
> void main(void)[/color]

Stop right there. main returns int. If you define main as having any other
return type, the C language disowns your program completely, and does not
define what will happen.
[color=blue]
> {
> int p;
>
> p=system("time");
>
> if(p<0)[/color]

The meaning of the return value of system() is implementation-dependent.
Check your documentation.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Richard Heathfield
Guest
 
Posts: n/a
#4: Dec 30 '05

re: reg 'system' function--- wid a simple code!


Albert said:
[color=blue]
> The program should work.[/color]

There is no reason why it should. It is not a valid C program.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Albert
Guest
 
Posts: n/a
#5: Dec 30 '05

re: reg 'system' function--- wid a simple code!


Richard Heathfield:
[color=blue]
> There is no reason why it should. It is not a valid C program.[/color]

Here's what I say in return - I compiled it successfully and changed my
system's time and clock successfully.

Jack Klein
Guest
 
Posts: n/a
#6: Dec 30 '05

re: reg 'system' function--- wid a simple code!


On 29 Dec 2005 19:51:45 -0800, "Harsh_forC"
<sriharsha.sripada@gmail.com> wrote in comp.lang.c:
[color=blue]
> hello folks,
>
> here i m inserting d very simple code tat im trying to execute..
> but still gettin d same error msg,.." Not enuf memory"[/color]

You'll get better results if you don't write like an idiot.
[color=blue]
> #include<stdlib.h>
> #include<stdio.h>
>
> void main(void)[/color]

Oops, not a valid C program once you define main() with a return type
of void instead of int.
[color=blue]
> {
> int p;
>
> p=system("time");
>
> if(p<0)
> {
> perror("Error:");
> exit(1);
> }
> }
>
>
> i also tried executing dis code in my frd's comp. whoz havin double d
> memory
> than im havin..
> but still gettin d same msg.
>
> wat to do?[/color]

Make an effort to use proper spelling and grammar, and get rid of the
stupid abbreviations and SMS chat usage.

Then go back and read the answers you got when you posted the same
question yesterday. Especially the one by Madhav.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://c-faq.com/
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html
Richard Heathfield
Guest
 
Posts: n/a
#7: Dec 30 '05

re: reg 'system' function--- wid a simple code!


Albert said:
[color=blue]
> Richard Heathfield:
>[color=green]
>> There is no reason why it should. It is not a valid C program.[/color]
>
> Here's what I say in return - I compiled it successfully and changed my
> system's time and clock successfully.[/color]

That's as may be, but it is still not a valid C program.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Kenny McCormack
Guest
 
Posts: n/a
#8: Dec 30 '05

re: reg 'system' function--- wid a simple code!


In article <1135914705.860612.201260@z14g2000cwz.googlegroups .com>,
Harsh_forC <sriharsha.sripada@gmail.com> jibber-jabbered:
....[color=blue]
>i also tried executing dis code in my frd's comp. whoz havin double d
>memory
>than im havin..
>but still gettin d same msg.
>
>wat to do?[/color]

Speak English maybe?

Mark McIntyre
Guest
 
Posts: n/a
#9: Dec 30 '05

re: reg 'system' function--- wid a simple code!


On 29 Dec 2005 19:51:45 -0800, in comp.lang.c , "Harsh_forC"
<sriharsha.sripada@gmail.com> wrote:
[color=blue]
>hello folks,
>
> here i m inserting d very simple code tat im trying to execute..
>but still gettin d same error msg,.." Not enuf memory"[/color]

I very much doubt your computer printed that message.

(top tip: in CLC do not use abbreviations of words, this is not a
mobile phone / IM).

As for your code:
a) main returns an int, not void. Returning anything other than an int
is not well defined and may not work.

b) the return value of system is implementation defined, you can't
check it like that.

c) you may not be able to execute 'time' like that - eg on MSDOS &
Windows its a builtin shell command so you may need to invoke the
shell first. For more info, ask in a Windows programming group as the
precise details of that are offtopic here.
Mark McIntyre
--

----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Joe Wright
Guest
 
Posts: n/a
#10: Dec 30 '05

re: reg 'system' function--- wid a simple code!


Harsh_forC wrote:[color=blue]
> hello folks,
>
> here i m inserting d very simple code tat im trying to execute..
> but still gettin d same error msg,.." Not enuf memory"
>
> #include<stdlib.h>
> #include<stdio.h>
>
> void main(void)
> {
> int p;
>
> p=system("time");
>
> if(p<0)
> {
> perror("Error:");
> exit(1);
> }
> }
>
>
> i also tried executing dis code in my frd's comp. whoz havin double d
> memory
> than im havin..
> but still gettin d same msg.
>
> wat to do?
>[/color]

Learn to write English. Pay more attention writing C code. The following
works as I expect on my machine. How about yours?

#include<stdlib.h>
#include<stdio.h>

int main(void) {
int p;
p = system("time");

if (p < 0) {
perror("Error:");
exit(1);
}
return 0;
}


--
Joe Wright
"Everything should be made as simple as possible, but not simpler."
--- Albert Einstein ---
ozbear
Guest
 
Posts: n/a
#11: Dec 30 '05

re: reg 'system' function--- wid a simple code!


On Fri, 30 Dec 2005 12:20:55 +0000, Mark McIntyre
<markmcintyre@spamcop.net> wrote:
[color=blue]
>On 29 Dec 2005 19:51:45 -0800, in comp.lang.c , "Harsh_forC"
><sriharsha.sripada@gmail.com> wrote:
>[color=green]
>>hello folks,
>>
>> here i m inserting d very simple code tat im trying to execute..
>>but still gettin d same error msg,.." Not enuf memory"[/color]
>
>I very much doubt your computer printed that message.
>[/color]

He might have if he is using the 133t Windows language pack :O)

Oz
--
A: Because it fouls the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Closed Thread