473,721 Members | 1,763 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 1386
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.l earn.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************ **********@z14g 2000cwz.googleg roups.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

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

Similar topics

9
4963
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 webserver runs that part of the script (see attached file, snippet.php), though, it doesn't go through. I don't get an error message or anything...it just returns a "1" (whereas it should return a "0") as far as I can tell. I have read the PHP...
1
2362
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 codes for the function? Any help is most appreciated. -- Randy Jackson http://fourcolorexplosion.com
1
1565
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 to system function then It will return 0 only for both conditions(success and failure). So What I need to do for this. I want the result like php system
20
2561
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 following, delimited by //////: ////////////////pose.h #ifndef pose_h #define pose_h #include "point.h"
13
4085
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
1834
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 framework 2.0, and he had 1.0 and it didn't work; then he installed 2.0 and it still didn't work; so he tried with 2.1 and it didn't work, then 3.0 and nothing still worked. I have Intel Centrino Mobile (laptop computer), and he has Intel Pentium...
6
3824
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 an object of type 'WindowsApplication10.Form1+DictionaryExt`2' was not found." Source="mscorlib" You can just past the snippet on any form with a button.
30
3534
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
8840
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8730
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9367
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9131
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9064
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5981
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4753
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2576
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2130
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.