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

Discussion in 'C Programming' started by Harsh_forC, Dec 30, 2005.

  1. Harsh_forC

    Harsh_forC Guest

    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?
     
    Harsh_forC, Dec 30, 2005
    #1
    1. Advertising

  2. Harsh_forC

    Albert Guest

    The program should work.
     
    Albert, Dec 30, 2005
    #2
    1. Advertising

  3. 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)
     
    Richard Heathfield, Dec 30, 2005
    #3
  4. 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)
     
    Richard Heathfield, Dec 30, 2005
    #4
  5. Harsh_forC

    Albert Guest

    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.
     
    Albert, Dec 30, 2005
    #5
  6. Harsh_forC

    Jack Klein Guest

    On 29 Dec 2005 19:51:45 -0800, "Harsh_forC"
    <> 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/~ajo/docs/FAQ-acllc.html
     
    Jack Klein, Dec 30, 2005
    #6
  7. 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)
     
    Richard Heathfield, Dec 30, 2005
    #7
  8. In article <>,
    Harsh_forC <> 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?
     
    Kenny McCormack, Dec 30, 2005
    #8
  9. On 29 Dec 2005 19:51:45 -0800, in comp.lang.c , "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"


    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 =----
     
    Mark McIntyre, Dec 30, 2005
    #9
  10. Harsh_forC

    Joe Wright Guest

    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 ---
     
    Joe Wright, Dec 30, 2005
    #10
  11. Harsh_forC

    ozbear Guest

    On Fri, 30 Dec 2005 12:20:55 +0000, Mark McIntyre
    <> wrote:

    >On 29 Dec 2005 19:51:45 -0800, in comp.lang.c , "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"

    >
    >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?
     
    ozbear, Dec 30, 2005
    #11
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Harsh_forC

    reg 'System' function

    Harsh_forC, Dec 29, 2005, in forum: C Programming
    Replies:
    7
    Views:
    336
    Mike Wahler
    Dec 30, 2005
  2. prob wid compiler

    , Mar 7, 2008, in forum: C++
    Replies:
    3
    Views:
    310
    Jim Langston
    Mar 8, 2008
  3. Shanksluvsuall
    Replies:
    0
    Views:
    374
    Shanksluvsuall
    Mar 14, 2008
  4. Lew

    Problem wid eclipse..

    Lew, Jul 20, 2008, in forum: Java
    Replies:
    3
    Views:
    378
  5. Replies:
    0
    Views:
    95
Loading...

Share This Page