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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Harsh_forC

    #1

    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?

  • Albert

    #2
    Re: reg 'system' function--- wid a simple code!

    The program should work.

    Comment

    • Richard Heathfield

      #3
      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

      email: rjh at above domain (but drop the www, obviously)

      Comment

      • Richard Heathfield

        #4
        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

        email: rjh at above domain (but drop the www, obviously)

        Comment

        • Albert

          #5
          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.

          Comment

          • Jack Klein

            #6
            Re: reg 'system' function--- wid a simple code!

            On 29 Dec 2005 19:51:45 -0800, "Harsh_forC "
            <sriharsha.srip ada@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.l earn.c-c++

            Comment

            • Richard Heathfield

              #7
              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

              email: rjh at above domain (but drop the www, obviously)

              Comment

              • Kenny McCormack

                #8
                Re: reg 'system' function--- wid a simple code!

                In article <1135914705.860 612.201260@z14g 2000cwz.googleg roups.com>,
                Harsh_forC <sriharsha.srip ada@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?

                Comment

                • Mark McIntyre

                  #9
                  Re: reg 'system' function--- wid a simple code!

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

                  Comment

                  • Joe Wright

                    #10
                    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 ---

                    Comment

                    • ozbear

                      #11
                      Re: reg 'system' function--- wid a simple code!

                      On Fri, 30 Dec 2005 12:20:55 +0000, Mark McIntyre
                      <markmcintyre@s pamcop.net> wrote:
                      [color=blue]
                      >On 29 Dec 2005 19:51:45 -0800, in comp.lang.c , "Harsh_forC "
                      ><sriharsha.sri pada@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?

                      Comment

                      Working...