473,513 Members | 2,429 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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?

Dec 30 '05 #1
10 1378
The program should work.

Dec 30 '05 #2
Harsh_forC said:
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"
If you are getting that error message, consider replacing your operating
system with one written by someone who knows English.

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

void main(void)
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.
{
int p;

p=system("time");

if(p<0)


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)
Dec 30 '05 #3
Albert said:
The program should work.


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)
Dec 30 '05 #4
Richard Heathfield:
There is no reason why it should. It is not a valid C program.


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

Dec 30 '05 #5
On 29 Dec 2005 19:51:45 -0800, "Harsh_forC"
<sr***************@gmail.com> wrote in comp.lang.c:
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"
You'll get better results if you don't write like an idiot.
#include<stdlib.h>
#include<stdio.h>

void main(void)
Oops, not a valid C program once you define main() with a return type
of void instead of int.
{
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?


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
Dec 30 '05 #6
Albert said:
Richard Heathfield:
There is no reason why it should. It is not a valid C program.


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


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)
Dec 30 '05 #7
In article <11**********************@z14g2000cwz.googlegroups .com>,
Harsh_forC <sr***************@gmail.com> jibber-jabbered:
....
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?


Speak English maybe?

Dec 30 '05 #8
On 29 Dec 2005 19:51:45 -0800, in comp.lang.c , "Harsh_forC"
<sr***************@gmail.com> wrote:
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"


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 =----
Dec 30 '05 #9
Harsh_forC wrote:
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?


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 ---
Dec 30 '05 #10
On Fri, 30 Dec 2005 12:20:55 +0000, Mark McIntyre
<ma**********@spamcop.net> wrote:
On 29 Dec 2005 19:51:45 -0800, in comp.lang.c , "Harsh_forC"
<sr***************@gmail.com> wrote:
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"


I very much doubt your computer printed that message.


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?
Dec 30 '05 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
4935
by: Penn Markham | last post by:
Hello all, I am writing a script where I need to use the system() function to call htpasswd. I can do this just fine on the command line...works great (see attached file, test.php). When my...
1
2340
by: Randy Jackson | last post by:
I'm attempting to debug some code that uses the System function. When the function is called, it returns Error 1. Does anyone know what that error might be, or where I can find a list of error...
1
1545
by: praba kar | last post by:
Dear All, In Php If I send a command to system function then It will return 1 on success and 0 on failure. So based upon that value I can to further work. But In Python If I send a command...
20
2532
by: Sam | last post by:
Hi I'm learning to code with C++ and wrote some very simple code. I think it's consistent with every rule but always got compiling errors that I don't understand. The code include 5 files as...
13
4061
by: Gary Wessle | last post by:
hi how can I use $wc -l file_name which puts out the number of lines. #include <cstdlib> using std::system; system (wc -l file_name) I get...
10
1796
by: Sourcerer | last post by:
I wrote this very simple code in .NET VC++. I compiled it on my system, and tried to run it on my friend's computer (he doesn't have the compiler). We both have Windows XP Professional. I have .NET...
6
3810
by: pamela fluente | last post by:
Hi, please find below a very simple code snippet which is giving me the following error: System.Runtime.Serialization.SerializationException was unhandled Message="The constructor to deserialize...
30
3474
by: galiorenye | last post by:
Hi, Given this code: A** ppA = new A*; A *pA = NULL; for(int i = 0; i < 10; ++i) { pA = ppA; //do something with pA
0
7388
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7545
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7111
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7539
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5095
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4751
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3240
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1605
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
807
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.