Thread: system() too big?

  1. #1
    Registered User
    Join Date
    Jun 2006
    Posts
    27

    system() too big?

    I'm trying to issue a system call from my program. However, when I run the program, I get the message "Program too big to fit in memory"

    Does anyone have any idea why this is, and how I might fix this? Specifically, I'm trying to do this:

    system (Cmd);

    where Cmd is a xcopy command string. I checked the command string and it is what it's supposed to be. If I type the exact same command at the command prompt, it works fine and the folder is copied correctly. But when I'm running it from my program, it says program too big and the very next line it says "File not found - (name of folder I'm trying to copy)

    Thanks.

  2. #2
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    Maybe your program takes up so much memory that xcopy doesn't have any?

    Do you have any really big arrays?
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  3. #3
    Registered User
    Join Date
    Jun 2006
    Posts
    27
    I have some string buffers that are maximum of 600 characters. All of them together shouldn't exceed 5k bytes, I'd say. So how is it possible to run out of memory?

  4. #4
    ... kermit's Avatar
    Join Date
    Jan 2003
    Posts
    1,534
    Maybe post some code so we can have a look?

  5. #5
    Registered User
    Join Date
    Jun 2006
    Posts
    27
    Thanks for your help. Just found out I'm not supposed to use the system() call. So now I have a new problem of trying to copy files and folders manually. Still figuring out how to do that.

  6. #6
    Registered User
    Join Date
    Mar 2006
    Posts
    725
    Um... do it yourself?
    Write a recursive function which traverses the directories, copying files and creating folders as you go.

    Google: opendir, readdir, mkdir, fopen, fread, fwrite. All are part of Standard/POSIX C.
    Code:
    #include <stdio.h>
    
    void J(char*a){int f,i=0,c='1';for(;a[i]!='0';++i)if(i==81){
    puts(a);return;}for(;c<='9';++c){for(f=0;f<9;++f)if(a[i-i%27+i%9
    /3*3+f/3*9+f%3]==c||a[i%9+f*9]==c||a[i-i%9+f]==c)goto e;a[i]=c;J(a);a[i]
    ='0';e:;}}int main(int c,char**v){int t=0;if(c>1){for(;v[1][
    t];++t);if(t==81){J(v[1]);return 0;}}puts("sudoku [0-9]{81}");return 1;}

  7. #7
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    Google: opendir, readdir, mkdir, fopen, fread, fwrite. All are part of Standard/POSIX C.
    There's an FAQ entry with a sample program that parses directories.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. measuring system resources used by a function
    By Aran in forum C Programming
    Replies: 1
    Last Post: 03-13-2006, 05:35 PM
  2. New system build wont boot
    By lightatdawn in forum Tech Board
    Replies: 7
    Last Post: 12-02-2005, 06:58 AM
  3. Using mscorlib & system namespace in an MFC?
    By Robert_Sitter in forum C++ Programming
    Replies: 3
    Last Post: 11-13-2005, 06:47 PM
  4. system();
    By GanglyLamb in forum C Programming
    Replies: 5
    Last Post: 10-30-2002, 03:57 AM
  5. Big Code, Little Problem
    By CodeMonkey in forum Windows Programming
    Replies: 4
    Last Post: 10-03-2001, 05:14 PM